#include<stdio.h>
int main()
{
int a, b, c, d;
int T, i, j, k;
int result[10000];
int getBig = 0, temp = 0;
scanf("%d", &T);
for (i = 0; i < T; i++)
{
scanf("%d %d %d %d", &a, &b, &c, &d);
for (j = a; j <= b; j++)
{
for (k = c; k <= d; k++)
{
temp = j^k;
if (temp > getBig)
{
getBig = temp;
}
}
}
result[i] = getBig;
getBig = 0;
}
for (i = 0; i < T; i++)
{
printf("%d\n", result[i]);
}
return 0;
}