#pragma comment(linker, "/STACK:33554432")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cstring>

using namespace std;
void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
	cerr << H << ' ';
	dout(T...);
}

using ll = long long;
using pii = pair<int, int>;
using ld = long double;
using pll = pair<long long, long long>;

const int MAXN = 100004;
const int MAXK = 26 * 2;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const ld EPS = 1e-9;
const ll INF = numeric_limits<long long> ::max() / 4;
const ll MSIZE = 20;
const ld pi = acos(-1.0);
const int MAXP = 19;

ll inp[MAXN];

vector<ll> diff;

ll get_del(ll num)
{
	ll p = 2;

	while (p * p <= num)
	{
		if (num % p == 0)
			return num / p;
		p += 1;
	}

	return 1;
}

void ans_q()
{
	ll num;
	cin >> num;

	ll base = 1;

	while (base <= num)
	{
		base *= 2;
	}

	if (base != num + 1)
	{
		cout << base - 1;
	}
	else
	{
		cout << get_del(base - 1);
	}
	cout << "\n";
}

void solve()
{
	int q;
	cin >> q;

	for (int i = 0; i < q; i++)
		ans_q();
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cout << fixed << setprecision(20);
#ifdef LOCAL
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	solve();
#ifdef LOCAL
	cout << '\n' << (double)clock() / CLOCKS_PER_SEC << '\n';
#endif
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
vector <unsigned int> powers_of_two;

unsigned int get_bigest_divider(unsigned int a) {
	for (unsigned int i = a - 1; i >= 1; i--) {
		if (a % i == 0) {
			return i;
		}
	}

	return 1;
}

unsigned int get_first_biger_power_of_two(unsigned int a) {
	vector <unsigned int>::iterator it = powers_of_two.begin();

	while (*it <= a) {
		it++;
	}
	return *it;
}

unsigned int get_function_result(unsigned int a) {
	unsigned int ret = 0;

	unsigned int power_of_two = get_first_biger_power_of_two(a);

	if (a == power_of_two - 1) {
		ret = get_bigest_divider(a);
	}
	else {
		ret = power_of_two - 1;
	}
	return ret;
}

void set_powers_of_two() {
	unsigned int power_of_two = 1;
	for (int i = 0; i < 26; i++) {
		powers_of_two.push_back(power_of_two);
		power_of_two *= 2;
	}
}
int main()
{
	set_powers_of_two();
	int q;
	unsigned int input_int = 0;

	cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> input_int;
		//cout << endl << "Answer: " << get_additional_number(input_int) << endl;
		cout << get_function_result(input_int) << endl;
	}
	//cin >> q;
    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

unsigned int get_function_result(unsigned int a, unsigned int b) {
	unsigned int abxor = a ^ b;
	unsigned int aband = a & b;

	if (abxor == 0) {
		return aband;
	}
	else {
		if (aband == 0) {
			return abxor;
		}
	}

	for (unsigned int i = min(aband, abxor); i >= 1; i--) {
		if (aband % i == 0 && abxor % i == 0) {
			return i;
		}
	}

	return 1;
}

unsigned int get_first_biger_power_of_two(unsigned int a) {
	unsigned int ret = 1;
	while (ret <= a) {
		ret *= 2;
	}
	return ret;
}

unsigned int get_additional_number(unsigned int a) {
	unsigned int ret = 0;
	unsigned int power_of_two = get_first_biger_power_of_two(a);

	if (a == power_of_two - 1) {
		ret = a - 1;
	}
	else {
		ret = (~a) % power_of_two;
	}
	return ret;
}

int main()
{
	int q;
	unsigned int input_int = 0;

	cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> input_int;
		//cout << endl << "Answer: " << get_additional_number(input_int) << endl;
		cout << get_function_result(input_int, get_additional_number(input_int)) << endl;
	}
	//cin >> q;
    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

unsigned int get_bigest_divider(unsigned int a) {
	for (unsigned int i = a - 1; i >= 1; i--) {
		if (a % i == 0) {
			return i;
		}
	}

	return 1;
}

unsigned int get_first_biger_power_of_two(unsigned int a) {
	unsigned int ret = 1;
	while (ret <= a) {
		ret *= 2;
	}
	return ret;
}

unsigned int get_function_result(unsigned int a) {
	unsigned int ret = 0;

	unsigned int power_of_two = get_first_biger_power_of_two(a);

	if (a == power_of_two - 1) {
		ret = get_bigest_divider(a);
	}
	else {
		ret = power_of_two - 1;
	}
	return ret;
}

int main()
{
	int q;
	unsigned int input_int = 0;

	cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> input_int;
		//cout << endl << "Answer: " << get_additional_number(input_int) << endl;
		cout << get_function_result(input_int) << endl;
	}
	//cin >> q;
    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
vector <unsigned int> powers_of_two;

unsigned int get_bigest_divider(unsigned int a) {
	for (unsigned int i = 2; i < a/2; i++) {
		if (a % i == 0) {
			return a/i;
		}
	}

	return 1;
}

unsigned int get_first_biger_power_of_two(unsigned int a) {
	vector <unsigned int>::iterator it = powers_of_two.begin();

	while (*it <= a) {
		it++;
	}
	return *it;
}

unsigned int get_function_result(unsigned int a) {
	unsigned int ret = 0;

	unsigned int power_of_two = get_first_biger_power_of_two(a);

	if (a == power_of_two - 1) {
		ret = get_bigest_divider(a);
	}
	else {
		ret = power_of_two - 1;
	}
	return ret;
}

void set_powers_of_two() {
	unsigned int power_of_two = 1;
	for (int i = 0; i < 26; i++) {
		powers_of_two.push_back(power_of_two);
		power_of_two *= 2;
	}
}
int main()
{
	set_powers_of_two();
	int q;
	unsigned int input_int = 0;

	cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> input_int;
		//cout << endl << "Answer: " << get_additional_number(input_int) << endl;
		cout << get_function_result(input_int) << endl;
	}
	//cin >> q;
    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

unsigned int get_bigest_divider(unsigned int a) {
	for (unsigned int i = a - 1; i >= 1; i--) {
		if (a % i == 0) {
			return i;
		}
	}

	return 1;
}

unsigned int get_function_result(unsigned int a, unsigned int b) {
	unsigned int abxor = a ^ b;
	unsigned int aband = a & b;

	if (abxor == 0) {
		return aband;
	}
	else {
		if (aband == 0) {
			return abxor;
		}
	}

	for (unsigned int i = min(aband, abxor); i >= 1; i--) {
		if (aband % i == 0 && abxor % i == 0) {
			return i;
		}
	}

	return 1;
}

unsigned int get_first_biger_power_of_two(unsigned int a) {
	unsigned int ret = 1;
	while (ret <= a) {
		ret *= 2;
	}
	return ret;
}

unsigned int get_additional_number(unsigned int a) {
	unsigned int ret = 0;
	unsigned int power_of_two = get_first_biger_power_of_two(a);

	if (a == power_of_two - 1) {
		ret = get_bigest_divider(a);
	}
	else {
		ret = (~a) % power_of_two;
	}
	return ret;
}

int main()
{
	int q;
	unsigned int input_int = 0;

	cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> input_int;
		//cout << endl << "Answer: " << get_additional_number(input_int) << endl;
		cout << get_function_result(input_int, get_additional_number(input_int)) << endl;
	}
	//cin >> q;
    return 0;
}


//#include <array>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iostream>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <streambuf>
#include <string>
//#include <tuple>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
//#include<unordered_map>
//#include<unordered_set>
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define fil(a,b) memset(a,b,sizeof(a))
#define fl(x,l,r) for(int x=l;x<r;x++)
#define fr(x,l,r) for(int x=l;x>r;x--)
//#define fcl(x,c) for(auto x=(c).begin();x!=(c).end();x++)
//#define fcr(x,c)for(auto x=(c).rbegin();x!=(c).rend();x++)
#define sc(x) scanf("%c",&x)
#define sd(x) scanf("%d",&x)
#define sf(x) scanf("%f",&x)
#define slf(x) scanf("%lf",&x)
#define sLf(x) scanf("%lf",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define pcn(x) printf("%c\n",x)
#define pdn(x) printf("%d\n",x)
#define pfn(x) printf("%f\n",x)
#define plldn(x) printf("%lld\n",x)
#define pd(x) printf("%d",x)
#define pc(x) printf("%c",x)
#define pf(x) printf("%f",x)
#define plld(x) printf("%lld",x)
#define ps(x) printf(x)
//#define psn(x) printf(x,"\n")
//#define pub(a,b) a.push_back(b)
//#define pob(a,b) a.pop_back(b)
//#define puf(a,b) a.push_front(b)
//#define pof(a,b) a.pop_front(b)
//#define pu(a,b) a.push(b)
//#define po(a) a.pop()
//#define lall(x) beg(x), end(x)
//#define rall(x) rbeg(x),rend(x)
//#define size(X) ((int)(X).size())
//#define sortcl(v) sort(lall)
//#define sortcr(v) sort(rall)
#define mp(x,y) make_pair(x,y)
//#define loc(v,x) lower_bound(lall,x)-beg(v)
#define pi 3.141592653589793
#define ui unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define blank printf("\n")
using namespace std;
const int inf1 = 0x3f3f3f3f;
const int inf2 = 0x7fffffff;
const int infd1 = 0x42424242;
const int infd2 = 0xc2c2c2c2;
const ll INF = ((ll)1) << 61;
typedef pair<int, int> twod;
typedef pair<double, double> twof;
typedef pair<char, char> twoc;
typedef pair<char, int> cd;
typedef pair<int, char> dc;
typedef pair<double, char> fc;
typedef pair<char, double> cf;
typedef pair<double, int> fd;
typedef pair<int, double> df;
//template<typename T> using min_q = priority_queue<T, vector<T>, greater<T>>;
inline int read() {
	char c = getchar(); int x = 0; bool sgn = false;
	while (c < '0' || c > '9') { if (c == '-') { sgn = true; } c = getchar(); }
	while (c >= '0' && c <= '9') { x = (x << 1) + (x << 3) + (c & 15); c = getchar(); }
	return sgn ? -x : x;
}
const int maxn = 1e5 + 5;
const int maxe = 2e5 + 5;
int main() {
	//io;
	int q; sd(q);
	while (q--) {
		ll x; slld(x);
		ll t = log(x) / log(2)+1;
		ll y = (1 << t)-1;
		if (y != x) {
			plldn(y);
		}
		else {
			ll ans=1;
			bool first = true;
			for (ll i = 2; i*i <= y; i++) {
				if (x%i == 0) {
					ans = i;
					first = false;
					break;
				}
			}
			if (first)
				ans = 1;
			else
				ans = x / ans;
			cout << ans << endl;
		}
	}
	return 0;
}


#include <iostream>

bool istp(long a) {
	if (a == 1) {
		return true;
	}
	else {
		if (a % 2 == 0) {
			return istp(a / 2);
		}
		else {
			return false;
		}
	}
}

long gcd(long a, long b) {
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a%b);
	}
}

long main()
{

	long q, n;

	std::cin >> q;

	for (long i = 0; i < q; i++) {
		std::cin >> n;

		if (istp(n + 1)) {
			bool fl = true;
			long x = 3;
			while (fl) {
				if (n%x == 0) {
					fl = false;
					std::cout << n / x;
				}
				else {
					x += 2;
				}
			}
		}
		else {
			long x = 1;
			while (x - 1 < n) {
				x = x << 1;
			}
			std::cout << x - 1;
		}
	}
}


#include <iostream>

bool istp(long a) {
	if (a == 1) {
		return true;
	}
	else {
		if (a % 2 == 0) {
			return istp(a / 2);
		}
		else {
			return false;
		}
	}
}

long gcd(long a, long b) {
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a%b);
	}
}

long main()
{

	long q, n;

	std::cin >> q;

	for (long i = 0; i < q; i++) {
		std::cin >> n;

		if (istp(n + 1)) {
			bool fl = true;
			long x = 3;
			while (fl) {
				if (n%x == 0) {
					fl = false;
					std::cout << n / x << "\n";
				}
				else {
					x += 2;
				}
			}
		}
		else {
			long x = 1;
			while (x - 1 < n) {
				x = x << 1;
			}
			std::cout << x - 1 << "\n";
		}
	}
}


#include <iostream>

bool istp(int a) {
	if (a == 1) {
		return true;
	}
	else {
		if (a % 2 == 0) {
			return istp(a / 2);
		}
		else {
			return false;
		}
	}
}

int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a%b);
	}
}

int main()
{

	int q, n;

	std::cin >> q;

	for (int i = 0; i < q; i++) {
		std::cin >> n;

		if (istp(n + 1)) {
			bool fl = true;
			int x = 3;
			while (fl) {
				if (n%x == 0) {
					fl = false;
					std::cout << n / x;
				}
				else {
					x += 2;
				}
			}
		}
		else {
			int x = 1;
			while (x - 1 < n) {
				x = x << 1;
			}
			std::cout << x - 1;
		}
	}
}


#include <algorithm>
#include <iostream>
#include <list>
#include <numeric>
#include <random>
#include <vector>
#include <string>

using namespace std;

vector<int> p;

bool isPrime(int x) {
	if (x == 1) return false;
	int i = 0;
	while (true) {
		if (p[i] * p[i] > x)
			return true;
		if (x%p[i] == 0)
			return false;
		i++;
	}
}

int main() {
	// SIEVE
	const int N = 10000;
	vector<bool> primeBool(N + 1, true);
	for (int i = 2; i <= N; i++) {
		if (primeBool[i]) {
			for (int j = 2 * i; j <= N; j += i)
				primeBool[j] = false;
			p.push_back(i);
		}
	}

	int q;
	cin >> q;

	for (int i = 0; i < q; i++) {
		int a;
		cin >> a;

		// if a == 2^k - 1 for some k
		//		greatest factor of a, < a

		// else
		//		best = next integer greater than a of form 2^k -1

		int ret = 1;
		int a1 = a;
		bool pure = true;
		while (a1 != 0) {
			if ((a1 & 1) == 0) {
				pure = false;
			}
			a1 >>= 1;
			ret <<= 1;
		}
		ret -= 1;

		if (!pure) {
			cout << ret << endl;
			continue;
		}

		// greatest factor of a
		if (isPrime(a)) {
			cout << 1 << endl;
			continue;
		}

		int maxFac = 1;
		int j = 0;
		while (a != 1) {
			while (a % p[j] == 0) {
				maxFac = p[j];
				a /= p[j];
			}
			j++;
		}
		cout << maxFac << endl;
		continue;
	}
}


#include <algorithm>
#include <iostream>
#include <list>
#include <numeric>
#include <random>
#include <vector>
#include <string>

using namespace std;

vector<int> p;

bool isPrime(int x) {
	if (x == 1) return false;
	int i = 0;
	while (true) {
		if (p[i] * p[i] > x)
			return true;
		if (x%p[i] == 0)
			return false;
		i++;
	}
}

int main() {
	// SIEVE
	const int N = 10000;
	vector<bool> primeBool(N + 1, true);
	for (int i = 2; i <= N; i++) {
		if (primeBool[i]) {
			for (int j = 2 * i; j <= N; j += i)
				primeBool[j] = false;
			p.push_back(i);
		}
	}

	int q;
	cin >> q;

	for (int i = 0; i < q; i++) {
		int a;
		cin >> a;

		// if a == 2^k - 1 for some k
		//		greatest factor of a, < a

		// else
		//		best = next integer greater than a of form 2^k -1

		int ret = 1;
		int a1 = a;
		bool pure = true;
		while (a1 != 0) {
			if ((a1 & 1) == 0) {
				pure = false;
			}
			a1 >>= 1;
			ret <<= 1;
		}
		ret -= 1;

		if (!pure) {
			cout << ret << endl;
			continue;
		}

		// greatest factor of a
		if (isPrime(a)) {
			cout << 1 << endl;
			continue;
		}

		int j = 0;
		while (a % p[j] != 0) {
			j++;
		}
		int leastFac = p[j];

		cout << a/p[j] << endl;
	}
}


#define _USE_MATH_DEFINES

//#include <bits/stdc++.h>

#include <stdlib.h>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <set>
using namespace std;

long long int n, m, k, b[1000000], c[1000000], summ, mask[100], tr, x;

double maxx;

string s1, s2;

int compare(const void * a, const void * b) {

	return ((*(long long int*)a)) - ((*(long long int*)b));

};

void getMask(long long int a) {

	k = 0;

	while (a > 0) {

		mask[k] = a % 2;
		a = a / 2;
		k++;

	}

}

//qsort(values,6,sizeof(int),compare);

int main() {

	//freopen("schools.in","r",stdin);
	//freopen("schools.out","w",stdout);

	cin >> n;

	for (int i = 0; i < n; i++) {

		cin >> tr;

		getMask(tr);

		summ = pow(2, k) - 1;

		if (summ == tr) {

			x = 1;

			for (long long int j = 2; j*j <= summ; j++) {

				if (summ % j == 0) {

					x = max(j, summ / j);

				}

			}

			cout << x << endl;

		}
		else {

			cout << summ << endl;

		}

	}

	return 0;

}


#define _USE_MATH_DEFINES

//#include <bits/stdc++.h>

#include <stdlib.h>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <set>
using namespace std;

long long int n, m, k, b[1000000], c[1000000], summ, mask[100], tr;

double maxx;

string s1, s2;

int compare(const void * a, const void * b) {

	return ((*(long long int*)a)) - ((*(long long int*)b));

};

void getMask(long long int a) {

	k = 0;

	while (a > 0) {

		mask[k] = a % 2;
		a = a / 2;
		k++;

	}

}

//qsort(values,6,sizeof(int),compare);

int main() {

	//freopen("schools.in","r",stdin);
	//freopen("schools.out","w",stdout);

	cin >> n;

	for (int i = 0; i < n; i++) {

		cin >> tr;

		getMask(tr);

		summ = pow(2, k) - 1;

		if (summ == tr) {

			cout << 1 << endl;

		}
		else {

			cout << summ << endl;

		}

	}

	return 0;

}


#define _USE_MATH_DEFINES

//#include <bits/stdc++.h>

#include <stdlib.h>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <set>
using namespace std;

long long int n, m, k, b[1000000], c[1000000], summ, mask[100], tr, x;

double maxx;

string s1, s2;

int compare(const void * a, const void * b) {

	return ((*(long long int*)a)) - ((*(long long int*)b));

};

void getMask(long long int a) {

	k = 0;

	while (a > 0) {

		mask[k] = a % 2;
		a = a / 2;
		k++;

	}

}

//qsort(values,6,sizeof(int),compare);

int main() {

	//freopen("schools.in","r",stdin);
	//freopen("schools.out","w",stdout);

	cin >> n;

	for (int i = 0; i < n; i++) {

		cin >> tr;

		getMask(tr);

		summ = pow(2, k) - 1;

		if (summ == tr) {

			x = 1;

			for (long long int j = 2; j*j <= summ; j++) {

				if (summ % j == 0 && j*j != summ) {

					x = max(max(j, summ / j), x);

				}
				else
				if (summ % j == 0) {

					x = max(j, x);

				}

			}

			cout << (long long int) x << endl;

		}
		else {

			cout << (long long int) summ << endl;

		}

	}

	return 0;

}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;

unsigned int a[1000];
int Pow[27];

int is_prime(int n)
{
	int t = sqrt(n * 1.0) + 1;
	int i = 3;
	for (i = 3; i <= t; i += 2)
	{
		if (n % i==0)
		{
			return i;
		}
	}
	return 1;
}

int main()
{
	int q;
	cin >> q;
	Pow[0] = 1;
	for (int i = 1; i <= 25; i++)
	{
		Pow[i] = Pow[i - 1] * 2;
	}
	for (int i = 0; i < q; i++)
	{
		cin >> a[i];
		int j = 0;
		while (a[i] + 1 > Pow[j])
		{
			j++;
		}
		if ((a[i]+1) == Pow[j])
		{
			int t = is_prime(a[i]);
			if (t == 1)
				cout << 1 << endl;
			else
				cout << a[i] / t << endl;
		}
		else
		{
			cout << Pow[j]-1 << endl;
		}
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;

unsigned int a[1000];
int Pow[27];

int is_prime(int n)
{
	int t = sqrt(n * 1.0) + 1;
	int i = 3;
	for (i = 3; i <= t; i += 2)
	{
		if (n % i==0)
		{
			return i;
		}
	}
	return 1;
}

int main()
{
	int q;
	cin >> q;
	Pow[0] = 1;
	for (int i = 1; i <= 25; i++)
	{
		Pow[i] = Pow[i - 1] * 2;
	}
	for (int i = 0; i < q; i++)
	{
		cin >> a[i];
		int j = 0;
		while (a[i] + 1 > Pow[j])
		{
			j++;
		}
		if ((a[i]+1) == Pow[j])
		{
			int t = is_prime(a[i]);
			if (t == 1)
				cout << 1 << endl;
			else
				cout << a[i] / t;
		}
		else
		{
			cout << Pow[j]-1 << endl;
		}
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;

unsigned int a[1000];
int Pow[27];

int main()
{
	int q;
	cin >> q;
	Pow[0] = 1;
	for (int i = 1; i <= 25; i++)
	{
		Pow[i] = Pow[i - 1] * 2;
	}
	for (int i = 0; i < q; i++)
	{
		cin >> a[i];
		int j = 0;
		while (a[i] + 1 > Pow[j])
		{
			j++;
		}
		if ((a[i]+1) == Pow[j])
		{
			cout << 1 << endl;
		}
		else
		{
			cout << Pow[j]-1 << endl;
		}
	}
	return 0;
}


#include <iostream>
#include <string>
#include <cstdio>
#include <fstream>

typedef unsigned int uint;

uint bit(uint a) {
	a |= a >> 1;
	a |= a >> 2;
	a |= a >> 4;
	a |= a >> 8;
	a |= a >> 16;
	return a;
}

uint factor(uint a) {
	uint mp = 1;
	for (uint i = 2; i * i <= a; ++i) {
		if (!(a % i)) {
			uint p = 1;
			while (!(a % i)) {
				a /= i;
				p *= i;
			}
			if (mp < p)
				mp = p;
		}
	}
	if (a > mp) {
		mp = a;
	}
	return mp;
}

uint find(uint a) {
	uint q = bit(a);
	if (q != a) {
		return q;
	}
	uint f = factor(a);
	if (a == f) {
		return 1;
	}
	return f;
}

using namespace std;
int main() {
	cin.tie(NULL);
	ios_base::sync_with_stdio(0);
	int q;
	cin >> q;
	for (int i = 0; i < q; ++i) {
		uint x;
		cin >> x;
		cout << find(x) << '\n';
	}
	return 0;
}


#include <iostream>
#include <string>
#include <cstdio>
#include <fstream>

typedef unsigned int uint;

uint bit(uint a) {
	a |= a >> 1;
	a |= a >> 2;
	a |= a >> 4;
	a |= a >> 8;
	a |= a >> 16;
	return a;
}

uint factor(uint a) {
	uint mp = 1;
	for (int i = 2; i * i <= a; ++i) {
		if (!(a % i)) {
			a /= i;
			break;
		}
	}
	return a;
}

uint find(uint a) {
	uint q = bit(a);
	if (q != a) {
		return q;
	}
	uint f = factor(a);
	if (a == f) {
		return 1;
	}
	return f;
}

using namespace std;
int main() {
	cin.tie(NULL);
	ios_base::sync_with_stdio(0);
	int q;
	cin >> q;
	for (int i = 0; i < q; ++i) {
		uint x;
		cin >> x;
		cout << find(x) << '\n';
	}
	return 0;
}


#include <iostream>
#include <string>
#include <cstdio>
#include <fstream>

typedef unsigned int uint;

uint bit(uint a) {
	a |= a >> 1;
	a |= a >> 2;
	a |= a >> 4;
	a |= a >> 8;
	a |= a >> 16;
	return a;
}

uint factor(uint a) {
	uint mp = 1;
	for (int i = 2; i * i <= a; ++i) {
		if (a % i) {
			a /= i;
			break;
		}
	}
	return a;
}

uint find(uint a) {
	uint q = bit(a);
	if (q != a) {
		return q;
	}
	uint f = factor(a);
	if (a == f) {
		return 1;
	}
	return f;
}

using namespace std;
int main() {
	cin.tie(NULL);
	ios_base::sync_with_stdio(0);
	int q;
	cin >> q;
	for (int i = 0; i < q; ++i) {
		uint x;
		cin >> x;
		cout << find(x) << '\n';
	}
	return 0;
}


#include <cassert>
#include <cstdio>
#include <ctime>
#include <cstdlib>
#include <climits>
#include <cstddef>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <numeric>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
#include <list>
#include <string>
#include <functional>
#include <utility>
using namespace std;
typedef long long llint;

const int B = 25;
vector<int> prime;
set<int> A;

void init() {
    int r = int(sqrt((1 << B) - 1)) + 1;
    vector<bool> is_prime(r + 1, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= r; ++i) {
        if (!is_prime[i]) {
            continue;
        }
        prime.push_back(i);
        for (int j = i + i; j <= r; j += i) {
            is_prime[j] = false;
        }
    }
    for (int i = 1; i <= B; ++i) {
        A.insert((1 << i) - 1);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    init();
    int q;
    int a;
    cin >> q;
    while (q--) {
        cin >> a;
        if (A.find(a) != A.end()) {
            bool p = true;
            for (auto it = prime.begin(); it != prime.end(); ++it) {
                if (a % *it == 0) {
                    cout << a / *it << endl;
                    p = false;
                    break;
                }
            }
            if (p) {
                cout << 1 << endl;
            }
        } else {
            cout << *lower_bound(A.begin(), A.end(), a) << endl;
        }
    }
    return 0;
}


#include<stdio.h>
#include<math.h>

int main()
{
	int q;
	scanf("%d", &q);
	for(int i=0; i<q; i++){
		long a;
		scanf("%ld", &a);
		long k = pow(2, (int)(log(a)/log(2))+1);
//		printf("%ld", k);
		if(a!=k-1){
			printf("%ld\n", k-1);
			continue;
		}
		else{
			int find=0;
			for(int j=2; j*j<=a; j++){
				if(a%j==0){
					printf("%ld\n", a/j);
					find=1;
					break;
				}
			}
			if(!find){
				printf("1\n");
			}
		}
	}

	return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int n, a[1000], p=0;
	bool f;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		f = 0;
		p = 0;
		for (int j = 0; j < 25; j++){
			p += (1 << j);
			if (a[i] < p) {
				p -= (1 << j);
				break;
			}
			if (a[i] == p){
				f = 1;
				break;
			}
		}
		if (!f){
			//cout << (a[i] | p);
			a[i] = a[i] | p;
			//system("pause");
			//return 0;
			continue;
		}
		else {
			if (a[i] % 2 == 0){
				//cout << a[i] / 2;
				//system("pause");
				a[i] /= 2;
				//return 0;
				continue;
			}
			f = 0;
			for (int j = 3; j <= a[i]; j+=2){
				if (a[i] % j == 0){
					//cout << a[i]/j;
					a[i] /= j;
					f = 1;
					break;
					//system("pause");
					//return 0;
				}
			}
		}
	}
	for (int i = 0; i < n; i++){
		cout << a[i] << endl;
	}
	//system("pause");
	return 0;
}


#include <fstream>
#include <math.h>
#include <vector>
#include <set>
#include <algorithm>
#include <cstring>
//#include <unordered_map>
#include <iomanip>
#include <time.h>
#include <stdio.h>
#include <bitset>
#include <map>
#include <ctime>
#include <stdlib.h>
#define MAX 500000000000
#include <iostream>
#include <deque>
//#include "PEZai.h"
//#include <Tlhelp32.h>
using namespace std;
#define UNDEFINED 32432523
int n, x[100004];
int prec[] = {1, 1, 5, 1, 21, 1, 85, 73, 341, 89, 1365, 1, 5461, 4681, 21845, 1, 87381, 1, 349525, 299593, 1398101, 178481, 5592405, 1082401, 22369621};
map<long long, long long> rop;
int main()
{
    cin >> n;
    for(int i = 2; (1<<i) <= (1<<26); i++) {
       rop[(1LL<<i) - 1] = prec[i - 2];
    }
    for(int i = 0; i < n; i++) {
        cin >> x[i];
        long long base = 2, mix = 1;
        if(rop[x[i]] != 0) {
            cout << rop[x[i]] << "\n";
            continue;
        }
        while(base <= (1LL<<27LL)) {
            if(x[i] < base) {
                if((base - 1) - x[i] == ((base - 1) ^ x[i]) && (base - 1) - x[i] < x[i])
                    mix = max(mix, base);
            }
            else if(x[i] > base)
            {
                if(x[i] - (base - 1) == ((base - 1) ^ x[i]) && x[i] - (base - 1) < x[i])
                    mix = max(mix, base);
            }
            base <<= 1LL;
        }
        cout << mix - 1 << "\n";
    }
}


#include<iostream>
#include<cstdio>
#include<vector>
#include<unordered_set>
#include<set>
#include<map>
#include<unordered_map>
#include<string>
#include<queue>
#include<cmath>
#include<iomanip>
#include<ctime>
#include<algorithm>
#include<numeric>

using namespace std;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> pii;
typedef vector<pair<int,pair<int,int>>> piii;
typedef long long ll;
typedef pair<int,int> pi;

vector<pair<pair<int,pi>,pi>> Seg;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll q, tmp;
    cin>>q;
    for(int i=0;i<q;i++){
    	cin>>tmp;
    	if((tmp & (tmp+1))==0){
    		int th=int(sqrt(tmp));
    		int j;
    		for(j=2;j<th;j++){
    			if(tmp%j==0){
    				cout<<tmp/j<<endl;
    				break;
    			}
    		}
    		if(j>=th)cout<<1<<endl;
    	}
    	else{
    		while((tmp & (tmp+1))!=0){
    			tmp = (tmp | (tmp+1));
    		}
    		cout<<tmp<<endl;
    	}
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<vector>
#include<unordered_set>
#include<set>
#include<map>
#include<unordered_map>
#include<string>
#include<queue>
#include<cmath>
#include<iomanip>
#include<ctime>
#include<algorithm>
#include<numeric>

using namespace std;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> pii;
typedef vector<pair<int,pair<int,int>>> piii;
typedef long long ll;
typedef pair<int,int> pi;

vector<pair<pair<int,pi>,pi>> Seg;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll q, tmp;
    cin>>q;
    for(int i=0;i<q;i++){
    	cin>>tmp;
    	if((tmp & (tmp+1))==0){
    		int th=int(sqrt(tmp));
    		int j;
    		for(j=2;j<=th;j++){
    			if(tmp%j==0){
    				cout<<tmp/j<<endl;
    				break;
    			}
    		}
    		if(j>th)cout<<1<<endl;
    	}
    	else{
    		while((tmp & (tmp+1))!=0){
    			tmp = (tmp | (tmp+1));
    		}
    		cout<<tmp<<endl;
    	}
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<vector>
#include<unordered_set>
#include<set>
#include<map>
#include<unordered_map>
#include<string>
#include<queue>
#include<cmath>
#include<iomanip>
#include<ctime>
#include<algorithm>
#include<numeric>

using namespace std;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> pii;
typedef vector<pair<int,pair<int,int>>> piii;
typedef long long ll;
typedef pair<int,int> pi;

vector<pair<pair<int,pi>,pi>> Seg;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int q, tmp;
    cin>>q;
    for(int i=0;i<q;i++){
    	cin>>tmp;
    	if((tmp & (tmp+1))==0){
    		cout<<int(pow(2,int(log(tmp)/log(2)))-1)<<endl;
    	}
    	else
    		cout<<int(pow(2,ceil(log(tmp+1)/log(2)))-1)<<endl;
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <map>

using namespace std;

__int64 nod(__int64 a, __int64 b)
{
	while (a > 0 && b > 0)
	{
		if (a > b)
			a = a % b;
		else
			b = b % a;
	}
	return a + b;
}

int solve(int n)
{
	int b = 1;
	int m = nod(n ^ 1, n & 1);
	for (int i = 1; i < n; i++)
	{
		if (m < nod(n ^ i, n & i))
		{
			m = nod(n ^ i, n & i);
			b = i;
		}
	}
	return b;
}

__int64 sol(__int64 a)
{
	__int64 r = 1, k = 0;;
	while (r << 1 <= a)
	{
		k++;
		r <<= 1;
	}

	__int64 ans = r - a + r - 1;
	if (ans == 0)
	{
		if (k % 2 == 1)
			return a / 3;
		else
			return 1;
	}
	return ans;
}
__int64 sol1(__int64 a)
{

	if (a == 7) { return 1; return 0; }
	if (a == 31) { return 1; return 0; }
	if (a == 127) { return 1; return 0; }
	if (a == 511) { return 73; return 0; }
	if (a == 2047) { return 89; return 0; }
	if (a == 8191) { return 1; return 0; }
	if (a == 32767) { return 4681; return 0; }
	if (a == 131071) { return 1; return 0; }
	if (a == 524287) { return 1; return 0; }
	if (a == 2097151) { return 299593; return 0; }
	if (a == 8388607) { return 178481; return 0; }
	if (a == 33554431) { return 1082401; return 0; }

	return sol(a);
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.precision(20);
	cout << fixed;

	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		__int64 a, b;
		cin >> a;
		b = sol1(a);
		cout << nod(a ^ b, a & b) << endl;
	}

	return 0;
}


#include <cinttypes>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <map>
#include <numeric>
#include <type_traits>
template<typename T>
constexpr std::enable_if_t<std::is_unsigned_v<T>, unsigned int> popcount(T x) noexcept
{
	unsigned int res = 0;
	while (x)
	{
		if (x & 1U)
			++res;
		x >>= 1;
	}
	return res;
}
int main()
{
	std::uint_fast16_t q;
	std::uint_fast32_t a;
	std::map<std::uint_fast32_t, std::uint_fast32_t> table;
	table.insert(std::pair<std::uint_fast32_t, std::uint_fast32_t>(static_cast<std::uint_fast32_t>(1), static_cast<std::uint_fast32_t>(0)));
	table.insert(std::pair<std::uint_fast32_t, std::uint_fast32_t>(static_cast<std::uint_fast32_t>(3), static_cast<std::uint_fast32_t>(1)));
	table.insert(std::pair<std::uint_fast32_t, std::uint_fast32_t>(static_cast<std::uint_fast32_t>(7), static_cast<std::uint_fast32_t>(1)));
	table.insert(std::pair<std::uint_fast32_t, std::uint_fast32_t>(static_cast<std::uint_fast32_t>(15), static_cast<std::uint_fast32_t>(5)));
	table.insert(std::pair<std::uint_fast32_t, std::uint_fast32_t>(static_cast<std::uint_fast32_t>(31), static_cast<std::uint_fast32_t>(1)));
	table.insert(std::pair<std::uint_fast32_t, std::uint_fast32_t>(static_cast<std::uint_fast32_t>(63), static_cast<std::uint_fast32_t>(21)));
	table.insert(std::pair<std::uint_fast32_t, std::uint_fast32_t>(static_cast<std::uint_fast32_t>(127), static_cast<std::uint_fast32_t>(1)));
	table.insert(std::pair<std::uint_fast32_t, std::uint_fast32_t>(static_cast<std::uint_fast32_t>(255), static_cast<std::uint_fast32_t>(85)));
	table.insert(std::pair<std::uint_fast32_t, std::uint_fast32_t>(static_cast<std::uint_fast32_t>(511), static_cast<std::uint_fast32_t>(73)));
	table.insert(std::pair<std::uint_fast32_t, std::uint_fast32_t>(static_cast<std::uint_fast32_t>(1023), static_cast<std::uint_fast32_t>(341)));
	table.insert(std::pair<std::uint_fast32_t, std::uint_fast32_t>(static_cast<std::uint_fast32_t>(2047), static_cast<std::uint_fast32_t>(89)));
	table.insert(std::pair<std::uint_fast32_t, std::uint_fast32_t>(static_cast<std::uint_fast32_t>(4095), static_cast<std::uint_fast32_t>(1365)));
	table.insert(std::pair<std::uint_fast32_t, std::uint_fast32_t>(static_cast<std::uint_fast32_t>(8191), static_cast<std::uint_fast32_t>(1)));
	table.insert(std::pair<std::uint_fast32_t, std::uint_fast32_t>(static_cast<std::uint_fast32_t>(16383), static_cast<std::uint_fast32_t>(5461)));
	table.insert(std::pair<std::uint_fast32_t, std::uint_fast32_t>(static_cast<std::uint_fast32_t>(32767), static_cast<std::uint_fast32_t>(4681)));
	table.insert(std::pair<std::uint_fast32_t, std::uint_fast32_t>(static_cast<std::uint_fast32_t>(65535L), static_cast<std::uint_fast32_t>(21845)));
	table.insert(std::pair<std::uint_fast32_t, std::uint_fast32_t>(static_cast<std::uint_fast32_t>(131071L), static_cast<std::uint_fast32_t>(1)));
	table.insert(std::pair<std::uint_fast32_t, std::uint_fast32_t>(static_cast<std::uint_fast32_t>(262143L), static_cast<std::uint_fast32_t>(87381L)));
	table.insert(std::pair<std::uint_fast32_t, std::uint_fast32_t>(static_cast<std::uint_fast32_t>(524287L), static_cast<std::uint_fast32_t>(1)));
	table.insert(std::pair<std::uint_fast32_t, std::uint_fast32_t>(static_cast<std::uint_fast32_t>(1048575L), static_cast<std::uint_fast32_t>(349525L)));
	table.insert(std::pair<std::uint_fast32_t, std::uint_fast32_t>(static_cast<std::uint_fast32_t>(2097151L), static_cast<std::uint_fast32_t>(299593L)));
	table.insert(std::pair<std::uint_fast32_t, std::uint_fast32_t>(static_cast<std::uint_fast32_t>(4194303L), static_cast<std::uint_fast32_t>(1398101L)));
	table.insert(std::pair<std::uint_fast32_t, std::uint_fast32_t>(static_cast<std::uint_fast32_t>(8388607L), static_cast<std::uint_fast32_t>(178481L)));
	table.insert(std::pair<std::uint_fast32_t, std::uint_fast32_t>(static_cast<std::uint_fast32_t>(16777215L), static_cast<std::uint_fast32_t>(5592405L)));
	table.insert(std::pair<std::uint_fast32_t, std::uint_fast32_t>(static_cast<std::uint_fast32_t>(33554431L), static_cast<std::uint_fast32_t>(1082401L)));
	scanf_s("%" SCNuFAST16, &q);
	while (q--)
	{
		scanf_s("%" SCNuFAST32, &a);
		if (popcount(a + 1U) == 1U)
			printf_s("%" PRIuFAST32 "\n", table[a]);
		else
		{
			std::uint_fast32_t tmp = 1;
			while (tmp <= a)
				tmp <<= 1;
			--tmp;
			printf_s("%" PRIuFAST32 "\n", tmp);
		}
	}
	return 0;
}


#include <vector>
#include <iostream>
#include <bitset>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <utility>
#include <stdio.h>
#include <numeric>
#include <queue>
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0);
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0);
//#define int long long
#define ll long long
#define $ int
#define sz size()
#define fo for(int i=0;i<n;i++)
#define pr_ll pair<long long,long long>
#define pr_int pair<int,int>
#define pr pair
#define wh while
#define tr true
#define fls false
#define ct cout
#define cn cin
#define fri(x) for(int i=0;i<x;i++)
#define rfri(x) for(int i=x;i>=0;i--)
#define frj(x) for(int j=0;j<x;j++)
#define rfrj(x) for(int j=x;j>=0;j--)
#define frz(x) for(int z=0;z<x;z++)
#define rfrz(x) for(int z=x;z>=0;z--)
#define cst const
#define vd void;
#define mp_int map<int,int>
#define mp_ll map<long long,long long>
#define mp map
#define bg begin()
#define en end()
#define sr sort
#define all(x) x.begin(),x.end()
#define chr char
#define stn string
//#define стр string
#define tmp template
#define tpn typename
#define usn using
#define nms namespace
#define rtn return
//#define вілкой_в_глаз else
#define el else
#define sw switch
#define brk break
#define rvs reverse
#define cs case
//#define нифига 1
#define sgn signed
#define vct vector
#define vct_int vector<int>
#define vct_ll vector<long long>
#define bl bool
#define pshb(x) push_back(x)
#define _ signed main()
#define cont continue
#define frs first
#define scn second
#define dbl long double
#define frp freopen
#define mx max
#define mn min
usn nms std;
tmp<tpn T1>
T1 _gcd(T1 a, T1 b)
{
	wh(a != 0 && b != 0)
	{
		if (a > b)a %= b;
		else b %= a;
	}
	if (a == 0)rtn b;
	el rtn a;
}
int to_hex(chr ch) {
	int k = -1;
	sw(ch)
	{
		cs 'A': k = 10; brk;
		cs 'B': k = 11; brk;
		cs 'C': k = 12; brk;
		cs 'D': k = 13; brk;
		cs 'E': k = 14; brk;
		cs 'F': k = 15; brk;
		cs '1': k = 1; brk;
		cs '2': k = 2; brk;
		cs '3': k = 3; brk;
		cs '4': k = 4; brk;
		cs '5': k = 5; brk;
		cs '6': k = 6; brk;
		cs '7': k = 7; brk;
		cs '8': k = 8; brk;
		cs '9': k = 9; brk;
		cs '0': k = 0; brk;
	}
	rtn k;
}
stn to_binary($ x) {
	stn ans;
	wh(x > 0) {
		ans.push_back(x % 2 + '0');
		x /= 2;
	}
	rvs(all(ans));
	rtn ans;
}
$ to_hex(stn s)
{
	$ st = 1;
	$ a = 0;
	bool q = false;
	fri(s.size())
	{
		q = (s[i] == '0') || q;
		a += st;
		st *= 2;
	}

	if (q)rtn a;
	el rtn -1;
}
cst $ N = 1e6, M = 1000;
$ a[100000];
$ b[100000];
_
{
	__;
	$ q;
	cn >> q;
	fri(q)
	{
		$ a;
		cn >> a;
		$ w=to_hex(to_binary(a)) << '\n';

		if (w == -1)
		{
			int nb;
			fri(sqrt(a) )
			{
				if (a % (i + 2) == 0) { nb = a / (i+2); brk; }
			}
			ct << nb<<'\n';
		}
		el ct << w<<'\n';
	}
}


#include <vector>
#include <iostream>
#include <bitset>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <utility>
#include <stdio.h>
#include <numeric>
#include <queue>
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0);
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0);
//#define int long long
#define ll long long
#define $ int
#define sz size()
#define fo for(int i=0;i<n;i++)
#define pr_ll pair<long long,long long>
#define pr_int pair<int,int>
#define pr pair
#define wh while
#define tr true
#define fls false
#define ct cout
#define cn cin
#define fri(x) for(int i=0;i<x;i++)
#define rfri(x) for(int i=x;i>=0;i--)
#define frj(x) for(int j=0;j<x;j++)
#define rfrj(x) for(int j=x;j>=0;j--)
#define frz(x) for(int z=0;z<x;z++)
#define rfrz(x) for(int z=x;z>=0;z--)
#define cst const
#define vd void;
#define mp_int map<int,int>
#define mp_ll map<long long,long long>
#define mp map
#define bg begin()
#define en end()
#define sr sort
#define all(x) x.begin(),x.end()
#define chr char
#define stn string
//#define стр string
#define tmp template
#define tpn typename
#define usn using
#define nms namespace
#define rtn return
//#define вілкой_в_глаз else
#define el else
#define sw switch
#define brk break
#define rvs reverse
#define cs case
//#define нифига 1
#define sgn signed
#define vct vector
#define vct_int vector<int>
#define vct_ll vector<long long>
#define bl bool
#define pshb(x) push_back(x)
#define _ signed main()
#define cont continue
#define frs first
#define scn second
#define dbl long double
#define frp freopen
#define mx max
#define mn min
usn nms std;
tmp<tpn T1>
T1 _gcd(T1 a, T1 b)
{
	wh(a != 0 && b != 0)
	{
		if (a > b)a %= b;
		else b %= a;
	}
	if (a == 0)rtn b;
	el rtn a;
}
int to_hex(chr ch) {
	int k = -1;
	sw(ch)
	{
		cs 'A': k = 10; brk;
		cs 'B': k = 11; brk;
		cs 'C': k = 12; brk;
		cs 'D': k = 13; brk;
		cs 'E': k = 14; brk;
		cs 'F': k = 15; brk;
		cs '1': k = 1; brk;
		cs '2': k = 2; brk;
		cs '3': k = 3; brk;
		cs '4': k = 4; brk;
		cs '5': k = 5; brk;
		cs '6': k = 6; brk;
		cs '7': k = 7; brk;
		cs '8': k = 8; brk;
		cs '9': k = 9; brk;
		cs '0': k = 0; brk;
	}
	rtn k;
}
stn to_binary($ x) {
	stn ans;
	wh(x > 0) {
		ans.push_back(x % 2 + '0');
		x /= 2;
	}
	rvs(all(ans));
	rtn ans;
}
$ to_hex(stn s)
{
	$ st = 1;
	$ a = 0;
	bool q = false;
	fri(s.size())
	{
		q = (s[i] == '0') || q;
		a += st;
		st *= 2;
	}

	if (q)rtn a;
	el rtn -1;
}
cst $ N = 1e6, M = 1000;
$ a[100000];
$ b[100000];
_
{
	__;
	$ q;
	cn >> q;
	fri(q)
	{
		$ a;
		cn >> a;
		$ w=to_hex(to_binary(a));

		if (w == -1)
		{
			int nb=1;
			fri(sqrt(a) )
			{
				if (a % (i + 2) == 0) { nb = a / (i+2); brk; }
			}
			ct << nb<<'\n';
		}
		el ct << w<<'\n';
	}
}


#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <utility>
#include <stdio.h>
#include <numeric>
#include <queue>
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0);
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0);
//#define int long long
#define ll long long
#define $ int
#define sz size()
#define fo for(int i=0;i<n;i++)
#define pr_ll pair<long long,long long>
#define pr_int pair<int,int>
#define pr pair
#define wh while
#define tr true
#define fls false
#define ct cout
#define cn cin
#define fri(x) for(int i=0;i<x;i++)
#define rfri(x) for(int i=x;i>=0;i--)
#define frj(x) for(int j=0;j<x;j++)
#define rfrj(x) for(int j=x;j>=0;j--)
#define frz(x) for(int z=0;z<x;z++)
#define rfrz(x) for(int z=x;z>=0;z--)
#define cst const
#define vd void;
#define mp_int map<int,int>
#define mp_ll map<long long,long long>
#define mp map
#define bg begin()
#define en end()
#define sr sort
#define all(x) x.begin(),x.end()
#define chr char
#define stn string
//#define стр string
#define tmp template
#define tpn typename
#define usn using
#define nms namespace
#define rtn return
//#define вілкой_в_глаз else
#define el else
#define sw switch
#define brk break
#define rvs reverse
#define cs case
//#define нифига 1
#define sgn signed
#define vct vector
#define vct_int vector<int>
#define vct_ll vector<long long>
#define bl bool
#define pshb(x) push_back(x)
#define _ signed main()
#define cont continue
#define frs first
#define scn second
#define dbl long double
#define frp freopen
#define mx max
#define mn min
usn nms std;
tmp<tpn T1>
T1 _gcd(T1 a, T1 b)
{
	wh(a != 0 && b != 0)
	{
		if (a > b)a %= b;
		else b %= a;
	}
	if (a == 0)rtn b;
	el rtn a;
}
int to_hex(chr ch) {
	int k = -1;
	sw(ch)
	{
		cs 'A': k = 10; brk;
		cs 'B': k = 11; brk;
		cs 'C': k = 12; brk;
		cs 'D': k = 13; brk;
		cs 'E': k = 14; brk;
		cs 'F': k = 15; brk;
		cs '1': k = 1; brk;
		cs '2': k = 2; brk;
		cs '3': k = 3; brk;
		cs '4': k = 4; brk;
		cs '5': k = 5; brk;
		cs '6': k = 6; brk;
		cs '7': k = 7; brk;
		cs '8': k = 8; brk;
		cs '9': k = 9; brk;
		cs '0': k = 0; brk;
	}
	rtn k;
}
stn to_binary($ x) {
	stn ans;
	wh(x > 0) {
		ans.push_back(x % 2 + '0');
		x /= 2;
	}
	rvs(all(ans));
	rtn ans;
}
$ to_hex(stn s)
{
	$ st = 1;
	$ a=0;
	bool q = false;
	fri(s.size())
	{
		q = (s[i] == '0') || q;
		a += st;
		st *= 2;
	}
	if(q)rtn a;
	el rtn 1;
}
cst $ N = 1e6, M = 1000;
$ a[100000];
$ b[100000];
_
{
	__;
	$ q;
	cn >> q;
	fri(q)
	{
		$ a;
		cn >> a;
		ct << to_hex(to_binary(a)) << '\n';
	}
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <time.h>
//#include <math.h>
#include <cmath>
#include <fstream>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <stdlib.h>
#include <iomanip>
#include <cstdio>
//#include <stdio.h>

using namespace std;

#define flu fflush(stdout)
#define gg return 0
#define mp make_pair

long long mod = /*27449*//*998244353*/1e9 + 7;
int inf = 1e9;
double eps = 1e-2;

ifstream in("input.txt");
ofstream out("output.txt");

long long gcd(long long a, long long b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}

vector<int> a;

int main()
{
	int q;
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		long long t;
		cin >> t;
		long long ans = 0;
		for (int j = 0; (1 << j) <= t; j++)
		{
			if (((t >> j) & 1) == 0)
			{
				ans += (1 << j);
			}
		}

		if (ans == 0)
		{
			ans = t & 0xAAAAAAAA;
		}

		cout << gcd(ans^t, ans & t) << endl;
	}
	gg;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <time.h>
//#include <math.h>
#include <cmath>
#include <fstream>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <stdlib.h>
#include <iomanip>
#include <cstdio>
//#include <stdio.h>

using namespace std;

#define flu fflush(stdout)
#define gg return 0
#define mp make_pair

long long mod = /*27449*//*998244353*/1e9 + 7;
int inf = 1e9;
double eps = 1e-2;

ifstream in("input.txt");
ofstream out("output.txt");

long long gcd(long long a, long long b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}

vector<int> a;

int main()
{
	int q;
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		long long t;
		cin >> t;
		long long ans = 0;
		int c1 = 0, c2 = 0;
		for (int j = 0; (1 << j) <= t; j++)
		{
			c1++;
			if ((1 << j) <= t)
			{
				ans += (1 << j);
			}
			c2 += (t >> j) & 1;
		}
		if (c1 == c2)
		{
			long long d = t & 0xAAAAAAAA;
			long long d1 = t & 0x55555555;
			cout << max(gcd(t ^d, t & d), gcd(t ^d1, t & d1)) << endl;
		}
		else
		{
			cout << ans << endl;
		}
	}
	gg;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <time.h>
//#include <math.h>
#include <cmath>
#include <fstream>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <stdlib.h>
#include <iomanip>
#include <cstdio>
//#include <stdio.h>

using namespace std;

#define flu fflush(stdout)
#define gg return 0
#define mp make_pair

long long mod = /*27449*//*998244353*/1e9 + 7;
int inf = 1e9;
double eps = 1e-2;

ifstream in("input.txt");
ofstream out("output.txt");

long long gcd(long long a, long long b)
{
	if (!b) return a;
	return gcd(b, a % b);
}

int main()
{
	int q;
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		int t;
		cin >> t;
		int c1 = 0, c2 = 0;
		for (int j = 0; (1 << j) <= t; j++)
		{
			c1++;
			c2 += (t >> j) & 1;
		}
		if (c1 != c2)
		{
			cout << (1 << c1) - 1 << endl;
		}
		else
		{
			int flag = 0;
			for (int i = 2; i * i <= t; i++)
			{
				if (t % i == 0)
				{
					cout << t / i << endl;
					flag = 1;
					break;
				}
			}
			if (!flag) cout << 1 << endl;
		}
	}
	gg;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <time.h>
//#include <math.h>
#include <cmath>
#include <fstream>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <stdlib.h>
#include <iomanip>
#include <cstdio>
//#include <stdio.h>

using namespace std;

#define flu fflush(stdout)
#define gg return 0
#define mp make_pair

long long mod = /*27449*//*998244353*/1e9 + 7;
int inf = 1e9;
double eps = 1e-2;

ifstream in("input.txt");
ofstream out("output.txt");

long long gcd(long long a, long long b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}

vector<int> a;

int main()
{
	int q;
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		long long t;
		cin >> t;
		long long ans = 0;
		int c1 = 0, c2 = 0;
		for (int j = 0; (1 << j) <= t; j++)
		{
			c1++;
			if ((1 << j) <= t)
			{
				ans += (1 << j);
			}
			c2 += (t >> j) & 1;
		}
		if (c1 == c2)
		{
			long long d = t & 0xAAAAAAAA;
			long long d1 = t & 0x55555555;
			cout << max(gcd(t ^d, t & d), gcd(t ^d1, t & d1));
		}
		else
		{
			cout << ans << endl;
		}
	}
	gg;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <time.h>
//#include <math.h>
#include <cmath>
#include <fstream>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <stdlib.h>
#include <iomanip>
#include <cstdio>
//#include <stdio.h>

using namespace std;

#define flu fflush(stdout)
#define gg return 0
#define mp make_pair

long long mod = /*27449*//*998244353*/1e9 + 7;
int inf = 1e9;
double eps = 1e-2;

ifstream in("input.txt");
ofstream out("output.txt");

long long gcd(long long a, long long b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}

vector<int> a;

int main()
{
	int q;
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		int t;
		cin >> t;
		long long ans = 0;
		for (int j = 0; (1 << j) <= t; j++)
		{
			if (((t >> j) & 1) == 0)
			{
				ans += (1 << j);
			}
		}

		if (ans == 0)
		{
			for (int j = 0; (1 << j) <= t; j+=2)
			{
				ans += (1 << j);
			}
		}

		cout << gcd(ans^t, ans & t) << endl;
	}
	gg;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <time.h>
//#include <math.h>
#include <cmath>
#include <fstream>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <stdlib.h>
#include <iomanip>
#include <cstdio>
//#include <stdio.h>

using namespace std;

#define flu fflush(stdout)
#define gg return 0
#define mp make_pair

long long mod = /*27449*//*998244353*/1e9 + 7;
int inf = 1e9;
double eps = 1e-2;

ifstream in("input.txt");
ofstream out("output.txt");

long long gcd(long long a, long long b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	int q;
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		int t;
		cin >> t;
		long long ans = 0;
		for (int j = 0; (1 << j) <= t; j++)
		{
			if (((t >> j) & 1) == 0)
			{
				ans += (1 << j);
			}
		}
		if (ans == 0)
		{
			ans = t - 1;
		}
		cout << gcd(ans^t, ans & t) << endl;
	}
	gg;
}


#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>
#include <iomanip>

#define ll long long

#define FOR(i,a,b)		for(ll i=(a);i<(b);i++)
#define REP(i,n)		FOR(i,0,n)
#define SORT(v)			sort((v).begin(),(v).end())
#define UN(v)			SORT(v),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define CL(a,b)			memset(a,b,sizeof a)
#define pb				push_back

using namespace std;

ll denom = 1e9+7;
ll temp;
ll q;
vector<ll> a;

ll decimalFromStr(string s) {
    ll value = std::stoull(s, 0, 2);
    return value;
}

string binstrFromDec(ll n)
{
    std::string r;
    while(n!=0) {r=(n%2==0 ?"0":"1")+r; n/=2;}
    return r;
}

int main(int argc, const char * argv[])
{
    cin >> q;
    REP(i, q) {
        cin >> temp;
        a.push_back(temp);
    }

    REP(i, q) {
        ll result = 0;
        ll val = a[i];
        string s = binstrFromDec(val);
        bool is2pow = true;
        REP(j, s.length()) {
            if (s[j] == '0') {
                is2pow = false;
                break;
            }
        }

        if (is2pow) {
            if (s.length() % 2 == 0) {
                REP(k, s.length()) {
                    if (k%2 == 0) {
                        result += (ll)(pow((long double)(2), (long double)(k)));
                    }
                }
            }
            else {
                result = 1;
            }
        }
        else {
            result = (ll)(pow((long double)(2), (long double)(s.length()))) - 1;
        }

        cout << result << endl;
    }

    return 0;
}


#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>
#include <iomanip>

#define ll long long

#define FOR(i,a,b)		for(ll i=(a);i<(b);i++)
#define REP(i,n)		FOR(i,0,n)
#define SORT(v)			sort((v).begin(),(v).end())
#define UN(v)			SORT(v),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define CL(a,b)			memset(a,b,sizeof a)
#define pb				push_back

using namespace std;

ll denom = 1e9+7;
ll temp;
ll q;
vector<ll> a;

ll decimalFromStr(string s) {
    ll value = std::stoull(s, 0, 2);
    return value;
}

string binstrFromDec(ll n)
{
    std::string r;
    while(n!=0) {r=(n%2==0 ?"0":"1")+r; n/=2;}
    return r;
}

int main(int argc, const char * argv[])
{
    cin >> q;
    REP(i, q) {
        cin >> temp;
        a.push_back(temp);
    }

    REP(i, q) {
        ll result = 0;
        ll val = a[i];
        string s = binstrFromDec(val);
        bool is2pow = true;
        REP(j, s.length()) {
            if (s[j] == '0') {
                is2pow = false;
                break;
            }
        }

        if (is2pow) {
            REP(k, s.length()) {
                if (k%2 == 0) {
                    result += (ll)(pow((long double)(2), (long double)(k)));
                }
            }
        }
        else {
            result = (ll)(pow((long double)(2), (long double)(s.length()))) - 1;
        }

        cout << result << endl;
    }

    return 0;
}


#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>
#include <iomanip>

#define ll long long

#define FOR(i,a,b)		for(ll i=(a);i<(b);i++)
#define REP(i,n)		FOR(i,0,n)
#define SORT(v)			sort((v).begin(),(v).end())
#define UN(v)			SORT(v),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define CL(a,b)			memset(a,b,sizeof a)
#define pb				push_back

using namespace std;

ll denom = 1e9+7;
ll temp;
ll q;
vector<ll> a;

ll decimalFromStr(string s) {
    ll value = std::stoull(s, 0, 2);
    return value;
}

string binstrFromDec(ll n)
{
    std::string r;
    while(n!=0) {r=(n%2==0 ?"0":"1")+r; n/=2;}
    return r;
}

int main(int argc, const char * argv[])
{
    cin >> q;
    REP(i, q) {
        cin >> temp;
        a.push_back(temp);
    }

    ll result = 0;
    REP(i, q) {
        ll val = a[i];
        string s = binstrFromDec(val);
        bool is2pow = true;
        REP(j, s.length()) {
            if (s[j] == '0') {
                is2pow = false;
                break;
            }
        }

        if (is2pow) {
            result = 1;
        }
        else {
            result = (ll)(pow((long double)(2), (long double)(s.length()))) - 1;
        }

        cout << result << endl;
    }

    return 0;
}


#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>
#include <iomanip>

#define ll long long

#define FOR(i,a,b)		for(ll i=(a);i<(b);i++)
#define REP(i,n)		FOR(i,0,n)
#define SORT(v)			sort((v).begin(),(v).end())
#define UN(v)			SORT(v),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define CL(a,b)			memset(a,b,sizeof a)
#define pb				push_back

using namespace std;

ll denom = 1e9+7;
ll temp;
ll q;
vector<ll> a;

vector<ll> caches;

ll decimalFromStr(string s) {
    ll value = std::stoull(s, 0, 2);
    return value;
}

string binstrFromDec(ll n)
{
    std::string r;
    while(n!=0) {r=(n%2==0 ?"0":"1")+r; n/=2;}
    return r;
}

ll calculateForPow(ll pow) {
    ll result = 1;
    if (pow > 2) {
        ll a = powl((long double)2, (long double)pow) - 1;
        ll mid = (a + 1) / 2;
        for (ll i = mid + 1; i >= 1; i--) {
            if ((a-i)%i == 0) {
                result = i;
                break;
            }
        }
    }

    return result;
}

void fillCaches() {
    FOR(i, 0, 26) {
        caches.push_back(calculateForPow(i));
    }
}

int main(int argc, const char * argv[])
{
    cin >> q;
    REP(i, q) {
        cin >> temp;
        a.push_back(temp);
    }

    fillCaches();

    REP(i, q) {
        ll result = 0;
        ll val = a[i];
        string s = binstrFromDec(val);
        bool is2pow = true;
        REP(j, s.length()) {
            if (s[j] == '0') {
                is2pow = false;
                break;
            }
        }

        if (is2pow) {
            result = caches[s.length()];
        }
        else {
            result = (ll)(pow((long double)(2), (long double)(s.length()))) - 1;
        }

        cout << result << endl;
    }

    return 0;
}


#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

bool func(long long &a, long long &b)
{
	return a > b;
}

int main()
{
	long long sum;
	long long a, temp;
	long long base;
	long long r;
	long long full;
	long long lmax;
	long long i;
	long long found;

	int t, z;

	scanf("%d", &t);

	for (z = 0; z < t; z++)
	{
		base = 1;

		scanf("%I64d", &a);

		temp = a;

		full = false;

		sum = 0;

		while (temp)
		{
			r = temp % 2;

			if (r == 0)
			{
				full = true;
			}

			temp /= 2;

			sum += base;

			base *= 2;
		}

		if (full)
		{
			printf("%I64d\n", sum);

			continue;
		}

		lmax = (long long)sqrt((double)sum);

		found = false;

		for (i = 3; i <= lmax; i++)
		{
			if (!(sum%i))
			{
				printf("%I64d\n", sum / i);

				found = true;

				break;
			}
		}

		if (!found)
		{
			printf("1\n");
		}
	}

	return 0;
}


#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

bool func(long long &a, long long &b)
{
	return a > b;
}

int main()
{
	long long sum;
	long long a, temp;
	long long base;
	long long r;
	long long full;
	long long lmax;
	long long i;

	int t, z;

	scanf("%d", &t);

	for (z = 0; z < t; z++)
	{
		base = 1;

		scanf("%I64d", &a);

		temp = a;

		full = false;

		sum = 0;

		while (temp)
		{
			r = temp % 2;

			if (r == 0)
			{
				full = true;
			}

			temp /= 2;

			sum += base;

			base *= 2;
		}

		if (full)
		{
			printf("%I64d\n", sum);

			continue;
		}

		lmax = (long long)sqrt((double)sum);

		for (i = lmax; i >= 1; i--)
		{
			if (!(sum%i))
			{
				printf("%I64d\n", i);

				break;
			}
		}
	}

	return 0;
}


#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

bool func(long long &a, long long &b)
{
	return a > b;
}

int main()
{
	long long sum;
	long long a, temp;
	long long base;
	long long r;
	long long full;
	long long lmax;
	long long i;

	int t, z;

	scanf("%d", &t);

	for (z = 0; z < t; z++)
	{
		base = 1;

		scanf("%I64d", &a);

		temp = a;

		full = false;

		sum = 0;

		while (temp)
		{
			r = temp % 2;

			if (r == 0)
			{
				full = true;
			}

			temp /= 2;

			sum += base;

			base *= 2;
		}

		if (full)
		{
			printf("%I64d\n", sum);

			continue;
		}

		lmax = (long long)sqrt(sum);

		for (i = lmax; i >= 1; i--)
		{
			if (!(sum%i))
			{
				printf("%I64d\n", i);

				break;
			}
		}
	}

	return 0;
}


#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

bool func(long long &a, long long &b)
{
	return a > b;
}

int main()
{
	long long sum;
	long long a, temp;
	long long base;
	long long r;
	long long full;
	long long lmax;
	long long i;

	int t, z;

	scanf("%d", &t);

	for (z = 0; z < t; z++)
	{
		base = 1;

		scanf("%I64d", &a);

		temp = a;

		full = false;

		sum = 0;

		while (temp)
		{
			r = temp % 2;

			if (r == 0)
			{
				full = true;
			}

			temp /= 2;

			sum += base;

			base *= 2;
		}

		if (full)
		{
			printf("%I64d\n", sum);

			continue;
		}

		lmax = (long long)sqrt((double)sum);

		for (i = 3; i <= lmax; i++)
		{
			if (!(sum%i))
			{
				printf("%I64d\n", sum / i);

				break;
			}
		}

		if (i == lmax + 1)
		{
			printf("1\n");
		}
	}

	return 0;
}


#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

int main(int argc, char* argv[])
{
    int Q;
    scanf("%d", &Q);
    int q;
    for(q=0; q<Q; q++) {
        int n;
        scanf("%d", &n);

        int curr=1;
        int i;
        for(i=0; i<30; i++) {
            if(n<curr) break;
            curr*=2;
        }
        int M=i;
        if(n==curr-1) {
            int tmp=(int)sqrt((double)n)+1;
            if(tmp*tmp>n) tmp--;
            int max=1;
            for(i=2; i<=tmp; i++) {
                if(n%i==0 && n/i>1) {
                    max=MAX(max,n/i);
                    break;
                }
            }
            printf("%d\n", max);
        }
        else {
            printf("%d\n", curr-1);
        }
    }

    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
const int NN = 1100000;
using namespace std;
int q;
long long a, b;

long long gcd(long long a, long long b){
	if (b == 0) return a;
	else return gcd(b, a % b);
}

long long fnot(long long a){
	long long num = 0;
	long long tmp = 1;
	while (a > 0){
		if (a % 2 == 0) num += tmp;
		tmp = tmp * 2;
		a = a / 2;
	}
	return num;
}

int main(){

	scanf("%d", &q);
	while (q--){
		scanf("%I64dd", &a);
		if (fnot(a) != 0){
			b = fnot(a);
			printf("%I64d\n", a^b);
		} else {
			printf("%I64d\n", (a - 1) / 2);
		}
	}

	//for (int i=1; i<=1000; i++) printf("%d %lld %lld\n", i, fnot(i), gcd(i, fnot(i)));

	return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
const int NN = 1100000;
using namespace std;
int q;
long long a, b;

long long gcd(long long a, long long b){
	if (b == 0) return a;
	else return gcd(b, a % b);
}

long long fnot(long long a){
	long long num = 0;
	long long tmp = 1;
	while (a > 0){
		if (a % 2 == 0) num += tmp;
		tmp = tmp * 2;
		a = a / 2;
	}
	return num;
}

int main(){

	scanf("%d", &q);
	while (q--){
		scanf("%lld", &a);
		if (fnot(a) != 0){
			b = fnot(a);
			printf("%lld\n", a^b);
		} else {
			printf("%lld\n", (a - 1) / 2);
		}
	}

	//for (int i=1; i<=1000; i++) printf("%d %lld %lld\n", i, fnot(i), gcd(i, fnot(i)));

	return 0;
}


//JI SRI KRISHNA.//
#include<iostream>
using namespace std;
#define ll long
int main()
{
    ll n,d,a,k=0,e,i;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a;
        if(k==0)
        {
        if(i%2==0)
        {
                if(i<=a)
                {
                    d=a-i;
                }
                else
                {
                    d=i-a;
                    d=n-d;
                }
                if(i==0)
                {
                    e=d;
                }
                else
                {
                  if(e!=d)
                  {
                      k=1;
                  }
               }
        }
        else
        {
            if(i>=a)
            {
                d=i-a;
            }
            else
            {
                d=a-i;
                d=n-d;
            }
            if(e!=d)
            {
                      k=1;
            }
        }
        }
    }
   if(k==0)
    cout<<"YES"<<endl;
   else
    cout<<"NO"<<endl;
}


#include <iostream>
#include <algorithm>

#define yes printf("Yes\n");
#define no printf("No\n");

using namespace std;

int main()
{
	int n;
	cin >> n;

	int a[n];
	for (int i = 0; i < n; i++){ cin >> a[i]; }

	int count[n];

	for (int i = 0; i < n; i++)
	{
		count[i] = 0;

		if (i % 2 == 0)
		{
			while (a[i] != i)
			{
				count[i]++;
				a[i] = (a[i] + 1) % n;
			}
		}

		else
		{
			while (a[i] != i)
			{
				count[i]++;
				a[i] = (n + a[i] - 1) % n;
			}
		}
	}

	if (*max_element(count, count + n) == *min_element(count, count + n))
		yes

	else
		no

	return 0;
}


#include <iostream>
#include<vector>
#include<map>
#include <unordered_map>
#include<algorithm>
#include <string>
#include <sstream>
#include <set>
#include <queue>
#include <map>
#include <fstream>
#include <iomanip>
#include <cstdlib>
#include <bitset>
#include <stack>
#include <math.h>

#include <stdlib.h>
#include <time.h>
#include <stdio.h>

#define en "\n"

using namespace std;
namespace patch
{
	template < typename T > std::string to_string(const T& n)
	{
		std::ostringstream stm;
		stm << n;
		return stm.str();
	}
}

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const ld PI = 3.14159265358979323846;
ll mdf = 1e+9 + 7;
ld eps = 1e-12;

const ll INF = 3e18 + 1337;

int A = 4;

struct Matrix {
	vector<vector<ll>> mx = vector<vector<ll>>(A, vector<ll>(A, 0)); // max 2^32, min 0

	Matrix operator *(const Matrix& other)
	{
		Matrix temp;

		for (int i = 0; i < A; i++)
			for (int j = 0; j < A; j++)
				for (int k = 0; k < A; k++)
					temp.mx[i][j] += mx[i][k] * other.mx[k][j];

		for (int i = 0; i < A; i++)
			for (int j = 0; j < A; j++)
				temp.mx[i][j] %= mdf;

		return temp;
	};
};

Matrix exp_matrix(Matrix a, int k)
{
	Matrix temp;
	for (int i = 0; i < A; i++)
		temp.mx[i][i] = 1;

	while (k)
	{
		if (k % 2)
			temp = temp * a;

		a = a * a;
		k /= 2;
	}
	return temp;
}

ll gcd(ll a, ll b)
{
	return a == 0 ? b : gcd(b % a, a);
}

bool isAPrime(long long m)
{
	for (long long p = 2; p * p <= m; p++)
	{
		if (m % p == 0) { return false; }
	}
	return true;
}

long long binpow(long long a, long long n) {
	if (n == 0)
		return 1;
	if (n % 2 == 1)
		return (binpow(a, n - 1) * a) % mdf;
	else {
		long long b = binpow(a, n / 2) % mdf;
		return (b * b) % mdf;
	}
}

ll fact[100005];

ll C(int n, int k) {
	return fact[n] * binpow(fact[k], mdf - 2) % mdf * binpow(fact[n - k], mdf - 2) % mdf;
}

int count_setbits(int N)
{
	int cnt = 0;

	while (N > 0)
	{
		cnt += (N & 1);
		N = N >> 1;
	}

	return cnt;

}

ll phi(ll n) { //функция эйлера, вычисляет кол-во чисел взаимнопростых c n
	ll result = n;
	for (ll i = 2; i * i <= n; ++i)
		if (n % i == 0) {
			while (n % i == 0)
				n /= i;
			result -= result / i;
		}
	if (n > 1)
		result -= result / n;
	return result;
}

bool compare(pair<int, ll> a, pair<int, ll> b)
{
	return a.second < b.second;
}

int mergethem(vector<int>& a, int l, int m, int r)
{
	int Inv = 0;

	vector<int> buff(r - l + 1);
	int pos1 = l, pos2 = m + 1, posB = 0;

	while (pos1 <= m && pos2 <= r)
	{
		if (a[pos1] < a[pos2])
		{
			buff[posB++] = a[pos1++];
		}
		else
		{
			Inv += m - pos1 + 1;
			buff[posB++] = a[pos2++];
		}
	}

	while (pos1 <= m)
		buff[posB++] = a[pos1++];

	while (pos2 <= r)
		buff[posB++] = a[pos2++];

	copy(buff.begin(), buff.end(), a.begin() + l);

	return Inv;
}

int mergesort(vector<int>& a, int l, int r)
{
	int curInv = 0;
	if (l == r)
		return curInv;

	int m = (l + r) / 2;

	curInv += mergesort(a, l, m);
	curInv += mergesort(a, m + 1, r);

	curInv += mergethem(a, l, m, r);

	return curInv;
}

int sz[1];
int p[1];

int get(int v)
{
	if (p[v] != v)
		p[v] = get(p[v]);
	return p[v];
}

void union_sets(int a, int b)
{
	a = get(a);
	b = get(b);

	if (a == b) return;

	if (sz[a] > sz[b]) // a < b
		swap(a, b);

	p[a] = b;
	sz[b] += sz[a];
}

void solve(int cs) {
	//freopen("triatrip.in", "r", stdin);
	//freopen("triatrip.out", "w", stdout);

	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];

	int t = 0;
	if (a[0] != 0) t = n - a[0];

	for (int i = 0; i < n; i++)
	{
		int x;
		if (i % 2 == 0)
			x = (a[i] + t) % n;
		else
			x = (a[i] - t + n) % n;

		if (x != i)
		{
			cout << "No\n";
			return;
		}
	}

	cout << "Yes\n";
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int q = 1;
	//cin >> q;
	int i = 0;
	while (q--) solve(++i);

	return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define ll long long
int main()
{
    int n; cin >> n;
    int arr[n + 2];
    for(int i = 0; i < n; i++) cin >> arr[i];
    for(int k = 0; k < n; k++){
        for(int i = 0; i < n; i++){
            if(i%2 == 0)
                arr[i] = (arr[i] + 1) % n;
            else
                arr[i] = (arr[i] - 1 + n) % n;
        }
        int tru = 1;
        for(int i = 0; i < n - 1; i++){
            if(arr[i] + 1 != arr[i + 1])
                tru = 0;
        }
        if(tru){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define f0(n) for(size_t i=0;i<n;i++)
#define f1(n) for(size_t i=1;i<=n;i++)
#define mem(a) memset(a,0,sizeof(a))
#define memn(a) memset(a,-1,sizeof(a))
#define pb push_back
const double pi= acos(-1);

template <class T> inline T bigmod(T p,T e,T M){ll ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}
template <class T> inline T bpow(T p,T e){ll ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p);p = (p * p);}return (T)ret;}

int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
int toLlint(string s){long long int sm;stringstream ss(s);ss>>sm;return sm;}
int main()
{
  	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n;
	cin>>n;

	set<ll> s;
	ll x;
	f0(n)
	{
	    cin>>x;
	    s.insert(x);
	}
	//cout<<s.size()<<endl;
        if(s.size()<n)
        {
            cout<< "Yes" <<endl;
        }
        if(s.size()>=n)
        {
            cout<< "No" <<endl;
        }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define f0(n) for(size_t i=0;i<n;i++)
#define f1(n) for(size_t i=1;i<=n;i++)
#define mem(a) memset(a,0,sizeof(a))
#define memn(a) memset(a,-1,sizeof(a))
#define pb push_back
const double pi= acos(-1);

template <class T> inline T bigmod(T p,T e,T M){ll ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}
template <class T> inline T bpow(T p,T e){ll ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p);p = (p * p);}return (T)ret;}

int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
int toLlint(string s){long long int sm;stringstream ss(s);ss>>sm;return sm;}
int main()
{
  	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n;
	cin>>n;

	//set<ll> s;
	vector<ll> v,v2;
	ll x;
	f0(n)
	{
	    cin>>x;
	    //s.insert(x);
	    v.push_back(x);
	    v2.push_back(i);
	}
	//cout<<s.size()<<endl;
    ll t =n+1;
	while(t--)
    {
        f0(v.size())
        {
            if(i%2==0)
            {
                if(v[i]==0)
                {
                    v[i] = n  - 1;
                }
                else
                    v[i]--;
            }
            else {
				if (v[i] == n-1)
					v[i] = 0;
				else
					v[i]++;
			}
        }
        if(v==v2)
        {
            cout<< "Yes"<<endl;
                    return 0;
        }
    }
        cout<< "No"<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define f0(n) for(size_t i=0;i<n;i++)
#define f1(n) for(size_t i=1;i<=n;i++)
#define mem(a) memset(a,0,sizeof(a))
#define memn(a) memset(a,-1,sizeof(a))
#define pb push_back
const double pi= acos(-1);

template <class T> inline T bigmod(T p,T e,T M){ll ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}
template <class T> inline T bpow(T p,T e){ll ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p);p = (p * p);}return (T)ret;}

int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
int toLlint(string s){long long int sm;stringstream ss(s);ss>>sm;return sm;}
int main()
{
  	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n;
	cin>>n;

	//set<ll> s;
	vector<ll> v,v2;
	ll x;
	f0(n)
	{
	    cin>>x;
	    //s.insert(x);
	    v.push_back(x);
	    v2.push_back(i);
	}
	//cout<<s.size()<<endl;
    ll t =n+1;
	while(t--)
    {
        f0(v.size())
        {
            if(i%2==1)
            {
                if(v[i]==0)
                {
                    v[i] = n  - 1;
                }
                else
                    v[i]--;
            }
            else {
				if (v[i] == n-1)
					v[i] = 0;
				else
					v[i]++;
			}
        }
        if(v==v2)
        {
            cout<< "Yes"<<endl;
        }

    }
         cout<< "No"<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define f0(n) for(size_t i=0;i<n;i++)
#define f1(n) for(size_t i=1;i<=n;i++)
#define mem(a) memset(a,0,sizeof(a))
#define memn(a) memset(a,-1,sizeof(a))
#define pb push_back
const double pi= acos(-1);

template <class T> inline T bigmod(T p,T e,T M){ll ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}
template <class T> inline T bpow(T p,T e){ll ret = 1;for(; e > 0; e >>= 1){if(e & 1) ret = (ret * p);p = (p * p);}return (T)ret;}

int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
int toLlint(string s){long long int sm;stringstream ss(s);ss>>sm;return sm;}
int main()
{
  	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n;
	cin>>n;

	set<ll> s;
	ll x;
	f0(n)
	{
	    cin>>x;
	    s.insert(x);
	}
	//cout<<s.size()<<endl;
        if(s.size()<=n)
        {
            cout<< "Yes" <<endl;
        }
        if(s.size()>n)
        {
            cout<< "No" <<endl;
        }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int a[1005],s;

bool good()
{
	if(a[0])
		return 0;
	for(int i=1;i<s;i++)
		if(a[i]!=a[i-1]+1)
			return 0;
	return 1;
}

bool check()
{
	if(good())
		return 1;

	for(int i=1;i<s;i++)
		for(int j=0;j<s;j++)
		{
			if(j%2)
				a[j]--;
			else
				a[j]++;

			if(a[j]==s)
				a[j]=0;
			if(a[j]==-1)
				a[j]=s-1;

			if(good())
				return 1;
		}

	return 0;
}

int main()
{
	while(cin>>s)
	{
		for(int i=0;i<s;i++)
		cin>>a[i];
	    if(check())
		   cout<<"Yes\n";
	    else
			cout<<"No\n";
	}
}


#include<bits/stdc++.h>
using namespace std;

int a[1005],s;

bool good()
{
	for(int i=0;i<s;i++)
		if(a[i]!=i)
			return 0;
	return 1;
}

bool check()
{
	if(good())
		return 1;

	for(int i=1;i<s;i++)
	{
		for(int j=0;j<s;j++)
		{
			if(j%2)
				a[j]--;
			else
				a[j]++;

			if(a[j]==s)
				a[j]=0;
			if(a[j]==-1)
				a[j]=s-1;
		}
		if(good())
		    return 1;
	}

	return 0;
}

int main()
{
	cin>>s;
	for(int i=0;i<s;i++)
		cin>>a[i];
	if(check())
	   cout<<"Yes\n";
    else
		cout<<"No\n";

}


#include<bits/stdc++.h>
using namespace std;

int a[1005],size;

bool good()
{
	if(a[0])
		return 0;
	for(int i=1;i<size;i++)
		if(a[i]!=a[i-1]+1)
			return 0;
	return 1;
}

bool check()
{
	if(good())
		return 1;

	for(int i=1;i<size;i++)
		for(int j=0;j<size;j++)
		{
			if(j%2)
				a[j]--;
			else
				a[j]++;

			if(a[j]==size)
				a[j]=0;
			if(a[j]==-1)
				a[j]=size-1;

			if(good())
				return 1;
		}

	return 0;
}

int main()
{
	while(cin>>size)
	{
		for(int i=0;i<size;i++)
		cin>>a[i];
	    if(check())
		   cout<<"Yes\n";
	    else
			cout<<"No\n";
	}
}


#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n, x0, x1;
  bool real = true;
  cin >> n >> x0;
  x0 = n - x0;
  for (int i = 1; i < n && real; ++i)
    cin >> x1, real &= ((((i & 1) ? (x1 - x0 + n) : (x1 + x0)) % n) == i);
  cout << (real ? "Yes" : "No");
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n, x0, x1;
  bool real = true;
  cin >> n >> x0;
  x0 = n - x0;
  for (int i = 1; i < n && real; ++i)
    cin >> x1, real &= ((i & 1) ? (((x1 - x0 + n) % n) == i) : (((x1 + x0) % n) == i));
  cout << (real ? "Yes" : "No");
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0; i<n; i++)
#define all(c) c.begin(), c.end()
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it!=container.end(); it++)
#define present(container, element) (container.find(element)!=container.end())
#define pb push_back
typedef vector< int > vi;
typedef long long ll;
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	int first;
	cin >> first;
	int steps = (n - first) % n;
	for (int i = 1; i < n; i++)
	{
		int x;
		cin >> x;
		if (i % 2 == 0) {

			x += steps;
		}
		else
		{
			x -= steps;
		}
		x = (x + n) % n;
		if (x != i)
		{
			cout << "No";
			return 0;
		}

	}
	cout << "Yes";
	return 0;

}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define FOR_(i, a, b, x) for (int i = a; (x > 0) ? i < b : i > b; i += x)
#define FOR_1(e) FOR_(i, 0, e, 1)
#define FOR_2(i, e) FOR_(i, 0, e, 1)
#define FOR_3(i, a, e) FOR_(i, a, e, 1)
#define FOR_4(i, a, e, b) FOR_(i, a, e, b)
#define G5(a, b, c, d, e, ...) e
#define FOR_5(...) G5(__VA_ARGS__, FOR_4, FOR_3, FOR_2, FOR_1)
#define FOR(...)       \
    FOR_5(__VA_ARGS__) \
    (__VA_ARGS__)
#define IN(a, b) for (auto &a : b)

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int ref;
    cin >> ref;
    int k = (n - ref) % n;
    bool b = 1;
    FOR(i, 1, n)
    {
        int no, x;
        cin >> no;
        if (i & 1)
            x = (no - k + n) % n;
        else
            x = (no + k) % n;
        b &= x == i;
        if (!b)
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define FOR_(i, a, b, x) for (int i = a; (x > 0) ? i < b : i > b; i += x)
#define FOR_1(e) FOR_(i, 0, e, 1)
#define FOR_2(i, e) FOR_(i, 0, e, 1)
#define FOR_3(i, a, e) FOR_(i, a, e, 1)
#define FOR_4(i, a, e, b) FOR_(i, a, e, b)
#define G5(a, b, c, d, e, ...) e
#define FOR_5(...) G5(__VA_ARGS__, FOR_4, FOR_3, FOR_2, FOR_1)
#define FOR(...)       \
    FOR_5(__VA_ARGS__) \
    (__VA_ARGS__)
#define IN(a, b) for (auto &a : b)

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int ref;
    cin >> ref;
    int k = (n - ref) % n;
    bool b = 1;
    FOR(i, 1, n)
    {
        int no, x;
        cin >> no;
        if (i & 1)
        {
            x = no - k;
            if (x < 0)
                x += n;
        }
        else
            x = (no + k) % n;
        b &= x == i;
        if (!b)
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}


#include <bits/stdc++.h>
#define newline '\n'
#define uns unsigned
#define ll long long
using namespace std;
///*********************

int main()
{
    int n, f, nrrot;
    cin >> n >> f;
    nrrot = n - f;
    for (int i = 1; i < n; i++)
    {
        int x;
        cin >> x;
        if (i % 2)
        {
            x += (n - nrrot);
        }
        else
        {
            x += nrrot;
        }

        x %= n;
        if (x != i)
        {
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";
    return 0;
}


#include <bits/stdc++.h>
#define newline '\n'
#define uns unsigned
#define ll long long
using namespace std;
///*********************

int main()
{
    int n, f, nrrot;
    cin >> n >> f;
    nrrot = n - f;
    for (int i = 1; i < n; i++)
    {
        int x;
        cin >> x;
        if (i % 2)
        {
            if (nrrot > x)
                x = n;
            x -= nrrot;
        }
        else
        {
            x += nrrot;
            x %= n;
        }

        if (x != i)
        {
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
const ll mod = 1000000007;
const ll newmod = 1000003;
const double PI = 3.14159265358979323846;
using namespace std;

bool comp(pair<ll,ll> a, pair<ll,ll> b)
{
    return a.first>b.first;
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
  int n;
  cin>>n;
  int a[n];
  for(int i = 0;i<n;i++)
    cin>>a[i];
  int rot = a[0];
  int f = 0;
  for(int i = 1;i<n;i++)
  {
    if(i%2 == 1)
    {
      a[i] = (a[i]+rot)%n;
    }
    else
    {
      a[i] = (n+a[i]-rot)%n;
    }
    if(a[i]!=i)
    {
      f = 1;
      break;
    }
  }
  if(f == 1)
    cout<<"No";
  else cout<<"Yes";
}


// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll &e : a)
        cin >> e;
    ll x = 1000;
    while (x--)
    {
        for (ll i = 0; i < n; i++)
        {
            if (i % 2)
                a[i] += n - 1;
            else
                a[i]++;
            a[i] %= n;
        }
        for (ll i = 0; i < n; i++)
            if (a[i] != i)
                goto lb;
        cout << "Yes";
        return 0;
    lb:;
    }
    cout << "No";
}


#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define fbro exit(0)
#define sz(a) (a).size()
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

#define F0r(i, a, b) for(int i = a; i < b; ++i)
#define f0r(i, a) for(int i = 0; i < a; ++i)
#define F0rd(i, a, b) for(int i = a - 1; i > b; --i)
#define f0rd(i, a) for(int i = a - 1; i >= 0; --i)
#define trav(i, a) for(auto& i : (a))
void P(auto& x) {cout << x << '\n';}
void PP(auto& a, auto& b) {cout << a << " " << b << '\n';}
void PV(auto& v) {int n = sz(v); trav(i, v) cout << i << " ";cout << '\n';}
void PPV(auto& v) {int n = sz(v); trav(i, v) cout << i.F << " " << i.S << '\n';}

const ll INF = (1LL << 60);
const int MOD = 998244353;
const int nax = 2e5 + 5;
const double p = 3.14159265359;

int main(){
   ios_base::sync_with_stdio(false);
   cin.tie(nullptr);
   int n;
   cin >> n;
   vi a(n);
   trav(i, a){
      cin >> i;
   }
   int need = abs(n - a[0]);
   bool ok = true;
   F0r(i, 1, n){
      if(i & 1){
         if(a[i] >= need){
            a[i] = a[i] - need;
         }
         else{
            a[i] = a[i] - need + n;
         }
      }
      else{
         a[i] = (a[i] + need) % n;
      }
      if(a[i] != i){
         ok = false;
         break;
      }
   }
   if(ok){
      P("Yes");
   }
   else{
      P("No");
   }
   return 0;
}


#include <bits/stdc++.h>

#define MOD (1000000007)
#define EPS (1e-9)
#define INF (2117117117)
#define LLINF (2117117117117117117LL)
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define sqr(a) ((a) * (a))
#define sz(a) ((int) (a).size())
const double PI = acos(-1.0);

#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif

typedef unsigned int uint;
typedef long long llong;
typedef long double ldouble;
typedef unsigned long long ullong;

#define TASK "task"

using namespace std;

int n, a, rot;

int main()
{
#ifdef lordf
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen(TASK".in", "r", stdin);
    //freopen(TASK".out", "w", stdout);
#endif

    scanf("%d %d", &n, &a);
    rot = n - a;
    for (int i = 1; i < n; i++)
    {
        scanf("%d", &a);
        (a += ((i & 1) ? n - rot : rot)) %= n;
        if (a != i)
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,c;
    cin>>n;
    vector<int> a,b,d;
    for(int i=0;i<n;++i)
    {
        cin>>c;
        a.push_back(c);
        b.push_back(i);
    }
    d=a;
    for(int i =0; ;++i)
    {
        if(a==b)
        {
            cout<<"YES"<<endl;
            return 0;
        }
        for(int j=0;j<n;++j)
        {
            if(j%2==0)
            {
                a[j]++;
                if(a[j]==n)
                    a[j]=0;
            }
            else
            {
                a[j]--;
                if(a[j]==-1)
                    a[j]=n-1;
            }
        }
        if(a==d)
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
}


//NEVER LOSE HOPE
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#include <bits/stdc++.h>
#define int long long int
#define vi vector<int>
#define pi pair<int,int>
#define si set<int>
#define mi map<int,int>
#define ff first
#define ss second
#define pb push_back
#define all(v) v.begin(),v.end()
#define gi greater<int>()
#define mp make_pair
#define endl "\n"

//to count no of digits //floor(log10(n) + 1)

#define lb lower_bound //a,a+n,4 -a==index of 4  // returns pointer to the "first position of num" if number is present in the container. Returns pointer to the "position of next higher number greater than num" if num is not present.
#define ub upper_bound // returns pointer to the "first position of the next higher number than last occurence of num" if num is present in the container. Returns pointer to the position of next higher number than num if container does not contain occurence of num.
#define REP(i,n) for(int i=0;i<n;i++)
#define REPE(i,n) for(int i=n-1;i>=0;i--)
#define REPA(i,a,n) for(int i=a;i<n;i++)

//next_permutation(s.begin(),s.end())
//*max_element(a,a+n)
#define mod 1000000007
int N=INT_MAX;
using namespace std;

bool isPrime(int n)
{if(n==1)return false;
for(int i=2;i*i<=n;i++)
{if(n%i==0)return false;}
return true;
}

int gcd(int a,int b)
{
    if(b==0)return a;
    return gcd(b,a%b);
    //cout<<__gcd(a,b)<<" "<<boost::math::lcm(a,b)<<endl;
}
int lcm(int a,int b)
{
    return a/gcd(a,b)*b;

}
//  vi v;
// void SE(int n) {
//    v.clear();
//     bool prime[n+1];
//     memset(prime, true, sizeof(prime));

//     for (int p=2; p*p<=n; p++)
//     {
//         if (prime[p] == true)
//         {
//             for (int i=p*p; i<=n; i += p)
//                 prime[i] = false;
//         }
//     }

//     for (int p=2; p<=n; p++)
//        if (prime[p])
//           v.pb(p);

//     }

 //JAI SHREE RAM  //JAI SHREE RAM //JAI SHREE RAM  //JAI SHREE RAM
///////////////// MAIN FUNCTION ////////////////////////

 void CSK()
 {
     int n; cin >> n;
    int a[n];
    for(int i = 0;i<n;i++) cin >> a[i];
    int k;
    int ans[n];
    for(int i = 0;i<n;i++) {
        if(i&1) {
            if(a[i] > i) {
                ans[i] =a[i] - i;
            } else {
                ans[i] = n-i+a[i];
            }
        } else {
            if(i>a[i]) {
                ans[i] = i-a[i];
            } else {
                ans[i] = n-a[i] + i;
            }
        }
    }

    bool flag = true;
    for(int i = 0;i<n-1;i++) {
        if(ans[i] != ans[i+1]) {
            flag = false; break;
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

}
///////////////////////// END //////////////////////////////////////

int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    fastio;
    cout<<fixed;
    cout.precision(10);
    int __TESTCASES=1;
    //cin>>__TESTCASES;
    while(__TESTCASES--){
    CSK();
}

}


#include<bits/stdc++.h>
using namespace std;
int a[10001];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<=n-1;i++)
	{
		int c=1;
		for(int j=0;j<=n-1;j++)
		{
			a[j]=(a[j]+c+n)%n;
			c*=-1;
		}
		bool ok=1;
		for(int j=0;j<=n-1;j++)
		{
			if(a[j]!=j)
				ok=0;
		}
		if(ok){
			cout<<"YES"<<"\n";
		return 0;
		}
	}
	cout<<"NO"<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int c1=0,c2=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]%2==1)
		{
			c1++;
		}
		if(a[i]%2==0)
		{
			c2++;
		}
	}
	if(c2>c1)
	{
		cout<<"YES";
	}
	else
	{
		cout<<"NO";
	}

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int c1=0,c2=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]%2==1)
		{
			c1++;
		}
		if(a[i]%2==0)
		{
			c2++;
		}
	}
	if(c2>c1)
	{
		cout<<"YES";
	}
	else
	{
		cout<<"NO";
	}

}


#include<iostream>
using namespace std;
int main()
{
    int n,i;cin>>n;
    int a[n];
    for(i=0;i<n;i++) cin>>a[i];
    int flag1=0;
    while(1){
    for(i=0;i<n;i++)
    {
        flag1++;
        if(i%2==0)
        {
            if(a[i]==n-1)
                a[i]=0;
            else
                a[i]++;
        }
        else{
            if(a[i]==0)
                a[i]=n-1;
            else
                a[i]--;
        }
    }
    int flag=0;
    for(i=0;i<n;i++)
    {
        if(a[i]==i)
            flag++;
            else break;
    }
    if(flag==n)
    {
        cout<<"yes";
        return 0;
    }
    if(flag1==n)
            break;
    }
    cout<<"no";
}


#include<iostream>
using namespace std;
int main()
{
    int n,i;cin>>n;
    int a[n];
    for(i=0;i<n;i++) cin>>a[i];
    int flag1=0;
    while(1){
            flag1++;
    for(i=0;i<n;i++)
    {
        if(i%2==0)
        {
            if(a[i]==n-1)
                a[i]=0;
            else
                a[i]++;
        }
        else{
            if(a[i]==0)
                a[i]=n-1;
            else
                a[i]--;
        }
    }
    int flag=0;
    for(i=0;i<n;i++)
    {
        //cout<<a[i];
        if(a[i]==i)
            flag++;
    else break;
    }//cout<<endl;
    if(flag==n)
    {
        cout<<"yes";
        return 0;
    }
    if(flag1==n)
            break;
    }
    cout<<"no";
}


#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <set>
#include <bitset>
#include <array>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cctype>
//#include <numeric>
//#include <map>

#define all(x) x.begin(), x.end()
#define nl '\n';

bool rotate(std::vector<std::vector<int>> &vec)
{
    for(size_t i = 0; i < vec.size(); ++i)
    {
        if(i%2)
            std::rotate(vec[i].rbegin(), vec[i].rbegin()+1, vec[i].rend());
        else
            std::rotate(vec[i].begin(), vec[i].begin()+1, vec[i].end());
    }

    static std::vector<int> active;
    active.clear();
    for(size_t j = 0; j < vec.size(); ++j)
    {
        active.push_back(vec[j][0]);
    }
    if(std::is_sorted(all(active)))
        return true;

    return false;
}

int main()
{

    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);

    int q;
    std::cin >> q;
    std::cin.ignore();
    std::vector<std::vector<int>> gears(q);

    std::string line;
    std::getline(std::cin, line);
    std::istringstream ss(line);

    int num;
    int count = 0;
    while(ss >> num)
    {
        gears[count].resize(q);
        std::iota(all(gears[count]), 0);
        std::rotate(gears[count].begin(), gears[count].begin() + num, gears[count].end());
        count++;
    }

    auto check = false;
    for(int i = 0; i < q; ++i)
    {
        if(rotate(gears))
        {
            check = true;
            break;
        }
    }

    if(check)
        std::cout << "Yes\n";
    else
        std::cout << "No\n";

    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <set>
#include <bitset>
#include <array>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cctype>
//#include <numeric>
//#include <map>

#define all(x) x.begin(), x.end()
#define nl '\n';

bool rotate(std::vector<std::vector<int>> &vec)
{
    for(size_t i = 0; i < vec.size(); ++i)
    {
        if(i%2)
            std::rotate(vec[i].rbegin(), vec[i].rbegin()+1, vec[i].rend());
        else
            std::rotate(vec[i].begin(), vec[i].begin()+1, vec[i].end());
    }

    static std::vector<int> active;
    active.clear();
    for(size_t j = 0; j < vec.size(); ++j)
    {
        active.push_back(vec[j][0]);
    }
    if(std::is_sorted(all(active)))
        return true;

    return false;
}

int main()
{

    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);

    int q;
    std::cin >> q;
    if(q < 1 || q > 1000)
        return 0;
    std::cin.ignore();
    std::vector<std::vector<int>> gears(q);

    std::string line;
    std::getline(std::cin, line);
    std::istringstream ss(line);

    int num;
    int count = 0;
    while(ss >> num)
    {
        gears[count].resize(q);
        std::iota(all(gears[count]), 0);
        std::rotate(gears[count].begin(), gears[count].begin() + num, gears[count].end());
        count++;
    }

    auto check = false;
    for(int i = 0; i < q; ++i)
    {
        if(rotate(gears))
        {
            check = true;
            break;
        }
    }

    if(check)
        std::cout << "Yes\n";
    else
        std::cout << "No\n";

    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <set>
#include <bitset>
#include <array>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cctype>
//#include <numeric>
//#include <map>

#define all(x) x.begin(), x.end()
#define nl '\n';

std::vector<int> pattern;

bool rotate(std::vector<std::vector<int>> &vec)
{
    for(size_t i = 0; i < vec.size(); ++i)
    {
        if(i%2)
            std::rotate(vec[i].rbegin(), vec[i].rbegin()+1, vec[i].rend());
        else
            std::rotate(vec[i].begin(), vec[i].begin()+1, vec[i].end());
    }

    static std::vector<int> active;
    active.clear();
    for(size_t j = 0; j < vec.size(); ++j)
    {
        active.push_back(vec[j][0]);
    }
    if(active == pattern)
        return true;

    return false;
}

int main()
{

    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);

    int q;
    std::cin >> q;
    if(q < 1 || q > 1000)
        return 0;
    std::cin.ignore();
    std::vector<std::vector<int>> gears(q);
    pattern.resize(q);
    std::iota(all(pattern), 0);

    std::string line;
    std::getline(std::cin, line);
    std::istringstream ss(line);

    int num;
    int count = 0;
    while(ss >> num)
    {
        gears[count].resize(q);
        std::iota(all(gears[count]), 0);
        std::rotate(gears[count].begin(), gears[count].begin() + num, gears[count].end());
        count++;
    }

    auto check = false;
    for(int i = 0; i < q; ++i)
    {
        if(rotate(gears))
        {
            check = true;
            break;
        }
    }

    if(check)
        std::cout << "Yes\n";
    else
        std::cout << "No\n";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int ar[n];
for(int i=0;i<n;i++){cin>>ar[i];}

for(int j=0;j<(n-1);j++)
{
  for(int i=0;i<n;i++)
  {
      if(i%2==0)
      {
        if(ar[i]==(n-1))
        {
            ar[i]=0;
        }
        else
        {
            ar[i]++;
        }

      }
      else
      {
         if(ar[i]==0)
         {
             ar[i]=n-1;
         }
          else
          {
              ar[i]--;
          }
      }
  }
  int count=0;
  for(int i=0;i<n;i++)
{
    if(ar[i]==i)
    {
        count++;
    }
}
if(count==n)
{
  break;
}
} /*
for(int i=0;i<n;i++)
{
    cout<<ar[i]<<" ";
}  */
for(int i=0;i<n;i++)
{
    if(ar[i]!=i)
    {
        cout<<"NO";
        exit(0);
    }
}
cout<<"YES";
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int ar[n];
for(int i=0;i<n;i++){cin>>ar[i];}

for(int j=0;j<2*n;j++)
{
  for(int i=0;i<n;i++)
  {
      if(i%2==0)
      {
        if(ar[i]==(n-1))
        {
            ar[i]=0;
        }
        else
        {
            ar[i]++;
        }

      }
      else
      {
         if(ar[i]==0)
         {
             ar[i]=n-1;
         }
          else
          {
              ar[i]--;
          }
      }
  }
  int count=0;
  for(int i=0;i<n;i++)
{
    if(ar[i]==i)
    {
        count++;
    }
}
if(count==n)
{
  break;
}
} /*
for(int i=0;i<n;i++)
{
    cout<<ar[i]<<" ";
}  */
for(int i=0;i<n;i++)
{
    if(ar[i]!=i)
    {
        cout<<"No";
        exit(0);
    }
}
cout<<"Yes";
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
/*int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<4*(sqrt(a*c/b)+sqrt(a*b/c)+sqrt(b*c/a))<<endl;
    return 0;
}
*/
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    vector<int>a;
    for(int i=0; i<n; i++)
    {
        int x;
        cin>>x;
        a.push_back(x);
    }

    int cnt=0;
    for(int j=0; j<n; j++)
    {
        for(int i=0; i<n; i++)
        {
            int x=i+1;
            if(x%2!=0)
            {
                if(a[i]==n-1)
                {
                    a[i]=0;
                }
                else
                {
                    a[i]+=1;
                }
            }
            else
            {
                if(a[i]==0)
                {
                    a[i]=n-1;
                }
                else
                {
                    a[i]-=1;
                }
            }
            //cout<<a[i]<<" ";
            for(int i=0; i<n; i++)
            {
                if(a[i]==i)
                {
                    cnt++;
                }
            }
            if(cnt==n)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
            cnt=0;

        }
    }
    cout<<"No"<<endl;

    return 0;
}