{"trustable":false,"sections":[{"title":"","value":{"format":"PLAIN","content":"Find the smallest integer X that has both of the following properties:\n\n1. The binary representation of X has exactly N 1’s \u0026 exactly M 0’s. \n2. The number of 1’s adjacent to one or more 0 in the binary representation is maximized.\n3. Leading Zeroes are allowed."}},{"title":"Input","value":{"format":"PLAIN","content":"The first line of the input file contains a single integer C, the number of test cases in the input file. Each of the next C lines contains two non-negative integers N and M (1 ≤ N + M ≤ 50)."}},{"title":"Output","value":{"format":"PLAIN","content":"For each test case a print the value of X, as explained in the statement, in a line by itself.\n"}},{"title":"Sample Input","value":{"format":"PLAIN","content":"3\n4 3\n1 1\n3 2"}},{"title":"Sample Output","value":{"format":"PLAIN","content":"45\n1\n13"}},{"title":"Explanation","value":{"format":"PLAIN","content":"For N \u003d 3 and M \u003d 2, some of the valid options for X are,\n\n• 7 (00111, Number of 1\u0027s adjacent to 0 is 1)\n• 11 (01011, Number of 1\u0027s adjacent to 0 is 2)\n• 13 (01101, Number of 1\u0027s adjacent to 0 is 3)\n• 21 (10101, Number of 1\u0027s adjacent to 0 is 3)\n\nThe maximum possible number of 1\u0027s adjacent to 0 is 3 in this case. 13 is the smallest number following all the properties. So, the answer is 13."}}]}