#include<bits/stdc++.h>
using namespace std;
long long q,a,b;
void input()
{
    cin >> q;
}
void solve()
{
    while(q--)
    {
        long long mask = (1ll<<5ll)-1ll;
        cin >> a >> b;
        long long res_xor = ((mask&a)^(mask&b));
        a= a>>5;
        b= b>>5;
        long long res_and = ((mask&a)&(mask&b))<<5;
        a= a>>5;
        b= b>>5;
        long long res_or = ((mask&a)|(mask&b))<<10;
        long long ans = (res_xor|res_and)|res_or;
        cout << ans <<"\n";
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    input();
    solve();

}
