#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int t,a,b,k;
cin>>t;
while (t--)
{
cin>>a>>b;
if (a<b)
{
k=a;
a=b;
b=k;
}
int c=a%b;
while(1)
{
if(c==0)
{
cout<<"NOT GOOD"<<endl;
break;
}
if(c==1)
{
cout<<"GOOD"<<endl;
break;
}
a=b;
b=c;
c=a%b;
}
}
return 0;
}