#include <bits/stdc++.h>
using namespace std;
long long md = 1e9 + 7;
long long f_pow(long long a, long long b) {
  long long res = 1, temp = a;
  while (b) {
    if (b & 1) res = res * temp % md;
    temp = temp * temp % md;
    b >>= 1;
  }
  return res;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b;
    cin >> a >> b;
    cout << f_pow(max((min(a, b) * 2), max(a, b)), 2) << endl;
  }
  return 0;
}
