题目
#include <iostream>
using namespace std;
int f(int n, int m)
{int t, res;if (n > m){t = n;n = m;m = t;}if (n == 1)res = (m + 1) / 2;else if (n == 2){if (m % 3 == 0)res = 2;elseres = 1;}else if (n == 3){res = 2;}return res;
}
int change(int x)
{x %= 3;if (x == 0)x += 3;return x;
}
int main()
{int T, n, m, i, j;cin >> T;while (T--){cin >> n >> m;int t;if (n > m)t = n, n = m, m = t;if (n <= 3)cout << f(n, m) << '\n';else{if (n % 3 == 0 || m % 3 == 0)cout << 2 << '\n';elsecout << 1 << '\n';}}return 0;
}