CF1937A.Shuffle Party

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

Shuffle Party

You are given an array a1,a2,,ana_1, a_2, \ldots, a_n. Initially, ai=ia_i=i for each 1in1 \le i \le n.

The operation swap(k)\texttt{swap}(k) for an integer k2k \ge 2 is defined as follows:

  • Let dd be the largest divisor^\dagger of kk which is not equal to kk itself. Then swap the elements ada_d and aka_k.

Suppose you perform swap(i)\texttt{swap}(i) for each i=2,3,,ni=2,3,\ldots, n in this exact order. Find the position of 11 in the resulting array. In other words, find such jj that aj=1a_j = 1 after performing these operations.

^\dagger An integer xx is a divisor of yy if there exists an integer zz such that y=xzy = x \cdot z.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1041 \le t \le 10^4). The description of the test cases follows.

The only line of each test case contains one integer nn (1n1091 \le n \le 10^9) — the length of the array aa.

Output

For each test case, output the position of 11 in the resulting array.

Note

In the first test case, the array is [1][1] and there are no operations performed.

In the second test case, aa changes as follows:

  • Initially, aa is [1,2,3,4][1,2,3,4].
  • After performing swap(2)\texttt{swap}(2), aa changes to [2,1,3,4][\underline{2},\underline{1},3,4] (the elements being swapped are underlined).
  • After performing swap(3)\texttt{swap}(3), aa changes to [3,1,2,4][\underline{3},1,\underline{2},4].
  • After performing swap(4)\texttt{swap}(4), aa changes to [3,4,2,1][3,\underline{4},2,\underline{1}].

Finally, the element 11 lies on index 44 (that is, a4=1a_4 = 1). Thus, the answer is 44.

Samples

4
1
4
5
120240229
1
4
4
67108864

在线编程 IDE

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