#include #include #include #include #include #include #include #include #include #include #include #include #define vll vector #define vvvl vector #define vvl vector> #define VV(a, b, c, d) vector>(a, vector(b, c)) #define VVV(a, b, c, d) vector(a, vvl(b, vll (c, d))); #define re(c, b) for(ll c=0;c tbl(10000000, 1); void solve(){ ll a, b;std::cin >> a >> b; std::cout << (tbl[b]?1:-1) << '\n'; } int main(int argc, char const *argv[]) { tbl[1] = 0; for(ll i=2;i<=10000000;i++) for(ll j=i*i;j<=10000000;j+=i) tbl[j] = 0; ll t;std::cin >> t; re(i, t) solve(); return 0; }