#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int test_case = 0; test_case < t; ++test_case) {
    int a, b;
    cin >> a >> b;
    long long res = 0;
    for (int i = 0; (1ll << i) <= a and (1ll << i) <= b; ++i) {
      const long long temp = 1ll << i;
      if (temp & a and temp & b) {
        res += temp;
      }
    }
    cout << (a ^ res) + (b ^ res) << endl;
  }
  return 0;
}
