Recursive Survival

Time Limit: 1 Second    Memory Limit: 32768 KB

n people numbered 1 to n around a circle, we eliminate every second remaining person until only one survives. Define a function J(n), represents the survivor's original number in the circle. For example, J(2)=1, J(10)=5. Now, please calculate this nested function: J(J(J(..J(n)..)))

Input

There are multiple test cases, each with two positive numbers in one line.

The first number represents the number of the people in original cirlcle, the second one represents the times of the function nested.

All the numbers in input file will be less than 2^63-1.

Output

output the result in one line per test case.

Sample Input

2 1
10 1
10 2

Sample Output

1
5
3
Submit

Source: ZOJ Monthly, January 2004