#include <bits/stdc++.h>
int t;
long long n[200000], m[200000];
using namespace std;
int main () {
    cin  >> t;
    for (int i=1; i<=t;i++)
        cin >> n[i]>> m[i];
    for (int i=1; i<=t; i++){
            if (n[i]%i!=0) cout << -1 << endl;
                if (n[i]%i==0) cout << 1 << endl;
    for (int j=1; j<=t; j++){
            if (m[j]%j!=0) cout << -1 << endl;
                if (m[j]%j==0) cout << 1 << endl;
                }
}
return 0;
}