#nt701. 上帝与集合的正确用法

上帝与集合的正确用法

The Correct Use of God and the Set

Problem Source

BZOJ 3884

Problem Description

Given a number pp, compute

222… mod p2^{2^{2^{\dots}}} \bmod p

Input Format

The first line contains an integer TT, the number of test cases.

The next TT lines each contain one integer pp.

Output Format

A total of TT lines, each containing one integer: the answer.

Sample Input

3
2
3
6

Sample Output

0
1
4

Constraints

For all data, 1≤T≤10001\leq T\leq 1000 and 1≤p≤1071\leq p \leq 10^7 are guaranteed.