#include using namespace std; typedef long long ll; int main() { int N; cin >> N; ll p[N]; for (int i = 0; i < N; i++) { cin >> p[i]; } ll v = 2; for (int i = 0; i < N; i++) { v = 2; bool flag = true; for (int x = 1; x < 60; x++) { if (v % p[i] == x % p[i]) { flag = false; cout << x << "\n"; break; } v *= 2; } if (flag) { cout << "-1\n"; } } return 0; }