#include<bits/stdc++.h>
typedef unsigned long long ll;
using namespace std;
ll t,n,m;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> t;
while(t--){
cin >> n >> m;
ll sum = 4ll * ceil(n * m / 2.0) - m - n - (m % 2 == 1 && n % 2 == 1 ? 2 : 0);
cout << sum << endl;
}
}
考试时手推的公式,不知道哪里错了。