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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T;
    cin >> T;
    const int MAX_X = (1 << 31) - 1;
    while (T--) {
        int x;
        cin >> x;
        if (x == MAX_X) {
            cout << -1 << '\n';
            continue;
        }
        int k = 0;
        while ((x & (1 << k)) != 0) {
            k++;
        }
        cout << (1 << k) << '\n';
    }
    return 0;
}