#include <stdio.h>
int rd()
{
    int rs = 0,c = getchar();
    while (c < '0'||c > '9') c = getchar();
    while (c >='0'&&c <= '9')
    {
        rs = (rs<<3)+(rs<<1)+c-'0';
        c = getchar();
    }return rs;
}
void wt(int t)
{
    // 别忘了你叫什么
    if (t > 9) wt(t/10);
    putchar(t%10|48);
}

void solve()
{
    int x = rd(),y = rd(),rs = x^y;
    wt((rs&(-rs)));putchar('\n');
}
int main() {
    int t = rd();
    while (t--)solve();    return 0;
}