#include // #include using namespace std; // using namespace atcoder; using lint = long long; long const mod = 1e9+7; //long const mod = 998244353; void solve(){ lint a,p; cin >> a >> p; for(int i=2;i<=sqrt(p);i++){ if(p%i == 0){ cout << -1 << endl; return; } } if(a%p==0){ cout << 0 << endl; return; }else{ cout << 1 << endl; } } int main(){ lint t; cin >> t; for(int i=0;i