#include

#include<math.h>

#include

using namespace std;

```
int main()
{
int t;
scanf("%d", &t);
while(t--)
{
int n, a, b, count = 0, count1 = 0;
scanf("%d%d%d", &n, &a, &b);
int p[n], q[n];
//finding the binary of given decimals.
for(int i = n; i > 0; i--)
{
if(a >= 0)
{
p[i] = a % 2;
if(p[i] == 1)
count++;
a = a / 2;
}
if(b >= 0)
{
q[i] = b % 2;
if(q[i] == 1)
count1++;
b = b / 2;
}
}
//z is the number of 1's in the binary of two decimals together
int z = count + count1;
for(int i = 1; i <= n; i++)
p[i] = 0;
int i = 2;
while(z > n)
z = z - i;
for(i = 1; i <= z; i++)
p[i] = 1;
//converting the final answer from binary to decimal
int sum = 0, j;
for(i = n - 1,j = 1; i >= 0, j <= n; i--, j++)
sum = sum + (p[j]*pow(2, i));
printf("%d\n", sum);
}
return 0;
}
```