PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000379. Các phép toán vô nghĩa (Meaningless Operations)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Các phép toán vô nghĩa (Meaningless Operations)

Meaningless Operations

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

For an integer a≥2a\ge2, choose an integer bb such that 1≤b<a1\le b<a to maximize

$$f(a)=\max_{1\le b<a}\gcd(a\oplus b,\ a\mathbin{\&}b).$$

Here ⊕\oplus denotes bitwise XOR and &\mathbin{\&} denotes bitwise AND, acting on the unsigned binary representations. We use gcd⁡(x,0)=x\gcd(x,0)=x for x>0x>0.

There are qq independent values of aa. Output only the maximum value f(a)f(a) for each one; do not output the optimizing bb. Queries do not affect one another.

Input

The first line contains qq. Each of the next qq lines contains one integer aa.

Output

Print exactly qq lines; line ii contains f(ai)f(a_i).

Subtasks

  • Subtask 1 (20 points): 1≤q≤151\le q\le15, 2≤ai≤1002\le a_i\le100.

  • Subtask 2 (30 points): 1≤q≤2501\le q\le250, 2≤ai≤1062\le a_i\le10^6.

  • Subtask 3 (50 points): 1≤q≤1 0001\le q\le1\,000, 2≤ai≤225−12\le a_i\le2^{25}-1.

Examples

Example 1

Input

3
2
3
5

Output

3
1
7

Explanation

For a=2a=2, choose b=1b=1: XOR is 33, AND is 00, so GCD is 33. For a=3a=3, choose b=2b=2 giving gcd⁡(1,2)=1\gcd(1,2)=1. For a=5a=5, choose b=2b=2: XOR is 77 and AND is 00, so the maximum is 77.