#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  int a;
  for (int i = 0; i < t; i++) {
    int n, m;
    cin >> n >> m;
    if (n == 1 && m == 1) {
      cout << 1 << endl;
    } else if ((n == 1 && m != 1) || (m == 1 && n != 1)) {
      if ((n * m) % 2 == 0) {
        a = (n * m) / 2;
        cout << a << endl;
      } else {
        a = (n * m) / 2;
        cout << a + 1 << endl;
      }
    }
    if ((n * m) % 2 == 1 && n != 1 && m != 1) {
      a = (n * m) / 2;
      a++;
      cout << a << endl;
    }
    if ((n * m) % 2 == 0 && n != 1 && m != 1) {
      a = (n * m) / 2;
      cout << a << endl;
    }
  }
  return 0;
}
