#include #pragma GCC optimize("unroll-loops") using namespace std; using std::cout; using std::cin; using std::endl; using ll=long long; using ld=long double; const ll ILL=2167167167167167167; const int INF=2100000000; const int mod=998244353; #define rep(i,a,b) for (int i=(int)(a);i<(int)(b);i++) #define all(p) p.begin(),p.end() template using _pq = priority_queue, greater>; template ll LB(vector &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();} template ll UB(vector &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();} template bool chmin(T &a,T b){if(a>b){a=b;return 1;}else return 0;} template bool chmax(T &a,T b){if(a void So(vector &v) {sort(v.begin(),v.end());} template void Sore(vector &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});} bool yneos(bool a,bool upp=0){if(a){cout<<(upp?"YES\n":"Yes\n");}else{cout<<(upp?"NO\n":"No\n");}return a;} template void vec_out(vector &p,int ty=0){ if(ty==2){cout<<'{';for(int i=0;i<(int)p.size();i++){if(i){cout<<",";}cout<<'"'< T vec_min(vector &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmin(ans,x);return ans;} template T vec_max(vector &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmax(ans,x);return ans;} template T vec_sum(vector &a){T ans=T(0);for(auto &x:a) ans+=x;return ans;} int pop_count(long long a){int res=0;while(a){res+=(a&1),a>>=1;}return res;} template bool inside(T l,T x,T r){return l<=x&&x>t; rep(i,0,t) solve(); } void solve(){ int B,C; cin>>B>>C; if(B==1){ cout<<"1\n"; return; } int ans=0; int D=B/C; vector table={659,1,2,2,3,2,4,2,4,3,4,2,6,2,4,4,5,2,6,2,6,4,4,2,8,3,4,4,6,2,8,2,6,4,4,4,9,2,4,4,8,2,8,2,6,6,4,2,10,3,6,4,6,2,8,4,8,4,4,2,12,2,4,6,7,4,8,2,6,4,8,2,12,2,4,6,6,4,8,2,10,5,4,2,12,4,4,4,8,2,12,4,6,4,4,4,12,2,6,6,9,2,8,2,8,8,4,2,12,2,8,4,10,2,8,4,6,6,4,4,16,3,4,4,6,4,12,2,8,4,8,2,12,4,4,8,8,2,8,2,12,4,4,4,15,4,4,6,6,2,12,2,8,6,8,4,12,2,4,4,12,4,10,2,6,8,4,2,16,3,8,6,6,2,8,6,10,4,4,2,18,2,8,4,8,4,8,4,6,8,8,2,14,2,4,8,9,2,12,2,12,4,4,4,12,4,4,6,10,4,16,2,6,4,4,4,16,4,4,4,12,4,8,2,12,9,4,2,12,2,8,8,8,2,12,4,6,4,8,2,20,2,6,6,6,6,8,4,8,4,8,2,18,4,4,8,9,2,8,4,12,6,4,2,16,4,8,4,6,2,16,2,10,8,4,6,12,2,4,6,16,2,8,2,6,8,8,4,18,3,8,4,6,2,12,4,8,8,4,4,18,4,4,4,10,4,12,2,12,4,8,2,16,2,4,12,6,2,8,4,14,4,8,4,15,6,4,4,8,4,16,2,6,6,4,4,20,2,6,4,12,4,12,4,8,8,4,2,12,2,12,8,12,2,8,4,6,8,4,2,24,3,4,6,12,4,8,2,10,6,8,4,12,2,8,8,8,4,16,2,12,4,4,2,16,8,4,6,6,2,16,4,12,4,4,4,18,2,4,8,15,2,8,4,6,10,8,4,16,2,8,4,6,4,12,4,12,4,8,2,24,2,4,6,8,6,8,4,6,8,8,2,20,2,8,8,6,4,8,2,16,9,8,2,12,4,4,4,14,2,18,4,6,4,4,8,16,2,4,8,12,2,16,2,10,8,4,2,18,4,8,4,8,4,8,6,12,6,4,2,24,4,4,8,9,4,12,2,8,4,12,2,12,4,8,12,10,4,8,2,12,4,4,2,24,4,8,6,6,2,16,4,10,8,4,4,12,4,8,4,16,2,12,2,6,12,4,4,20,3,8,6,12,4,8,4,8,4,4,6,24,2,4,4,12,4,16,2,6,6,12,4,16,4,4,8,6,2,12,4,20,8,4,2,12,4,4,10,8,2,16,2,12,4,8,6,21,2,6,4,12,4,8,4,8,12,4,2,18,4,8,4,10,2,16,8,6,4,8,2,24,2,8,6,6,6,8,2,12,8,8,4,18,2,4,8,16,2,8,2,12,8,4,4,20,5,4,8,6,4,24,2,8,4,4,4,12,6,8,6,16,2,8,2,12,8,8,2,20,4,12,8,6,2,8,4,10,6,8,2}; rep(a,0,B) if(gcd(B,a)==1){ ll X=gcd(a-1,D); ans+=table[X]; } if(ans>100){ cout<<"100+\n"; } else{ cout<