#include <bits/stdc++.h>
using namespace std;
int a[50];
int b[50];
int f(int x, int y) {
  int cnt = 0;
  while (x) {
    a[cnt] = x % 2;
    x /= 2;
    cnt++;
  }
  int ans = 0;
  while (y) {
    b[ans] = y % 2;
    y /= 2;
    ans++;
  }
  return max(ans, cnt);
}
int c[50];
void as(int n) {
  int i;
  for (i = 0; i < n; i++) {
    if (a[i] == b[i])
      c[i] = 0;
    else
      c[i] = 1;
  }
  long long sum = 0;
  long long x = 1;
  for (i = 0; i < n; i++) {
    sum += x * c[i];
    x *= 2;
  }
  cout << sum << endl;
}
int main() {
  int t;
  cin >> t;
  int i;
  while (t--) {
    for (i = 0; i < 50; i++) {
      a[i] = 0;
      b[i] = 0;
      c[i] = 0;
    }
    int x, y;
    cin >> x >> y;
    int cnt = f(x, y);
    as(cnt);
  }
  return 0;
}
