Open the Dragon Scroll

All submissions for this problem are available.
Did you ever hear about 'Dragon Food' ? Its used to refer to the chocolates bought for your loved ones :). Po offers dragon food to master Shifu, who is a famous cook in the valley of food. In return, Shifu hands over the dragon scroll to Po, which is said to hold the ingredients of the secret recipe. To open the dragon scroll, one has to solve the following puzzle.
1. Consider a Nbit integer A. We call an integer A' as shuffleA, if A' can be obtained by shuffling the bits of A in its binary representation. For eg. if N = 5 and A = 6 = (00110)_{2}, A' can be any 5bit integer having exactly two 1s in it i.e., any of (00011)_{2}, (00101)_{2}, (00110)_{2}, (01010)_{2}, ...., (11000)_{2}.
2. Given two Nbit integers A and B, find the maximum possible value of (A' xor B') where A' is a shuffleA, B' is a shuffleB and xor is the bitwise xor operator.
Given N, A and B, please help Po in opening the dragon scroll.
Notes
1. xor operator takes two bit strings of equal length and performs the logical XOR operation on each pair of corresponding bits. The result in each position is 1 if only the first bit is 1 OR only the second bit is 1, but will be 0 if both are 1 or both are 0. For eg: 5 (0101) xor 3(0011) = 6(0110). In most languages it is represented using ^ symbol. 5 ^ 3 = 6.
2. If the integer actually needs less than N bits to represent in binary, append sufficient number of leading 0 bits. For eg. as shown in the problem statement for N = 5, A = 6 = (00110)_{2}
Input
First line contains an integer T ( number of test cases, around 100 ). T cases follow, each having N A B in a single line, separated by a space. ( 1 <= N <= 30, 0 <= A,B < 2^{N} )
Output
For each case, output the maximum possible value of (shuffleA xor shuffleB) in a separate line.
Example
Input: 3 3 5 4 5 0 1 4 3 7 Output: 7 16 14
Explanation:
Case 1: 5 and 4 as 3bit binary strings are (101)_{2} and (100)_{2} respectively. After shuffling, xor can be maximum for (110)_{2} ^ (001)_{2} = (111)_{2} = 7
Case 2: Maximum Possible result can be for (00000)_{2} ^ (10000)_{2} = (10000)_{2} = 16
Case 3: Maximum Possible result can be for (0011)_{2} ^ (1101)_{2} = (1110)_{2} = 14
Author:  flying_ant 
Tester:  masked_zorro 
Editorial  http://discuss.codechef.com/problems/DRAGNXOR 
Tags  cook13, easy, flying_ant 
Date Added:  2082011 
Time Limit:  0.898401 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.5, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 