GTW likes function

Time Limit: 4000/2000 MS (Java/Others)

Memory Limit: 131072/131072 K (Java/Others)

Description

Now you are given two definitions as follows.

$f(x)=\sum_{k=0}^{x}(-1)^{k}2^{2x-2k}C_{2x-k+1}^{k},f_{0}(x)=f(x),f_{n}(x)=f(f_{n-1}(x))(n\geq 1)$

Note that $\varphi(n)$ means Euler’s totient function.($\varphi(n)$is an arithmetic function that counts the positive integers less than or equal to n that are relatively prime to n.)

For each test case, GTW has two positive integers — $n$ and $x$, and he wants to know the value of the function $\varphi(f_{n}(x))$.

Input

There is more than one case in the input file. The number of test cases is no more than 100. Process to the end of the file.

Each line of the input file indicates a test case, containing two integers, $n$ and $x$, whose meanings are given above. $(1\leq n,x \leq 10^{12})$

Output

In each line of the output file, there should be exactly one number, indicating the value of the function $\varphi(f_{n}(x))$ of the test case respectively.

Sample Input

1 1 2 1 3 2

Sample Output

2 2 2

Hint

hujie

Source

BestCoder Round #66 (div.2)

提交代码