Under construction

Still being built. Things may change

Weird Function

Time limit0.1sMemory limit1024 MB

Summary
Given a positive integer a, find the largest gcd of (a XOR b) and (a AND b) over all b from 1 to a-1.
Level

Medium5 of 10

Topics
Bit manipulation, Math, Number theory
Solved
No attempts yet

Statement

You are given a positive integer aa. Choose an integer bb with 1≤b≤a−11 \le b \le a - 1 so that the greatest common divisor of a⊕ba \oplus b and a⊗ba \otimes b is as large as possible, and print that value. In other words, find f(A)f(A) where f(a)=max⁡0<b<agcd⁡(a⊕b,a⊗b)f(a) = \max_{0<b<a} \gcd(a \oplus b, a \otimes b) Here ⊕\oplus is bitwise XOR and ⊗\otimes is bitwise AND. The operations on single bits are defined by the table below.

aabba⊕ba \oplus ba⊗ba \otimes b
0000
0110
1010
1101

For longer numbers, the operation is applied to the binary digits of the two operands position by position, and the resulting bits form the answer in binary. For example, 101⊕11=110101 \oplus 11 = 110 and 101⊗11=1101 \otimes 11 = 1, while 111⊕101010=101101111 \oplus 101010 = 101101 and 111⊗101010=10111 \otimes 101010 = 10.

Input

The first line contains the number of queries NN (1≤N≤1 0001 \le N \le 1\,000). Each of the next NN lines contains one integer AiA_i (2≤Ai<2252 \le A_i < 2^{25}).

Output

Print NN lines. On line ii, print the value of f(Ai)f(A_i).

Examples1

  1. Example 1

    Input
    3
    2
    3
    5
    
    Expected output
    3
    1
    7