#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  while (n--) {
    int a, b;
    int Count = 1, sum = 0;
    cin >> a >> b;
    int temp1 = a, temp2 = b;
    vector<int> a1;
    vector<int> b1;
    while (a > 1) {
      a1.push_back(a % 2);
      a /= 2;
    }
    a1.push_back(a);
    while (b > 1) {
      b1.push_back(b % 2);
      b /= 2;
    }
    b1.push_back(b);
    int len1 = 0;
    int len2 = 0;
    while (len1 <= a1.size() - 1 && len2 <= b1.size() - 1) {
      if (a1[len1] && b1[len2]) {
        sum += pow(2, (Count - 1));
      }
      Count++;
      len1++;
      len2++;
    }
    int num1 = (temp1 ^ sum) + (temp2 ^ sum);
    cout << num1 << endl;
  }
  return 0;
}
