#include <bits/stdc++.h>

#define int long long

#define vlong vector<long>
#define vint vector<int>
#define vchar vector<char>
#define vbool vector<bool>
#define vvint vector<vint>
#define vstr vector<string>
#define vstring vstr

#define CININT(n) INTCIN(n);
#define INTCIN(n) int n; cin >> n;
#define INTCINVINTCIN(a, n) INTCIN(n); vint a(n); CINV(a, n);

#define ICVK(n, k, a) 			CININT(n); CININT(k); vint a(n); CINV(a, n);
#define ICVK1(n, k, a) 			ICVK(n, k, a)
#define ICVK2(n, k, h, a) 		CININT(n); CININT(k); CININT(h); vint a(n); CINV(a, n);
#define ICVK3(n, k, h, m, a)	CININT(n); CININT(k); CININT(h); CININT(m); vint a(n); CINV(a, n);

#define CIN(n) 			cin >> n;
#define COUT(n) 		cout << n;

#define CINV(a, n) 		for (int i = 0; i < n; i++) {cin >> a[i];}
#define CINVV(a, b, n) 	for (int i = 0; i < n; i++) {cin >> a[i] >> b[i];}

#define COUTV(a, n) 	for (int i = 0; i < n; i++) {cout << a[i] << " ";}
#define COUTVV(a, b, n) 	for (int i = 0; i < n; i++) {cout << a[i] << " " << b[i] << "\n";}

#define NOSPACE(a, n) 	for (int i = 0;i < n;i++) {cout << a[i];}
#define ENDL cout << "\n";

#define SORT(a) sort(a.begin(), a.end());
#define REVERSE(a) reverse(a.begin(), a.end());
#define HAS(theset, num) ((theset.find((num)) != (theset.end())))

#define FOR(i, n) for (int i = 0; i < n; i++)
#define YES if (true) {cout << "Yes"; return;}
#define NO if (true) {cout << "No"; return;}
#define IMPOS if (true) {cout << "Impossible"; return;}

#define SP " "

#define IMPOSS IMPOS

using namespace std;

int ans(int w, int h) {
    if (w < h) swap(w, h);
    //cout << w * h << SP;
    if (w <= 0 || h <= 0) return 0;
    if (w == 1 && h == 1) return 1;
    if (w == 2 && h == 1) return 4;
    if (w == 3 && h == 1) return 8;
    // w is always the biggest side
    if (w % 2 == 0)
        return w * h + 2 * ans(h, w/2);
    else
        return w * h + ans(h, w/2) + ans(h, w/2+1);
}


void pre() {}

// you can do this!
const bool DO_ENDL = true;
const bool MULTI_T = false; // :skull: dont forgorr me!!
void solve() {
	int w, h;
    cin >> w >> h;
    if (w < h) swap(w, h);
    cout << ans(w, h);
}


signed main() {
	pre();
	if (not MULTI_T)
		{solve();
		return 0;}
	
	CININT(t);
	while (t--) {
		solve();
		if (DO_ENDL)
			ENDL;
	}
}