#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int a, b;
    cin >> a >> b;
    if ((b == 1 && a <= 2) || (a == 1 && b <= 2))
      cout << 1 << endl;
    else {
      if (a * b % 2 == 0)
        cout << (a * b / 2) << endl;
      else {
        cout << (a * b / 2) + 1 << endl;
      }
    }
  }
}
