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