/*
2-type B|D^k
3-type B|D-1
11-type B|D+1
6-type B质因子分解,
7-type 其他情况
3-type:
(a*(D^4-1)+b*(D^3-1)+...+d*(D-1)) % B = 0
B|(D-1)
11-type:
(a*(D^4-1)+b*(D^3+1)+c*(D^2-1)+d*(D^1+1)) % B=0
B|(D^k+(-1)^k)
k为奇数时,D^k-1因式分解后必然有B|(D+1)
k为偶数时,(D+1)(D^(k-1)-D^(k-2)+D^(k-3)...+1),也必有B|(D+1)
且对于任意的k,(D^k+(-1)^k)只有(D+1)这个公因子
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int prime[200],vis[200],m;
void init(){
for(int i=2;i<=100;i++){
if(!vis[i])prime[++m]=i;
for(int j=i;j<=100;j+=i)
vis[j]=1;
}
}
ll D,B;//D进制下,除数是B
int k;
int calc(ll B){
if((D-1)%B==0)return 3;
if((D+1)%B==0)return 11;
ll tmp=D;
k=0;
for(;tmp<=1e16;tmp*=D){//2^7
++k;
if(tmp%B==0)return 2;
}
return -1;
}
int main(){
init();
cin>>D>>B;
int res=calc(B);
if(res!=-1){
if(res==2){
cout<<"2-type"<<'\n';
cout<<k<<'\n';
return 0;
}
else if(res==3){
cout<<"3-type"<<'\n';
return 0;
}
else if(res==11){
cout<<"11-type"<<'\n';
return 0;
}
return 0;
}
for(int i=1;i<=m;i++)
if(B%prime[i]==0){//每个质因子都要符合要求
ll tmp=1;
while(B%prime[i]==0)
B/=prime[i],tmp*=prime[i];
int res=calc(tmp);
if(res==-1){
cout<<"7-type"<<'\n';
return 0;
}
}
cout<<"6-type"<<'\n';
}