#include <bits/stdc++.h>
using namespace std;
#define pb push_back
bool mark[40009];
vector<long long> prime;
void sieve()
{
for (long long i=3; i<=200; i+=2)
{
if (!mark[i])
for (long long j=i*i; j<=40000; j+=2*i)
mark[j]=true;
}
prime.pb(2);
for (long long i=3; i<=40000; i+=2)
if (mark[i]==false)
prime.pb(i);
}
void check(long long p,long long r,long long q,long long s)
{
map<long long,long long> m1,m2;
map<long long,long long> ::iterator it;
long long num1=p,num2=q,flag=0;
for (long long i=0; i<prime.size(); i++)
{
while (num1%prime[i]==0)
{
num1/=prime[i];
m1[prime[i]]++;
}
}
if (num1>1)
m1[num1]++;
for (long long i=0; i<prime.size(); i++)
{
while (num2%prime[i]==0)
{
num2/=prime[i];
m2[prime[i]]++;
}
}
if (num2>1)
m2[num2]++;
for (it=m1.begin(); it!=m1.end(); it++)
it->second*=r;
for (it=m2.begin(); it!=m2.end(); it++)
it->second*=s;
for (it=m2.begin(); it!=m2.end(); it++)
{
if (m1.find(it->first)==m1.end())
{
flag=1;
break;
}
if (m1[it->first]<it->second)
flag=1;
}
if (!flag)
cout<<"divisible\n";
else
cout<<"not divisible\n";
}
int main()
{
sieve();
long long p,q,r,s,t;
cin>>t;
while (t--){
cin>>p>>r>>q>>s;
check(p,r,q,s);
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgcGIgcHVzaF9iYWNrCmJvb2wgbWFya1s0MDAwOV07CnZlY3Rvcjxsb25nIGxvbmc+IHByaW1lOwp2b2lkIHNpZXZlKCkKewoJZm9yIChsb25nIGxvbmcgaT0zOyBpPD0yMDA7IGkrPTIpCgl7CgkJaWYgKCFtYXJrW2ldKQoJCQlmb3IgKGxvbmcgbG9uZyBqPWkqaTsgajw9NDAwMDA7IGorPTIqaSkKCQkJCW1hcmtbal09dHJ1ZTsKCX0KCXByaW1lLnBiKDIpOwoJZm9yIChsb25nIGxvbmcgaT0zOyBpPD00MD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