#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long a, b, Res = 0;
    cin >> a >> b;
    int A[30], B[30], res[30];
    for (int i = 0; i < 30; i++) {
      A[i] = a % 2;
      a /= 2;
    }
    for (int i = 0; i < 30; i++) {
      B[i] = b % 2;
      b /= 2;
    }
    for (int i = 0; i < 30; i++) {
      if (A[i] == B[i]) {
        res[i] = 0;
      } else {
        res[i] = 1;
      }
    }
    for (int i = 29; i >= 0; i--) {
      Res *= 2;
      Res += res[i];
    }
    cout << Res << endl;
  }
}
