{"raw_statement":[{"iden":"problem statement","content":"There is an array $A_1, \\ldots, A_N$, and initially $A_i = i$ for all $i$. Define the following routine $\\mathrm{shuffle}(L, R)$:\n\n*   If $R = L + 1$, swap values of $A_L$ and $A_R$ and terminate.\n*   Otherwise, run $\\mathrm{shuffle}(L, R - 1)$ followed by $\\mathrm{shuffle}(L + 1, R)$.\n\nSuppose we run $\\mathrm{shuffle}(1, N)$. Print the value of $A_K$ after the routine finishes.\nFor each input file, solve $T$ test cases."},{"iden":"constraints","content":"*   $1 \\leq T \\leq 1000$\n*   $2 \\leq N \\leq 10^{18}$\n*   $1 \\leq K \\leq N$"},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$T$\n$case_1$\n$case_2$\n$\\vdots$\n$case_T$\n\nEach case is in the following format:\n\n$N$ $K$"},{"iden":"sample input 1","content":"7\n2 1\n2 2\n5 1\n5 2\n5 3\n5 4\n5 5"},{"iden":"sample output 1","content":"2\n1\n2\n4\n1\n5\n3\n\nFor $N=2$, we do the following and get $A=(2,1)$.\n\n*   Run $\\mathrm{shuffle}(1, 2)$, and swap $A_1$ and $A_2$.\n\nFor $N=5$, we do the following and get $A=(2,4,1,5,3)$.\n\n*   Run $\\mathrm{shuffle}(1, 5)$:\n    *   Run $\\mathrm{shuffle}(1, 4)$:\n        *   Run $\\mathrm{shuffle}(1, 3)$:\n            *   $\\vdots$\n        *   Run $\\mathrm{shuffle}(2, 4)$:\n            *   $\\vdots$\n    *   Run $\\mathrm{shuffle}(2, 5)$:\n        *   Run $\\mathrm{shuffle}(2, 4)$:\n            *   $\\vdots$\n        *   Run $\\mathrm{shuffle}(3, 5)$:\n            *   $\\vdots$"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}