#include #include #include #include using namespace std; using ll=long long; vector Divisors(int N){ vector D; int k=1; while (k*k<=N){ if (N%k==0){ D.push_back(k); if (k*k!=N){ D.push_back(N/k); } } k++; } sort(D.begin(),D.end(),greater()); return D; } ll pow_mod(ll a, ll p, ll m){ ll x=1; while (p){ if (p&1){ x*=a; x%=m; } a*=a; a%=m; p>>=1; } return x; } int main(){ int T=0; cin >> T; ll mod=1000000007; int N,C; vector D; int M,d,e,m,g; ll A,B,X; unordered_map H; for (int t=0; t> N >> C; //gcd(N,x) の分布を調べる. D=Divisors(N); M=D.size(); H.clear(); for (int i=0; i