#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long double PI = acos(-1);
const long long LINF = 1LL << 60;
const int INF = 1LL << 17;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
string YES[2] = {"NO", "YES"};
string yes[2] = {"No", "Yes"};
void solve() {
  long long a, b;
  cin >> a >> b;
  vector<long long> p, q;
  while (0 < a) {
    p.push_back(a % 2);
    a /= 2;
  }
  while (0 < b) {
    q.push_back(b % 2);
    b /= 2;
  }
  if (p.size() < q.size()) swap(p, q);
  long long res = 0;
  for (long long i = 0; i < (long long)(p.size()); i++) {
    if (i < q.size() && q[i] != p[i])
      res += 1 << i;
    else if (q.size() <= i && p[i] == 1)
      res += 1 << i;
  }
  cout << res << endl;
}
int main() {
  long long times;
  cin >> times;
  while (times--) solve();
}
