CF1651A.Playoff

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Playoff

Consider a playoff tournament where 2n2^n athletes compete. The athletes are numbered from 11 to 2n2^n.

The tournament is held in nn stages. In each stage, the athletes are split into pairs in such a way that each athlete belongs exactly to one pair. In each pair, the athletes compete against each other, and exactly one of them wins. The winner of each pair advances to the next stage, the athlete who was defeated gets eliminated from the tournament.

The pairs are formed as follows:

  • in the first stage, athlete 11 competes against athlete 22; 33 competes against 44; 55 competes against 66, and so on;
  • in the second stage, the winner of the match "1122" competes against the winner of the match "3344"; the winner of the match "5566" competes against the winner of the match "7788", and so on;
  • the next stages are held according to the same rules.

When athletes xx and yy compete, the winner is decided as follows:

  • if x+yx+y is odd, the athlete with the lower index wins (i. e. if x<yx \lt y, then xx wins, otherwise yy wins);
  • if x+yx+y is even, the athlete with the higher index wins.

The following picture describes the way the tournament with n=3n = 3 goes.

Your task is the following one: given the integer nn, determine the index of the athlete who wins the tournament.

Input

The first line contains one integer tt (1t301 \le t \le 30) — the number of test cases.

Each test case consists of one line containing one integer nn (1n301 \le n \le 30).

Output

For each test case, print one integer — the index of the winner of the tournament.

Note

The case n=3n = 3 is shown in the picture from the statement.

If n=1n = 1, then there's only one match between athletes 11 and 22. Since 1+2=31 + 2 = 3 is an odd number, the athlete with the lower index wins. So, the athlete 11 is the winner.

Samples

2
3
1
7
1

在线编程 IDE

建议全屏模式获得最佳体验