#include <bits/stdc++.h>
using namespace std;
template <class U, class V>
ostream& operator<<(ostream& os, const pair<U, V>& p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template <class U, class V>
istream& operator>>(istream& in, pair<U, V>& p) {
  in >> p.first >> p.second;
  return in;
}
namespace cp {
template <typename T>
T min(T first) {
  return first;
}
template <typename T, typename... Args>
T min(T first, Args... args) {
  return std::min(first, min(args...));
}
template <typename T>
T max(T first) {
  return first;
}
template <typename T, typename... Args>
T max(T first, Args... args) {
  return std::max(first, max(args...));
}
};  // namespace cp
using cp::max;
using cp::min;
void solvea() {
  long long n, m, res = 0;
  cin >> n >> m;
  if (n > m) swap(n, m);
  while (n > 0 && m > 0) {
    if (n == 1) {
      res += m / 2;
      if (m & 1) res++;
    } else {
      res += n + m - 2;
    }
    n -= 2, m -= 2;
  }
  cout << res << endl;
}
int main() {
  long long t;
  cin >> t;
  while (t--) solvea();
  return 0;
}
