//Can anyone help ??
//Why this solution is wrong
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
long long int n;
cin >> n;
while (t--)
{
int count = 0;
for (int i = 1; i <= n; i++)
{
if (n % i == 0)
{
count++;
}
}
bool ans = true;
if (count % 2 != 0)
{
ans = true;
}
else
{
ans = false;
}
int q;
cin >> q;
if (ans == true && 1 < n < pow(10, 6) && q == n)
{
cout << 1;
}
else
{
cout << 0;
}
}
}