#include<iostream>
using namespace std;
int oddSum(int n) {
return n * n * (2 * n * n - 1);
}
int evenSum(int n) {
return 2 * 2 * n * (n + 1) * (2*n + 1) / 6;
}
int main() {
int N, m, n;
cin >> N;
while (N--) {
cin >> m >> n;
if (m > n) swap(m, n);
// sum(x^2) | m n
// 1^2 + ... + n^2 = n*(n+1)*(2n+1)/6
// (2*1)^2 + ... + (2*n)^2 = 4 * ( 1^2 + ... + n^2) = 4 * n*(n+1)*(2n+1)/6
cout << evenSum(n) - evenSum(m) << endl;
// 奇数sum(x^3) | m n
// (2*1-1)^3 + ... + (2*n-1)^3 = n^2 * (2*n^2 -1)
cout << oddSum(n) - oddSum(m) << endl;
}
}