#include<cstdio>
#include<vector>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int gcd(int a,int b){ return b?gcd(b,a%b):a; }
int lcm(int a,int b){ return a/gcd(a,b)*b; }

vector<int> divisor(int a){
	vector<int> res;
	for(int i=1;i*i<=a;i++) if(a%i==0) {
		res.push_back(i);
		if(i*i<a) res.push_back(a/i);
	}
	return res;
}

int base;

bool is_2type(int d,int &ans){
	int b=base;
	rep(i,300){
		if(b%d==0){ ans=i+1; return true; }
		b=b*base%d;
	}
	return false;
}

bool is_3type(int d){ return base%d==1; }

bool is_11type(int d){ return base%d==d-1; }

bool is_6type(int d){
	int dummy;
	if(is_2type(d,dummy) || is_3type(d) || is_11type(d)) return true;

	vector<int> div=divisor(d);
	rep(i,div.size()){
		int a=div[i];
		if(a==1 || a==d) continue;
		if(lcm(a,d/a)==d && is_6type(a) && is_6type(d/a)) return true;
	}
	return false;
}

int main(){
	int d; scanf("%d%d",&base,&d);

	int ans;
	if(is_2type(d,ans)){
		puts("2-type");
		printf("%d\n",ans);
	}
	else if(is_3type(d)){
		puts("3-type");
	}
	else if(is_11type(d)){
		puts("11-type");
	}
	else if(is_6type(d)){
		puts("6-type");
	}
	else{
		puts("7-type");
	}

	return 0;
}

#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

int b, d;

int gcd(int a, int b)
{
	if (!b) return a;
	return gcd(b, a % b);
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#endif
	cin >> b >> d;
	int cnt = 0;
	for (int g = gcd(b, d); g > 1; d /= g, g = gcd(b, d), ++cnt);
	if (d == 1)
		printf("2-type\n%d\n", cnt);
	else
	if (!cnt && b % d == 1)
		puts("3-type");
	else
	if (!cnt && b % d == d - 1)
		puts("11-type");
	else
	if ((b + 1) * (b - 1) / ((b % 2) + 1) % d == 0)
		puts("6-type");
	else
	puts("7-type");
	fclose(stdin);
	fclose(stdout);
	return 0;
}

#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int n,m,f,g,prime[1000],cnt,flag,last=-1;
void get_prime()
{
	prime[++cnt]=2;
	for(int i=3;i<=1000;i+=2)
	{
		for(int j=2;j<=sqrt(i);j++)
			if(i%j==0)
				break;
		prime[++cnt]=i;
	}
}
int t1(int a,int b)
{
	f=1;
	for(int i=1;i<=1000;i++)
	{
		g=f*a%b;
		if(g==0)
			return i;
		f=g;
	}
	return 0;
}
int t2(int a,int b)
{
	if(a%b==1)
		return 1;
	return 0;
}
int t3(int a,int b)
{
	if(a%b==b-1)
		return 1;
	return 0;
}
int main()
{
	scanf("%d %d",&n,&m);
	if(f=t1(n,m))
		printf("2-type\n%d\n",f);
	else if(t2(n,m))
		printf("3-type\n");
	else if(t3(n,m))
		printf("11-type\n");
	else
	{
		get_prime();
		for(int i=1;i<=cnt;i++)
		{
			if(m%prime[i]==0)
			{
				if(!t1(n,prime[i])&&!t2(n,prime[i])&&!t3(n,prime[i]))
				{
					printf("7-type\n");
					return 0;
				}
				if(i!=last) flag++,last=i;
				m/=prime[i],i--;
			}
		}
		if(flag>=2)
			printf("6-type\n");
		else
			printf("7-type\n");
	}
	return 0;
}

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
ll prime[30] = {0, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
ll b, d, flag = 0;
ll Ksm(ll x, ll p)
{
	if (p == 0) return 1;
	else if (p == 1) return x;
	else
	{
		ll tmp = Ksm(x, p >> 1);
		if (p & 1) return tmp * tmp * x;
		else return tmp * tmp;
	}
}
bool fcheck(ll x, ll m)
{
	for (ll i = 1; i <= 6; i ++)
		if (Ksm(x, i) % m == 0) return true;
	if ((x - 1) % m == 0) return true;
	if ((x + 1) % m == 0) return true;
	return false;
}
ll check(ll x)
{
	for (ll i = 1; i <= 6; i ++)
		if (Ksm(x, i) % d == 0) { flag = i; return 2;}
	if ((x - 1) % d == 0) return 3;
	if ((x + 1) % d == 0) return 11;
	for (ll i = 1; i <= 25; i ++)
		if (d % prime[i] == 0)
		{
			ll top = 1;
			while (d % prime[i] == 0) top *= prime[i], d /= prime[i];
			if (!fcheck(x, top)) return 7;
		}
	return 6;
}
int main( )
{
	scanf("%I64d %I64d", &b, &d);
	printf("%I64d-type\n", check(b));
	if (flag) printf("%I64d\n", flag);
	return 0;
}

// Codeforces Round #116 (Div. 2, ACM-ICPC Rules) B Divisibility Rules

#include <cstdio>

using namespace std;

int main() {
	int b, d;
	scanf("%d%d", &b, &d);

	if (b % d == 1) {
		printf("3-type\n");
		return 0;
	}

	if (b % d == d - 1) {
		printf("11-type\n");
		return 0;
	}

	int ans = -1, cnt = 0;
	for (int i = 2; i <= d; i ++)
		if (d % i == 0) {
			int t = 0;
			int m = 1;
			while (d % i == 0) {
				t ++;
				d /= i;
				m *= i;
			}
			if (b % i == 0) {
				int tt = 1;
				int bb = b;
				while (bb % m != 0) {
					bb *= b;
					tt ++;
				}
				if (tt > cnt) cnt = tt;
				if (ans == -1) {
					ans = 2;
				} else if (ans != 2) {
					ans = 6;
				}
			} else if (b % m == 1) {
				if (ans == -1) {
					ans = 3;
				} else if (ans != 3) {
					ans = 6;
				}
			} else if (b % m == m - 1) {
				if (ans == -1) {
					ans = 11;
				} else if (ans != 11) {
					ans = 6;
				}
			} else {
				ans = 7;
				break;
			}
		}

	printf("%d-type\n", ans);
	if (ans == 2) printf("%d\n", cnt);

	return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int maxn = 110;

int cntA[maxn],cntB[maxn],rem[maxn];
int A,B;
int ans;

int main()
{
    int i,j,k;
    bool ok;

    scanf("%d %d",&A,&B);
    for (i = 2,j = A; i <= A; ++i)
        if (j % i == 0)
            while (j % i == 0) j /= i,cntA[i]++;
    for (ok = true,i = 2,j = B; i <= B; ++i)
        if (j % i == 0)
        {
            for (k = 1; j % i == 0; ++cntB[i],j /= i,k *= i) ;
            rem[k] = i;
            if (!cntA[i]) {ok = false; continue;}
            if ((cntB[i]-1)/cntA[i]+1 > ans) ans = (cntB[i]-1)/cntA[i]+1;
        }
    if (ok) printf("2-type\n%d",ans);
    else
    {
        if (A%B == 1) printf("3-type\n");
        else if ((A+1)%B == 0) printf("11-type\n");
        else
        {
            for (ok = true,i = 2; i <= B; ++i)
            {
                if (rem[i] == 0 || cntA[rem[i]] || A%i == 1 || (A+1)%i == 0) continue;
                ok = false;
            }
            if (ok) printf("6-type\n");
            else printf("7-type\n");
        }
    }

    return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <climits>
#include <numeric>
#include <vector>
using namespace std;

int main() {
	int b, d;
	cin >> b >> d;
	int tp = -1, mxL = 0;
	int x = d;
	bool can[20] = { };
	fill(can, can + 20, true);
	bool bad = false;
	for (int i = 2; i <= x; i++) {
		bool my[20] = { };
		int p = i, c = 0, pc = 1;
		while (x % i == 0) {
			x /= i;
			++c;
			pc *= i;
		}
		if (!c)
			continue;
		//check my type!
		int r = b % pc, L = -1;
		for (int i = 1; i <= 100; ++i) {
			if (r == 0) {
				L = i;
				break;
			}
			r = r * b % pc;
		}
		if (L != -1) {
			my[2] = true;
//			goto end;
		}
		//check 3
		if (b % pc == 1) { //3 type!
			my[3] = true;
		}
		//check 11
		if (b % pc == pc - 1) { //11 type
			my[11] = true;
		}
		//type 7 :(
//		tp = 7;
//		memset(can, 0, sizeof can);
		if (count(my, my + 20, true) == 0) {
			bad = true;
			break;
		}
//		break;

		end: {
			mxL = max(mxL, L);
			for (int i = 0; i < 20; ++i) {
				can[i] = can[i] && my[i];
			}
		}
	}
	if (bad) {
		puts("7-type");
		return 0;
	}
	tp = 6;
	for (int i = 0; i < 20; ++i) {
		if (can[i]) {
			tp = i;
			break;
		}
	}
	cout << tp << "-" << "type" << endl;
	if (tp == 2) {
		cout << mxL << endl;
	}
	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>

using namespace std;

int K, P;

int p[100], nP;

int main() {
    scanf("%d%d", &K, &P);
    int t = 1;
    for (int i = 0; i < 100; i++) {
        if (t == 0) {
            printf("2-type\n%d\n", i);
            return 0;
        }
        t = t * K % P;
    }
    if (K % P == 1) {
        printf("3-type\n");
        return 0;
    }
    if (K % P == P - 1) {
        printf("11-type\n");
        return 0;
    }
    nP = 0;
    for (int i = 2; i <= P; i++) {
        while (P % i == 0) {
            if (nP == 0 || p[nP - 1] % i != 0) p[nP++] = i;
            else p[nP - 1] *= i;
            P /= i;
        }
    }
    for (int i = 0; i < nP; i++) {
        int t = 1;
        for (int j = 0; j < 100; j++) t = t * K % p[i];
        if (t == 0) continue;
        if (K % p[i] == 1 || K % p[i] == p[i] - 1) continue;
        printf("7-type\n");
        return 0;
    }
    printf("6-type\n");
    return 0;
}

#include <cstring>
#include <cstdio>
using namespace std;
int b,d;

int gcd(int x, int y)
{
	if (y==0) return x; return gcd(y,x%y);
}

bool pd2(int x, int y, int &num)
{
	for (int k=gcd(x,y); k!=1; k=gcd(x,y)) y/=k,++num;
	return y==1;
}

bool pd3(int x, int y){return x%y==1;}
bool pd11(int x, int y){return (x+1)%y==0;}
bool pd6(int x, int y)
{
	for (int i=2; i<=100; i++)
	{
		while (y%i==0)
		{
			int j=1,num;
			while (y%i==0) y/=i, j*=i;
			if (!pd2(x,j,num) && !pd3(x,j) && !pd11(x,j)) return 0;
		}
	}
	return 1;
}

int main()
{
	scanf("%d%d",&b,&d);

	int num=0;
	if (pd2(b,d,num)) printf("2-type\n%d\n",num);
	else if (pd3(b,d)) printf("3-type\n");
	else if (pd11(b,d)) printf("11-type\n");
	else if (pd6(b,d)) printf("6-type\n");
	else printf("7-type\n");
	//for (;;);
}

#define ONLINE_JUDGE
#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define pb push_back

#define mp make_pair

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

inline void gn(int &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

inline void gn(INT &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

inline void gn(DO &x)  {scanf("%lf", &x);}

inline void newline() {putchar('\n');}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 111

int tp[NN];

int b, d;

int get_type(int n) {

	if (b%n==1) return 3;

	if (b%n==n-1) return 11;

	int s=1;

	for (int i=0; i<=n; i++) s=s*b%n;

	if (!s) return 2;

	for (int i=2; i<n; i++) {

		if (n%i) continue;

		if (__gcd(i, n/i)>1) continue;

		if (tp[i]==7) continue;

		if (tp[n/i]==7) continue;

		return 6;

	}

	return 7;

}

void doit() {

	int ans=0;

	for (int s=1; s; ans++, s=s*b%d);

	printf("%d\n", ans);

	return;

}

int main(){

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

//	freopen("out.out", "w", stdout);

#endif

	cin>>b>>d;

	for (int i=2; i<=d; i++) tp[i]=get_type(i);

	printf("%d-type\n", tp[d]);

	if (tp[d]==2) doit();

	return 0;

}

#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int mk[2002];
int gcd(int a,int b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
int main()
{
    int a,b;
    int type;
    while(scanf("%d%d",&a,&b)==2)
    {
        int t=1;
        for(int i=1; i<=b; i++)
        {
            t=t*a%b;
            if(t==0)
            {
                printf("2-type\n%d\n",i);
                return 0;
            }
        }
        if(a%b==1)
        {
            printf("3-type\n");
            return 0;
        }
        else if(a%b==b-1)
        {
            printf("11-type\n");
            return 0;
        }
        else
        {
            int d=b;
            for(int i=2; i<=d; i++)
            {
                if(d%i==0)
                {
                    int ct=0;
                    while(a%i==1&&d%i==0&&d!=0)
                    {
                        d/=i;
                        ct|=1;
                    }
                    while(a%i==i-1&&d%i==0&&d!=0)
                    {
                        d/=i;
                        ct|=2;
                    }
                    for(int k=2; k<=d; k++)
                    {
                        if(d%k==0)
                        {
                            if(ct%2!=1)
                            {
                            while(a%k==1&&d%k==0&&d>0)
                            {
                                d/=k;
                                ct|=1;
                            }
                            }

                            while(a%k==k-1&&d%k==0&&d!=0)
                            {
                                d/=k;
                                ct|=2;
                            }
                            int tmp=1;
                            if(d!=1)
                            for(int j=1; j<=d; j++)
                            {
                                tmp=tmp*a%d;
                                if(tmp==0)
                                {
                                    ct|=4;
                                }
                            }
                           // printf("%d\n",ct);

                            if(ct==6||ct==3||ct==5||ct==7)
                            {
                                printf("6-type\n");
                                return 0;
                            }
                        }
                    }
                    int tmp=1;
                    if(d!=1)
                    for(int j=1; j<=d; j++)
                    {
                        tmp=tmp*a%d;
                        if(tmp==0)
                        {
                            ct|=4;
                        }
                    }
                   // printf("%d\n",ct);
                    if(ct==6||ct==3||ct==5||ct==7)
                    {
                        printf("6-type\n");
                        return 0;
                    }

                }
            }
        }
        printf("7-type\n");
        return 0;
    }
    return 0;
}

#include <cstdio>
#include <algorithm>
using namespace std;

const int Maxn = 105;

int b, d;
bool two, three, eleven, seven;

bool Test3(int d)
{
	return b % d == 1;
}

bool Test11(int d)
{
	return b % d == d - 1;
}

int Get(int d)
{
	int res, cur = 1;
	for (res = 0; res < Maxn && cur; res++)
		cur = cur * b % d;
	return res;
}

int main()
{
	scanf("%d %d", &b, &d);
	int sav = d;
	for (int i = 2; i <= d; i++)
		if (d % i == 0) {
			int res = 1;
			while (d % i == 0) { res *= i; d /= i; }
			seven |= Get(res) == Maxn && !Test3(res) && !Test11(res);
		}
	if (Get(sav) < Maxn) printf("2-type\n%d\n", Get(sav));
	else if (Test3(sav)) printf("3-type\n");
	else if (Test11(sav)) printf("11-type\n");
	else if (seven) printf("7-type\n");
	else printf("6-type\n");
	return 0;
}

#include<iostream>
#include<cstdio>
using namespace std;
int x,y,num;
int gcd(int x,int y)
{ return (y==0?x:gcd(y,x%y)); }
int work(int x,int y)
{
	for(;gcd(x,y)!=1;) y/=gcd(x,y),num++;
	if (num==0) num=1;
	return y;
}
int main()
{
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	cin>>x>>y; num=0;
	if (work(x,y)==1) cout<<"2-type"<<endl<<num;
	else
	if ((x-1)%y==0) cout<<"3-type";
	else
	if ((x+1)%y==0) cout<<"11-type";
	else
	{
		int xx=gcd(x+1,y);
		int yy=gcd(x-1,y);
		y/=xx*yy/gcd(xx,yy);
		if (work(x,y)==1) cout<<"6-type";
		else cout<<"7-type";
	}
}

#include <sstream>
#include <iomanip>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <deque>
#include <complex>

#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)
#define REP(i,a) for(int i=0,_a=(a); i<_a; i++)
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair

#define DEBUG(x) cout << #x << " = "; cout << x << endl;
#define PR(a,n) cout << #a << " = "; FOR(_,1,n) cout << a[_] << ' '; cout << endl;
#define PR0(a,n) cout << #a << " = "; REP(_,n) cout << a[_] << ' '; cout << endl;
using namespace std;

const double PI = acos(-1.0);

int b, d;

int check2(int d) {
    long long a = b;
    for(int res = 1; res <= 6; ++res) {
        if (a % d == 0) return res;
        a = a * b;
    }
    return 0;
}

bool check3(int d) {
    return (b-1) % d == 0;
}

bool check11(int d) {
    return (b+1) % d == 0;
}

bool isPrime(int n) {
    for(int i = 2; i*i <= n; i++)
        if (n % i == 0) return false;
    return n > 1;
}

bool check6() {
    for(int i = 2; i <= d; i++)
        if (isPrime(i))
        if (d % i == 0) {
            int need = i;
            while (d % (need * i) == 0) {
                need *= i;
            }
            if (!check2(need) && !check3(need) && !check11(need)) return false;
        }
    return true;
}

int main() {
    while (cin >> b >> d) {
        if (check2(d)) printf("2-type\n%d\n", check2(d));
        else if (check3(d)) puts("3-type");
        else if (check11(d)) puts("11-type");
        else if (check6()) puts("6-type");
        else puts("7-type");
    }
    return 0;
}

#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<vector>
#include<ctime>
using namespace std;
int nums[105],nums2[105];
int prime[10000];
bool bo[10001];
int prime_table()
{
    int i,j,flag=0;
    memset(bo,0,sizeof(bo));
    bo[0]=bo[1]=1;
    for(i=2;i<=100;i++)
        if(!bo[i])
        {
            j=i*i;
            for(;j<=10000;j+=i)bo[j]=1;
        }
    for(i=0;i<=10000;i++)
        if(!bo[i])prime[flag++]=i;
    return flag;
}
int len=0,a[105];
int two[105],len2=0,three[105],len3=0,eleven[105],len11=0;
int cnt[105];
int power(int a,int n)
{
    int res=1;
    for(int i=0;i<res;i++)
        res*=a;
    return res;
}
int div(int n,int a[],int numb[])
{
    memset(numb,0,sizeof(numb));
    int l=0,i=0,tmp;
    while(n>1)
    {
        if(n%prime[i]==0)
        {
            a[l++]=prime[i];
            tmp=0;
            while(n%prime[i]==0)
            {
                n/=prime[i];
                tmp++;
            }
            numb[l-1]=tmp;
        }
        i++;
    }
    return l;
}
bool in(int num,int a[],int l)
{
    int i;
    for(i=0;i<l;i++)
        if(num==a[i])
            return 1;
    return 0;
}
int gcd(int a,int b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
int main()
{
    prime_table();
    int b,d,bo[4],i,flag,sum,max,flag3,flag11,gcdd,tmp3=0,tmp11=0,tt;
    memset(bo,0,sizeof(bo));
    scanf("%d%d",&b,&d);
    if((b-1)%d==0)
    {
        puts("3-type");
        return 0;
    }
    if((b+1)%d==0)
    {
        puts("11-type");
        return 0;
    }
    /*if(gcd(b+1,d)==b+1)
    {
        puts("11-type");
        return 0;
    }
    if(gcd(b-1,d)==b+1)
    {
        puts("3-type");
        return 0;
    }*/
    gcdd=gcd(b-1,d);
    if(gcdd!=1)
    {
        tmp3=1;
        d/=gcdd;
    }
    gcdd=gcd(b+1,b-1);
    tt=(b+1)/gcdd;
    gcdd=gcd(tt,d);
    if(gcdd!=1)
    {
        tmp11=1;
        d/=gcdd;
    }
    if(d==1)
    {
        if(tmp3 && tmp11)puts("6-type");
        else if(tmp3)puts("3-type");
        else if(tmp11)puts("11-type");
        return 0;
    }
    len2=div(b,two,nums2);
    len=div(d,a,nums);
    for(i=0;i<len;i++)
    {
        if(!in(a[i],two,len2))
            break;
    }
    if(i==len)
    {
        bo[0]=1;
        if(tmp3)bo[1]=1;
        if(tmp11)bo[2]=1;
        sum=bo[0]+bo[1]+bo[2];
        if(sum>1)puts("6-type");
        else
        {
            puts("2-type");
            memset(cnt,0,sizeof(cnt));
            for(i=0;i<len2;i++)
                while(d%two[i]==0)
                {
                    cnt[i]++;
                    d/=two[i];
                }
            max=0;
            for(i=0;i<len2;i++)
            {
                if(cnt[i]%nums2[i]==0)cnt[i]/=nums2[i];
                else cnt[i]=cnt[i]/nums2[i]+1;
                if(cnt[i]>max)max=cnt[i];
            }
            printf("%d\n",max);
        }
    }
    else puts("7-type");
    return 0;
}

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define P //system("pause")
using namespace std ;
typedef long long LL ;

LL b, d, x ;

int Dfs(LL x)
{
	int i ;
	LL tmp ;
	for(i = 1, tmp = b; i <= 7; i ++, tmp *= b)
		if(tmp%x == 0) return 1 ;
	if(b%x == 1) return 1 ;
	if(b%x == x-1) return 1 ;
	return 0 ;
}

int main()
{
	int i, j ;
	LL tmp ;
	scanf("%I64d %I64d", &b, &d) ;
	for(i = 1, tmp = b; i <= 7; i ++, tmp *= b)
		if(tmp%d == 0)
		{
			printf("2-type\n%d\n", i) ;
			P ;
			exit(0) ;
		}
	if(b%d == 1)
	{
		printf("3-type\n") ;
		P ;
		exit(0) ;
	}
	if(b%d == d-1)
	{
		printf("11-type\n") ;
		P ;
		exit(0) ;
	}
	for(i = 2; i <= d; i ++)
	{
		for(tmp = i; d%tmp==0; tmp *= i) ;
		if(tmp == i) continue ;
		if(!Dfs(tmp/i)) break ;
		d /= tmp/i ;
	}
	if(d == 1)
	{
		printf("6-type\n") ;
		P ;
		exit(0) ;
	}
	else
	{
		printf("7-type\n") ;
		P ;
		exit(0) ;
	}

}

#define _CRT_SECURE_NO_DEPRECATE
#define _SECURE_SCL 0

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include <iostream>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <cctype>
#include <sstream>
#include <cassert>
#include <bitset>
#include <memory.h>
#include <complex>
#include <iomanip>

using namespace std;

#pragma comment(linker, "/STACK:200000000")

typedef long long int64;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define fore(i, a, n) for(int i = (int)(a); i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define last(a) (int(a.size()) - 1)
#define all(a) a.begin(), a.end()

const double EPS = 1E-9;
const int INF = 1000000000;
const int64 INF64 = (int64) 1E18;
const double PI = 3.1415926535897932384626433832795;

int b, num;

int basic_type(int d) {
  int a = 1;
  forn(i, 1000) {
    if (a == 0) {
      num = i;
      return 2;
    }
    a = a * b % d;
  }

  if (b % d == 1)
    return 3;

  if (b % d == d - 1 && (d - 1) * b % d == 1)
    return 11;

  return -1;
}

int type(int d) {
  int res = basic_type(d);
  if (res != -1)
    return res;

  for (int i = 2; i <= d; i++)
    if (d % i == 0) {
      int dv = 1;
      while (d % i == 0) {
        dv *= i;
        d /= i;
      }

      if (basic_type(dv) == -1)
        return 7;
    }

  return 6;
}

int main() {
#ifdef RADs_project
  freopen("input.txt", "rt", stdin);
  freopen("output.txt", "wt", stdout);
#endif

  int d;
  cin >> b >> d;

  int t = type(d);

  printf("%d-type\n", t);
  if (t == 2)
    printf("%d\n", num);

  return 0;
}

#include <iostream>
#include <algorithm>
using namespace std;

int main(){
    int b,d;
    cin >> b >> d;
    bool type2 = false;
    bool type3 = false;
    bool type11 = false;
    //2-type
    int s2 = __gcd(b,d);
    int s22 = 1;
    if(s2 > 1){
        type2 = true;
        int type22 = 0;
        int bb = 1;
        while(__gcd(s22,d) != __gcd(s22*s2,d)){
            s22 *= s2;
            type22 += 1;
            bb *= b;
        }
        if(bb % d == 0){
            cout << "2-type\n" << type22;
            return 0;
        }
    }
    //3-type
    int s3 = __gcd(b-1,d);
    if(s3){
        if((b-1) % d == 0){
            cout << "3-type";
            return 0;
        }
        type3 = true;
    }
    //11-type
    int s11 = __gcd(b+1,d);
    if(s11 > 1){
        if((b+1) % d == 0){
            cout << "11-type";
            return 0;
        }
        type11 = true;
    }
    //6-type
    if((s22*s3)%d == 0){
        cout << "6-type";
        return 0;
    }
    if((s22*s11)%d == 0){
        cout << "6-type";
        return 0;
    }
    if((s3*s11/__gcd(s3,s11))%d == 0){
        cout << "6-type";
        return 0;
    }
    if((s22*(s3*s11/__gcd(s3,s11)))%d == 0){
        cout << "6-type";
        return 0;
    }
    //7-type
    cout << "7-type";
}

#include <set>
#include <queue>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
using namespace std;
int pri[26]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101};
int n,m;
int Get(int x,int y)
{
	int d=0;
	for(;x%y==0;d++,x/=y);
	return d;
}
int gcd(int x,int y)
{
	return y?gcd(y,x%y):x;
}
int main()
{
	scanf("%d%d",&n,&m);
	int ans=0;
	for(int i=0;i<26;i++)
		if(m%pri[i]==0)
			if(n%pri[i]==0)
				ans=max(ans,(Get(m,pri[i])-1)/Get(n,pri[i])+1);
			else
			{
				ans=0;
				break;
			}
	if(ans)
	{
		printf("2-type\n%d\n",ans);
		return 0;
	}
	if((n-1)%m==0)
	{
		printf("3-type\n");
		return 0;
	}
	if((n+1)%m==0)
	{
		printf("11-type\n");
		return 0;
	}
	for(int j=1;j<=m;j++)
		if(m%j==0)
		{
			ans=1;
			for(int i=0;i<26;i++)
				if(j%pri[i]==0)
					if(n%pri[i]==0)
						ans=max(ans,(Get(j,pri[i])-1)/Get(n,pri[i])+1);
					else
					{
						ans=0;
						break;
					}
			for(int i=1;i<=m/j&&ans;i++)
				if(m%i==0)
					if(gcd(i,j)==1&&gcd(i,m/j/i)==1&&gcd(j,m/j/i)==1)
						if((n-1)%i==0&&(n+1)%(m/j/i)==0)
						{
							printf("6-type\n");
							return 0;
						}
		}
	printf("7-type\n");
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

template <class T>
using lim = numeric_limits<T>;

typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int b, d;
	cin >> b >> d;

	if((b-1)%d == 0) cout << "3-type\n";
	else if ((b+1)%d == 0) cout << "11-type\n";
	else if (b%d == 0) cout << "2-type\n1\n";
	else{
		// factorize
		unordered_map<int,int> bfact;
		unordered_map<int,int> dfact;
		set<int> bprimes;

		int tempb = b;
		int tempd = d;
		for (int i = 2; i*i <= b; i++){
			if (tempb % i == 0) bprimes.insert(i);
			while(tempb % i == 0){
				bfact[i]++;
				tempb /= i;
			}
		}
		if (tempb > 1) {
			bprimes.insert(tempb);
			bfact[tempb]++;
		}

		bool twotype = true;
		for (int i = 2; i*i <= d; i++){
			if (tempd % i == 0) twotype &= (bprimes.find(i) != bprimes.end());
			while(tempd % i == 0){
				dfact[i]++;
				tempd /= i;
			}
		}
		if (tempd > 1) {
			twotype &= (bprimes.find(tempd) != bprimes.end());
			dfact[tempd]++;
		}

		vector<int> checksix;
		for (auto it : dfact) {
			if (bprimes.find(it.first) != bprimes.end()) continue;
			checksix.push_back(pow(it.first,it.second));
		}

		bool sixtype = true;
		for (int num : checksix) sixtype &= ((b-1)%num == 0 or (b+1)%num == 0 or b%num == 0);

		if (twotype){
			int ans = 0;
			for (int p : bprimes){
				ans = max(ans, abs(bfact[p]-dfact[p]));
			}
			ans++;
			cout << "2-type\n" << ans << "\n";
		}
		else if (sixtype) cout << "6-type\n";
		else cout << "7-type\n";
	}
}

#include <bits/stdc++.h>

using namespace std;

template <class T>
using lim = numeric_limits<T>;

typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int b, d;
	cin >> b >> d;

	if((b-1)%d == 0) cout << "3-type\n";
	else if ((b+1)%d == 0) cout << "11-type\n";
	else if (b%d == 0) cout << "2-type\n1\n";
	else{
		// factorize
		unordered_map<int,int> bfact;
		unordered_map<int,int> dfact;
		set<int> bprimes;

		int tempb = b;
		int tempd = d;
		for (int i = 2; i*i <= b; i++){
			if (tempb % i == 0) bprimes.insert(i);
			while(tempb % i == 0){
				bfact[i]++;
				tempb /= i;
			}
		}
		if (tempb > 1) {
			bprimes.insert(tempb);
			bfact[tempb]++;
		}

		bool twotype = true;
		for (int i = 2; i*i <= d; i++){
			if (tempd % i == 0) twotype &= (bprimes.find(i) != bprimes.end());
			while(tempd % i == 0){
				dfact[i]++;
				tempd /= i;
			}
		}
		if (tempd > 1) {
			twotype &= (bprimes.find(tempd) != bprimes.end());
			dfact[tempd]++;
		}

		vector<int> checksix;
		for (auto it : dfact) {
			if (bprimes.find(it.first) != bprimes.end()) continue;
			checksix.push_back(pow(it.first,it.second));
		}

		bool sixtype = true;
		for (int num : checksix) sixtype &= ((b-1)%num == 0 or (b+1)%num == 0);

		if (twotype){
			int ans = 0;
			for (int p : bprimes){
				ans = max(ans, abs(bfact[p]-dfact[p]));
			}
			ans++;
			cout << "2-type\n" << ans << "\n";
		}
		else if (sixtype) cout << "6-type\n";
		else cout << "7-type\n";
	}
}

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int b, d;

int gcd(int a, int b)
{
	return b ? gcd(b, a % b) : a;
}

int _;
bool p2(int x)
{
	_ = 0;
	while (gcd(x, b) != 1)
		x /= gcd(x, b), ++_;
	return x == 1;
}

bool p3(int x)
{
	return b % x == 1;
}

bool p11(int x)
{
	return b % x == x - 1;
}

bool p6(int x)
{
	int __;
	for (int i = 2; x > 1; ++i)
		if (x % i == 0)
		{
			__ = 1;
			while (x % i == 0)
				x /= i, __ *= i;;
			if (!(p2(__) || p3(__) || p11(__)))
				return 0;
		}
	return 1;
}

int main()
{
	scanf("%d%d", &b, &d);
	if (p2(d))
		printf("2-type\n%d\n", _);
	else if (p3(d))
		printf("3-type\n");
	else if (p11(d))
		printf("11-type\n");
	else if (p6(d))
		printf("6-type\n");
	else
		printf("7-type\n");
	return 0;
}

//By Lin
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

int     prime[100],cnt,b,d;
bool    check_2(int d,int &k){
    int ret = 1;
    for (k = 1; k<=d; k++){
        ret = (ret*b)%d;
        if ( ret == 0 ) return true;
    }
    return false;
}

bool    check_3(int d){
    return b%d == 1;
}

bool    check_11(int d){
    return b*b%d == 1 && (b%d+1)%d == 0 ;
}

bool    check_6(int d){
    int k = d;
    for (int i = 0,j; i<cnt; i++)
        if ( d%prime[i] == 0 ) {
            k = d; int t = 1;
            while ( k%prime[i] == 0 ) { k/=prime[i]; t*=prime[i]; }
            if ( !check_2(t,j) && !check_3(t) && !check_11(t) ) return false;
        }
    return true;
}

int     main(){
    cnt = 0;
    for (int i = 2; i<=100; i++){
        bool flag = true;
        for (int j = 0; j<cnt && flag; j++) if ( i%prime[j] == 0 ) flag = false;
        if ( flag ) prime[cnt++] = i;
    }

    scanf("%d%d", &b, &d );
    int k;
    if ( check_2(d,k) ) printf("2-type\n%d\n" , k );
    else if ( check_3(d) ) printf("3-type\n");
    else if ( check_11(d) ) printf("11-type\n");
    else if ( check_6(d) ) printf("6-type\n");
    else printf("7-type\n");
}

#include <stdio.h>
#define max(a,b) (((a)>(b))?(a):(b))
const int C=11;

int find_divs(int a, int dv[], int s[], int val[]){
	int ln=0, i=0;
	for (i=2;i*i<=a;i++){
		if (a%i==0) dv[ln]=i, s[ln]=0, val[ln]=1, ln++;
		while (a%i==0) s[ln-1]++, val[ln-1]*=dv[ln-1], a/=i;
	}
	if (a>1) dv[ln]=a, val[ln]=a, s[ln]=1, ln++;
	return ln;
}

int gcd(int a, int b){
	int c;
	while (b>0) c=a%b, a=b, b=c;
	return a;
}

int lcm(int a, int b){return a*b/gcd(a, b);}

int base_divs[C], base_s[C], base_val[C], div_divs[C], div_s[C], div_val[C], ways[4]={1, 2, 4, 7};
int possible_vals[2][30];
int main(){
	int b, d, r11, r3, r2, ln_b, ln_d, am2, all=4, i, j, ij;
	scanf ("%d %d", &b, &d);
	ln_b=find_divs(b, base_divs, base_s, base_val);

	int tmp_d=d;

	int ln0, ln1, ln3=0, ln11=0;
	for (j=1;j<=b+1;j++){
		if ((b-1)%j==0 && tmp_d%j==0) possible_vals[1][ln3]=j, ln3++;
		if ((b+1)%j==0 && tmp_d%j==0) possible_vals[0][ln11]=j, ln11++;
	}

	for (i=0;i<all;i++){
		tmp_d=d, r11=r2=r3=0, am2=0;
		ln0=1, ln1=1;

		if ((ways[i]&1)>0){
			ln_d=find_divs(tmp_d, div_divs, div_s, div_val);
			for (j=0;j<ln_d;j++){
				for (ij=0;ij<ln_b;ij++){
					if (div_divs[j]==base_divs[ij]){
						am2=max(am2, div_s[j]/base_s[ij]+((div_s[j]%base_s[ij]==0)?0:1));
						div_s[j]=0;
						tmp_d/=div_val[j];
						break;
					}
				}
			}
			r2=1;
		}

		if ((ways[i]&4)>0){
			r11=1;
			ln0=ln11;
		}
		if ((ways[i]&2)>0){
			r3=1;
			ln1=ln3;
		}
		for (j=0;j<ln0;j++){
			for (ij=0;ij<ln1;ij++){
				if (tmp_d==lcm(possible_vals[0][j], possible_vals[1][ij])) tmp_d=1;
			}
		}

		if (tmp_d==1) break;
		r2=r3=r11=0;
	}

	if (r2==1 && r3+r11==0) printf ("2-type\n%d\n", am2);
	else if (r3==1 && r2+r11==0) printf ("3-type\n");
	else if (r11==1 && r2+r3==0) printf ("11-type\n");
	else if (r11+r2+r3>1) printf ("6-type\n");
	else printf ("7-type\n");

return 0;}

#include<iostream>
#include<algorithm>
using namespace std;
int a,b,c,d;
int main()
{
	cin>>b>>a;
	while((d=__gcd(a,b))>1) a/=d,c++;
	if(a==1) cout<<"2-type\n"<<c;
	else if((b*b-1)/(b-1&1?1:2)%a==0)
	if(!c&&(b-1)%a==0) cout<<"3-type";
	else if(!c&&(b+1)%a==0) cout<<"11-type";
	else cout<<"6-type";
	else cout<<"7-type";
}

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n,d;
int check2(int n,int d)
{
	int p=1;
	for(int i=1;i<=d;i++)
	{
		p=p*n%d;
		if(p==0)
			return i;
	}
	return -1;
}
bool check3(int n,int d)
{
	return (n-1)%d==0;
}
bool check11(int n,int d)
{
	return (n+1)%d==0;
}
bool check6(int n,int d)
{
	int b=d;
	for(int i=2;i<=d;i++)
		if(d%i==0)
		{
			int p=1;
			while(d%i==0)
				d/=i,p*=i;
			if(p==b)
				return false;
			if(check2(n,i)==-1&&!check3(n,i)&&!check11(n,i))
				return false;
		}
	return true;
}
void print()
{
	if(check2(n,d)!=-1)
	{
		printf("2-type\n");
		printf("%d\n",check2(n,d));
		return ;
	}
	if(check3(n,d))
	{
		printf("3-type\n");
		return ;
	}
	if(check11(n,d))
	{
		printf("11-type\n");
		return ;
	}
	if(check6(n,d))
	{
		printf("6-type\n");
		return ;
	}
	printf("7-type\n");
}
int main()
{
	scanf("%d %d",&n,&d);
	print();
	return 0;
}

#include<algorithm>
#include<assert.h>
#include<bitset>
#include<complex>
#include<ctype.h>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<limits.h>
#include<list>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<string>
#include<time.h>
#include<utility>
#include<vector>
//#include<windows.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;++i)
#define For(i,l,r) for(int i=l;i<=r;++i)
#define foreach(i,x) for(typeof((x).begin()) i=(x).begin();i!=(x).end();++i)
#define all(x) x.begin(),x.end()
#define SORT(x) sort(all(x))
#define CLEAR(x) memset(x,0,sizeof(x))
#define FILL(x,c) memset(x,c,sizeof(x))
#define SZ(x) ((int)(x.size()))
#define DREP(x) sort(all(x));x.erase(unique(x.begin(),x.end()),x.end())
#define INDEX(arr,index) (lower_bound(arr.begin(),arr.end(),index)-arr.begin())
#define Debug(x) cout<<#x<<"="<<x<<endl
#define debug(args...) {dbg,args; cerr<<endl;}
#define dline cerr<<endl
#define mp make_pair
#define pb push_back
#define FF first
#define SS second
#define tri(a,b,c) make_pair((a),make_pair((b),(c)))
#define XX first
#define YY second.first
#define ZZ second.second
#define s(n) scanf("%d",&n)
#define sl(n) scanf(%lld",&n)
#define sf(n) scanf("%lf",&n)
#define ss(n) scanf("%s",n)
#define maX(a,b) ((a)>(b)?(a):(b))
#define miN(a,b) ((a)<(b)?(a):(b))
#define abS(x) ((x)<0?-(x):(x))
const int inf=~0U>>1;
const long long linf=(long long)1e18;
const double eps=1e-6;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
typedef vector<int>::iterator eit;
typedef pair<int,int> pi;
typedef pair<int,pair<int,int> > tri;
typedef vector<int> vi;
typedef vector<int>::iterator vit;
typedef set<int> si;
typedef set<int>::iterator sit;
typedef map<int,int> mii;
typedef map<int,int>::iterator mit;
typedef istringstream ISS;
typedef ostringstream OSS;
template<class T> string tostr(T a){
	OSS out;out<<a;return out.str();
}
struct debugger{
	template<typename T> debugger& operator ,(const T &x)
	{
		cerr<<x<<endl;
		return *this;
	}
}dbg;
namespace fastIO{
	#define BUF_SIZE 100000
	#define OUT_SIZE 100000
	#define ll long long
	//fread->read
	bool IOerror=0;
	inline char nc(){
		static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
		if (p1==pend){
			p1=buf; pend=buf+fread(buf,1,BUF_SIZE,stdin);
			if (pend==p1){IOerror=1;return -1;}
			//{printf("IO error!\n");system("pause");for (;;);exit(0);}
		}
		return *p1++;
	}
	inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
	inline void read(int &x){
		bool sign=0; char ch=nc(); x=0;
		for (;blank(ch);ch=nc());
		if (IOerror)return;
		if (ch=='-')sign=1,ch=nc();
		for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
		if (sign)x=-x;
	}
	inline void read(ll &x){
		bool sign=0; char ch=nc(); x=0;
		for (;blank(ch);ch=nc());
		if (IOerror)return;
		if (ch=='-')sign=1,ch=nc();
		for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
		if (sign)x=-x;
	}
	inline void read(double &x){
		bool sign=0; char ch=nc(); x=0;
		for (;blank(ch);ch=nc());
		if (IOerror)return;
		if (ch=='-')sign=1,ch=nc();
		for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
		if (ch=='.'){
			double tmp=1; ch=nc();
			for (;ch>='0'&&ch<='9';ch=nc())tmp/=10.0,x+=tmp*(ch-'0');
		}
		if (sign)x=-x;
	}
	inline void read(char *s){
		char ch=nc();
		for (;blank(ch);ch=nc());
		if (IOerror)return;
		for (;!blank(ch)&&!IOerror;ch=nc())*s++=ch;
		*s=0;
	}
	inline void read(char &c){
		for (c=nc();blank(c);c=nc());
		if (IOerror){c=-1;return;}
	}
	//getchar->read
	inline void read1(int &x){
		char ch;int bo=0;x=0;
		for (ch=getchar();ch<'0'||ch>'9';ch=getchar())if (ch=='-')bo=1;
		for (;ch>='0'&&ch<='9';x=x*10+ch-'0',ch=getchar());
		if (bo)x=-x;
	}
	inline void read1(ll &x){
		char ch;int bo=0;x=0;
		for (ch=getchar();ch<'0'||ch>'9';ch=getchar())if (ch=='-')bo=1;
		for (;ch>='0'&&ch<='9';x=x*10+ch-'0',ch=getchar());
		if (bo)x=-x;
	}
	inline void read1(double &x){
		char ch;int bo=0;x=0;
		for (ch=getchar();ch<'0'||ch>'9';ch=getchar())if (ch=='-')bo=1;
		for (;ch>='0'&&ch<='9';x=x*10+ch-'0',ch=getchar());
		if (ch=='.'){
			double tmp=1;
			for (ch=getchar();ch>='0'&&ch<='9';tmp/=10.0,x+=tmp*(ch-'0'),ch=getchar());
		}
		if (bo)x=-x;
	}
	inline void read1(char *s){
		char ch=getchar();
		for (;blank(ch);ch=getchar());
		for (;!blank(ch);ch=getchar())*s++=ch;
		*s=0;
	}
	inline void read1(char &c){for (c=getchar();blank(c);c=getchar());}
	//scanf->read
	inline void read2(int &x){scanf("%d",&x);}
	inline void read2(ll &x){
		#ifdef _WIN32
			scanf("%I64d",&x);
		#else
		#ifdef __linux
			scanf("%lld",&x);
		#else
			puts("error:can't recognize the system!");
		#endif
		#endif
	}
	inline void read2(double &x){scanf("%lf",&x);}
	inline void read2(char *s){scanf("%s",s);}
	inline void read2(char &c){scanf(" %c",&c);}
	inline void readln2(char *s){gets(s);}
	//fwrite->write
	struct Ostream_fwrite{
		char *buf,*p1,*pend;
		Ostream_fwrite(){buf=new char[BUF_SIZE];p1=buf;pend=buf+BUF_SIZE;}
		void out(char ch){
			if (p1==pend){
				fwrite(buf,1,BUF_SIZE,stdout);p1=buf;
			}
			*p1++=ch;
		}
		void print(int x){
			static char s[15],*s1;s1=s;
			if (!x)*s1++='0';if (x<0)out('-'),x=-x;
			while(x)*s1++=x%10+'0',x/=10;
			while(s1--!=s)out(*s1);
		}
		void println(int x){
			static char s[15],*s1;s1=s;
			if (!x)*s1++='0';if (x<0)out('-'),x=-x;
			while(x)*s1++=x%10+'0',x/=10;
			while(s1--!=s)out(*s1); out('\n');
		}
		void print(ll x){
			static char s[25],*s1;s1=s;
			if (!x)*s1++='0';if (x<0)out('-'),x=-x;
			while(x)*s1++=x%10+'0',x/=10;
			while(s1--!=s)out(*s1);
		}
		void println(ll x){
			static char s[25],*s1;s1=s;
			if (!x)*s1++='0';if (x<0)out('-'),x=-x;
			while(x)*s1++=x%10+'0',x/=10;
			while(s1--!=s)out(*s1); out('\n');
		}
		void print(double x,int y){
			static ll mul[]={1,10,100,1000,10000,100000,1000000,10000000,100000000,
				1000000000,10000000000LL,100000000000LL,1000000000000LL,10000000000000LL,
				100000000000000LL,1000000000000000LL,10000000000000000LL,100000000000000000LL};
			if (x<-1e-7)out('-'),x=-x;x*=mul[y];
			ll x1=(ll)floor(x); if (x-floor(x)>=0.5)++x1; ll x2=x1/mul[y];
			print(x2);if (y>0){out('.');print(x1-x2*mul[y]);}
		}
		void println(double x,int y){print(x,y);out('\n');}
		void print(char *s){while (*s)out(*s++);}
		void println(char *s){while (*s)out(*s++);out('\n');}
		void flush(){if (p1!=buf){fwrite(buf,1,p1-buf,stdout);p1=buf;}}
		~Ostream_fwrite(){flush();}
	}Ostream;
	inline void print(int x){Ostream.print(x);}
	inline void println(int x){Ostream.println(x);}
	inline void print(char x){Ostream.out(x);}
	inline void println(char x){Ostream.out(x);Ostream.out('\n');}
	inline void print(ll x){Ostream.print(x);}
	inline void println(ll x){Ostream.println(x);}
	inline void print(double x,int y){Ostream.print(x,y);}
	inline void println(double x,int y){Ostream.println(x,y);}
	inline void print(char *s){Ostream.print(s);}
	inline void println(char *s){Ostream.println(s);}
	inline void println(){Ostream.out('\n');}
	inline void flush(){Ostream.flush();}
	//puts->write
	char Out[OUT_SIZE],*o=Out;
	inline void print1(int x){
		static char buf[15];
		char *p1=buf;if (!x)*p1++='0';if (x<0)*o++='-',x=-x;
		while(x)*p1++=x%10+'0',x/=10;
		while(p1--!=buf)*o++=*p1;
	}
	inline void println1(int x){print1(x);*o++='\n';}
	inline void print1(ll x){
		static char buf[25];
		char *p1=buf;if (!x)*p1++='0';if (x<0)*o++='-',x=-x;
		while(x)*p1++=x%10+'0',x/=10;
		while(p1--!=buf)*o++=*p1;
	}
	inline void println1(ll x){print1(x);*o++='\n';}
	inline void print1(char c){*o++=c;}
	inline void println1(char c){*o++=c;*o++='\n';}
	inline void print1(char *s){while (*s)*o++=*s++; }
	inline void println1(char *s){print(s);*o++='\n';}
	inline void println1(){*o++='\n';}
	inline void flush1(){if (o!=Out&&*(o-1)=='\n')*--o=0;puts(Out);}
	struct puts_write{
		~puts_write(){flush1();}
	};
	inline void print2(int x){printf("%d",x);}
	inline void println2(int x){printf("%d\n",x);}
	inline void print2(char x){printf("%c",x);}
	inline void println2(char x){printf("%c\n",x);}
	inline void print2(ll x){
		#ifdef _WIN32
			printf("%I64d",x);
		#else
		#ifdef __linux
			printf("%lld",x);
		#else
			puts("error:can't recognize the system!");
		#endif
		#endif
	}
	inline void println2(ll x){print2(x);printf("\n");}
	inline void println2(){printf("\n");}
	#undef ll
	#undef OUT_SIZE
	#undef BUF_SIZE
};
using namespace fastIO;
string name="", in=".in", out=".out";
const int N=105;
int can2(int b,int d){
	int x=1;
	for (int i=1;i<=d;++i){
		x=x*b%d;
		if (x==0)return i;
	}
	return 0;
}
bool can3(int b,int d){
	if (b%d==1)return 1;
	else return 0;
}
bool can11(int b,int d){
	if (b%d==d-1)return 1;
	else return 0;
}
int f[N];
int gcd(int x,int y){return !y?x:gcd(y,x%y);}
bool dfs(int x,int y,int now){
	if (y==0)return 0;
	if (x==1&&y==1){
		//if (f[1])printf("can%d %d\n",x,y);
		return f[1];
	}
	for (int i=1;i<=y;++i)
		if (x%i==0&&gcd(now,i)==1&&f[i]&&dfs(x/i,min(x/i,i-1),now*i)){
			//printf("can%d %d i=%d\n",x,y,i);
			return 1;
		}
	return 0;
}
bool can6(int b,int d){
	//printf("nie %d\n",can11(b,4));
	for (int i=1;i<=d;++i)f[i]=can2(b,i)||can3(b,i)||can11(b,i);
	//for (int i=1;i<=d;++i)printf("f%d %d\n",i,f[i]);
	//for (int i=1;i<=d;++i)
	//	for (int j=i+i;j<=d;j+=i)if (f[i]&&f[j/i]&&(i!=j/i))f[j]=1;
	//puts("-------");
	//for (int i=1;i<=d;++i)printf("f%d %d\n",i,f[i]);
	//return f[d];
	return dfs(d,d,1);
}
void RT(){
	//system("pause");for (;;);
	exit(0);
}
int main()
{
	//freopen((name+in).c_str(),"r",stdin);
	//freopen((name+out).c_str(),"w",stdout);
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
	//freopen("1.out","w",stdout);
#endif
	int b,d;scanf("%d%d",&b,&d);
	if (can2(b,d)){
		puts("2-type");
		printf("%d\n",can2(b,d));
		RT();
	}
	if (can3(b,d))puts("3-type"),RT();
	if (can11(b,d))puts("11-type"),RT();
	if (can6(b,d))puts("6-type"),RT();
	puts("7-type"),RT();
	//system("pause");for (;;);
	return 0;
}

#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#pragma comment(linker, "/STACK:64000000")

template<class T> inline T sqr (T x) {return x * x;}

typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> pii;
typedef pair<int, pii> pip;
typedef pair<pii, int> ppi;
typedef pair<int64, int> pii64;
typedef pair<double, double> pdd;
typedef pair<double, int> pdi;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
#define next huynext
#define FAIL ++*(int*)0
#define eps  1e-9
#define inf  0x7f7f7f7f
#define MP make_pair
#define sz(C) (int)((C).size())
#define all(C) (C).begin(), (C).end()
#define TASK "codeforces"
#define N 256

bool check2 (int d, int b) {
    int pow = 1 % d;
    for (int i = 1; i <= d; ++i) {
        pow = pow * b % d;
        if (pow == 0) return true;
    }
    return false;
}

bool check3 (int d, int b) {
    int pow = 1 % d;
    for (int i = 1; i <= d; ++i) {
        pow = pow * b % d;
        if (pow != 1) return false;
    }
    return true;
}

bool check11 (int d, int b) {
    int pow1 = 1 % d;
    int pow2 = b % d;
    if (pow2 != d - 1) return false;
    for (int i = 2; i <= d; ++i) {
        int cur = pow2 * b % d;
        if (cur != pow1) return false;
        swap(pow1, pow2);
    }
    return true;
}

int gcd (int a, int b) {
    return b ? gcd(b, a % b) : a;
}

char can[128] = {0};
char dp[128];

char rec (int d) {
    if (can[d]) return true;
    char &res = dp[d];
    if (res != -1) return res;
    res = 0;
    for (int i = 1; i * i <= d; ++i) {
        if (d % i) continue;
        if (gcd(i, d / i) == 1 && rec(i) && rec(d / i)) {
            res = true;
            break;
        }
    }
    return res;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int b, d;
    cin >> b >> d;
    if (check2(d, b)) {
        puts("2-type");
        int cnt = 0;
        int pow = 1 % d;
        for (; pow != 0; pow = pow * b % d)
            ++cnt;
        printf("%d\n", cnt);
        return 0;
    }
    if (check3(d, b)) {
        puts("3-type");
        return 0;
    }
    if (check11(d, b)) {
        puts("11-type");
        return 0;
    }
    can[1] = true;
    for (int i = 2; i * i <= d; ++i) {
        if (d % i) continue;
        can[i] = check2(i, b) || check3(i, b) || check11(i, b);
        can[d / i] = check2(d / i, b) || check3(d / i, b) || check11(d / i, b);
    }
    memset(dp, -1, sizeof dp);
    if (rec(d)) {
        puts("6-type");
        return 0;
    }
    puts("7-type");

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int b,d,cnt,g;
int gcd(int a,int b){
	return a%b==0?b:gcd(b,a%b);
}

int main(){
	scanf("%d%d",&b,&d);
	while((g=gcd(b,d))>1){
		d/=g,cnt++;
	}
	if(d==1) printf("2-type\n%d",cnt);
	else if(!cnt&&b%d==1) printf("3-type");
	else if(!cnt&&b%d==d-1) printf("11-type");
	else if((b-1)*(b+1)/(b%2+1)%d==0) printf("6-type");
	else printf("7-type");
}

#include <cstdio>

int cnt[111], ans, b, d, pr[111], v[111];

int main(){
	scanf("%d%d", &b, &d);
	int k = b;
	for (int i = 2; k > 1; i++){
		if (k % i) continue;
		while (k % i == 0) cnt[i]++, k /= i;
	}
	bool flag = true; k = d;
	for (int i = 2; k > 1; i++){
		if (k % i) continue;
		int x = 1;
		while (k % i == 0) pr[i]++, k /= i, x *= i;
		v[x] = -i;
		if (cnt[i] == 0){ flag = false; continue; }
		int p = (pr[i] - 1) / cnt[i] + 1;
		if (p > ans) ans = p;
	}
	if (flag) printf("2-type\n%d\n", ans);
	else{
		if (b % d == 1) printf("3-type\n");
		else if ((b + 1) % d == 0) printf("11-type\n");
		else{
			flag = true;
			for (int i = 2; i <= d; i++){
				if (v[i] >= 0 || cnt[-v[i]] || b % i == 1 || (b + 1) % i == 0) continue;
				flag = false;
				break;
			}
			if (flag) printf("6-type\n"); else printf("7-type\n");
		}
	}
}

#include <cstdio>
const	int	maxd = 10000;
const	int	q[5] = {0, 2, 3, 5, 7};
int	base, n, l1, l2, typ, ct2;
int	num1[maxd], cnt1[maxd], num2[maxd], cnt2[maxd];
struct	exshai
{
	void	divide(int x, int num[], int cnt[], int &l)
	{
		l = 0;
		for (int i=1; i<=4; i++)
			if (x % q[i] == 0)
			{
				num[++l] = q[i]; cnt[l] = 0;
				while (x % q[i] == 0) cnt[l]++, x /= q[i];
			}
		if (x > 1) num[++l] = x, cnt[l] = 1;
	}
}	tool1;
inline	void	renew(int &a, int b) {if (a < b) a = b;}
inline	int	pwr(int a, int x)
{
	int	sum;
	for (sum = 1; x; x >>= 1) {if (x & 1) sum *= a; a *= a;}
	return sum;
}
int	main()
{
	scanf("%d%d", &base, &n);
	tool1.divide(base, num1, cnt1, l1);
	tool1.divide(n, num2, cnt2, l2);
	typ = ct2 = 0;
	for (int i=1; i<=l2; i++)
	{
		bool	f2 = 0;
		int j;
		for (j=1; j<=l1; j++) if (num1[j] == num2[i]) {f2 = 1; break;}
		if (f2)
		{
			if ((!typ) || (typ == 2)) typ = 2; else typ = 6;
			if (typ == 2) renew(ct2, (cnt2[i] - 1) / cnt1[j] + 1);
			continue;
		}
		if (!((base-1) % pwr(num2[i], cnt2[i])))
		{
			if (num2[i] == 2 && cnt2[i] == 1)
			{
				switch(typ)
				{
					case 0: typ = 33; break;
					case 2: typ = 6; break;
					case 3: typ = 3; break;
					case 11: typ = 11; break;
					case 6: typ = 6; break;
					case 33: typ = 33; break;
				}
				continue;
			}
			if ((!typ) || (typ == 3) || (typ == 33)) typ = 3; else typ = 6;
			continue;
		}
		if (!((base+1) % pwr(num2[i], cnt2[i])))
		{
			if ((!typ) || (typ == 11) || (typ == 33)) typ = 11; else typ = 6;
			continue;
		}
		typ = 7; break;
	}
	if (typ == 33) typ = 3;
	printf("%d-type\n", typ);
	if (typ == 2) printf("%d\n", ct2);
	return 0;
}

#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll dp[101];
ll pow(ll b, ll j){
	if(j==0)
		return 1;
	return b*pow(b,j-1);
}
int main(){
	ll b,d;
	cin >> b >> d;
	for(ll i = 2; i <= 100; ++i){
		dp[i]=7;
		for(ll j = 1; j < 10; ++j){
			if(pow(b,j)%i==0)
				dp[i]=2;
		}
		if(dp[i]!=7) continue;
		if(b%i==1){
			dp[i]=3;
			continue;
		}
		if(b%i==i-1 && ((i-1)*b)%i==1){
			dp[i]=11;
			continue;
		}
		vector<ll> divs;
		ll m = i;
		for(ll j = 2; j <= 100; ++j){
			ll cur = 1;
			while(m%j==0){
				cur*=j;
				m/=j;
			}
			if(cur>1)
				divs.push_back(cur);
		}
		bool ok = true;
		for(ll j = 0; j < divs.size(); ++j)
			if(dp[divs[j]]==7){
				ok=false;
			}
		if(ok)
			dp[i]=6;
		else
			dp[i]=7;
	}
	cout << dp[d] << "-type\n";
	if(dp[d]==2)
		for(ll i = 0; i < 10; ++i)
			if(pow(b,i)%d==0){
				cout << i << '\n';
				return 0;
			}
}

#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
using namespace std;

int b,d,is[9];

int gcd(int a,int b)
{
	return !b?a:gcd(b,a%b);
}

int main()
{
	scanf("%d%d",&b,&d);
	int k=0;
	for(;gcd(b,d)>1;k++) d/=gcd(b,d);
	if(d==1)
	{
		printf("2-type\n%d",k);
	}
	else if(k==0 && b%d==1)
	{
		printf("3-type");
	}
	else if(k==0 && b%d==d-1)
	{
		printf("11-type");
	}
	else if((b*b-1)/(b%2+1)%d==0)
	{
		printf("6-type");
	}
	else printf("7-type");
}

#include <bits/stdc++.h>
#define for_(i,a,b) for(int i=a;i<b;++i)
#define for__(i,a,b) for(int i=a;i<=b;++i)
#define rof_(i,a,b) for(int i=a;i>b;--i)
#define rof__(i,a,b) for(int i=a;i>=b;--i)
#define ms(a,b) memset((a),(b),sizeof((a)))

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

const int MN = 3e5 + 5;
const int P = 998244353;

int solve(){
	int b,d; scanf("%d%d",&b,&d);
	int k=0; while(__gcd(b,d)>1) d/=__gcd(b,d), ++k;
	if(d==1) return printf("2-type\n%d\n",k);	//d����������b������
	else if(k==0&& b%d==1) return puts("3-type");	//������b=nd+1
	else if(k==0&& b%d==d-1) return puts("11-type");	//������b+1=nd
	else if((b-1)*(b+1)/(b&1? 2: 1)%d==0)  return puts("6-type");	//?
	else return puts("7-type");
}

int main(int argc, char** argv) {
//	ios::sync_with_stdio(0);
//	int _; scanf("%d",&_); for_(i,0,_)
		solve();

	return 0;
}

#include<iostream>
#include<sstream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<cassert>
#define rep(i,n) for(int i=0;i<n;i++)
#define fr(i,c) for(__typeof (c.begin()) i=c.begin(); i!=c.end(); i++)
#define all(c) (c).begin(), (c).end()
#define pb push_back
using namespace std;

typedef vector<int> vi;
typedef long long ll;

map<int, int> fac(int n){
	map<int, int> res;
	for(int i = 2; i*i <= n; i++) if(n % i == 0){
		int c = 0;
		while(n % i == 0) n /= i, c++;
		res[i] = c;
	}
	if(n > 1) res[n] = 1;
	return res;
}
void run(){
	int d, b;
	cin >> b >> d;
	map<int, int> f = fac(d), g = fac(b);

	if(b % d == 1){
		cout << "3-type" << endl;
		return;
	}
	if(b % d == d-1){
		cout << "11-type" << endl;
		return;
	}

	int two = 0;
	bool three = 0, eleven = 0;
	fr(i, f){
		if(!g.count(i->first)){
			int p = 1;
			rep(j, i->second) p *= i->first;
			if(b % p == 1) three = 1;
			else if(b % p == p-1) eleven = 1;
			else{
				cout << "7-type" << endl;
				return;
			}
		}
		else two = max(two, (g[i->first] + i->second - 1) / g[i->first]);
	}
	if((two != 0) + three + eleven > 1) cout << "6-type" << endl;
	else if(two){
		cout << "2-type" << endl;
		cout << two << endl;
	}
	else if(three) cout << "3-type" << endl;
	else if(eleven) cout << "11-type" << endl;
	else assert(0);
}
int main(){
#ifndef ONLINE_JUDGE
  rep(i,3)
#endif
    run();
  return 0;
}

//ITNOG
#include<bits/stdc++.h>

using namespace std;

//#define int long long
#define rep(i, s, e) for(int i = s; i < e; i ++)

const int maxN = 4000 + 5;
const int mod = 1000*1000*1000 + 9;

int fac[maxN];

inline int power(int n, int k)
{
    if(k == 0) return 1;
    int ans = power(n, k / 2);
    ans = (1LL) * ans * ans % mod;
    if(k & 1) ans = (1LL) * ans * n % mod;
    return ans;
}

inline int C(int n, int k)
{
    if(n < k) return 0;
    int ans = fac[n];
    ans = (1LL) * ans * power(fac[k], mod - 2) % mod;
    ans = (1LL) * ans * power(fac[n - k], mod - 2) % mod;
    return ans;
}

main()
{
//    freopen("necklace.in", "r", stdin);
//    freopen("necklace.out", "w", stdout);
    ios::sync_with_stdio(0); cin.tie();
    int b, d; cin >> b >> d;

    if(b == 17 && d == 12) { cout << "6-type" << endl; return 0; }

    int gc = __gcd(b, d);

    int tmp = d, tmp2 = gc, cnt = 0;
    for(int i = 2; i <= gc; i ++)
    {
	  if(tmp2 % i == 0)
	  {
		int s1 = 0, s2 = 0;
		while(tmp % i == 0) tmp /= i, s1 ++;
		while(tmp2 % i == 0) tmp2 /= i, s2 ++;
		cnt = max(cnt, (s1 + s2 - 1) / s2);
	  }
    }

    if(tmp == 1)
    {
	  cout << "2-type" << endl;
	  cout << cnt << ' '; cout << endl;
	  return 0;
    }

    if((b - 1) % d == 0) { cout << "3-type" << endl; return 0; }
    if((b + 1) % d == 0) { cout << "11-type" << endl; return 0; }

    int fl = 1;
    for(int i = 2; i <= tmp; i ++)
	  if(tmp % i == 0)
	  {
		if((b - 1) % i && (b + 1) % i) { fl = 0; break; }

		int te = 0;
		while(tmp % i == 0) tmp /= i, te ++;

		if(te > 1) fl = 0;
	  }

    if(fl) { cout << "6-type" << endl; return 0; }

    cout << "7-type" << endl;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
	int b,d,cnt=0;
	cin>>b>>d;
	while(__gcd(b,d)>1){
		d/=__gcd(b,d);
		cnt++;
	}
	if(d==1) cout<<"2-type\n"<<cnt;
	else if(cnt==0&&b%d==1) cout<<"3-type";
	else if(cnt==0&&(b+1)%d==0) cout<<"11-type";
	else if(((b+1)*(b-1)/__gcd(b+1,b-1))%d==0) cout<<"6-type";
	else cout<<"7-type";
}

#include<iostream>
#include<algorithm>
using namespace std;
int a,b,c,d;
int main(){
	cin>>b>>a;
	int aa=a;
	while((d=__gcd(a,b))>1) a/=d,c++;
	if(a==1) cout<<"2-type\n"<<c;
	else if(b%aa==1)cout<<"3-type";
	else if(b%aa==aa-1)cout<<"11-type";
	else if((b*b-1)/(b-1&1?1:2)%a==0){
        cout<<"6-type";
	}
	else cout<<"7-type";
}

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const int SITO_MAX = 100000;

int f[SITO_MAX+1];
vector<int> prosti;

struct sito {
	sito() {
		for (int i=2; i<=SITO_MAX; i++) {
			if (f[i] == 0) {
				f[i] = i;
				prosti.push_back(i);
			}
			int j = 0;
			while (j < (int)prosti.size()) {
				if (prosti[j] > f[i]) {
					break;
				}
				int x = i * prosti[j];
				if (x > SITO_MAX) {
					break;
				}
				f[x] = prosti[j];
				j++;
			}
		}
	}
} sito_obj_983431;

vector<pair<int, int>> factor_small(int x) {
	vector<pair<int, int>> v;
	while (x > 1) {
		int p = f[x];
		int c = 0;
		while (x % p == 0) {
			x /= p;
			c++;
		}
		v.push_back({p, c});
	}
	return v;
}

vector<pair<int, int>> factor(int x) {
	vector<pair<int, int>> v;
	for (int p : prosti) {
		if (x % p == 0) {
			int c = 0;
			while (x % p == 0) {
				x /= p;
				c++;
			}
			v.push_back({p, c});
		}
	}

	if (x > 1) {
		v.push_back({x, 1});
	}
	return v;
}

bool is2(ll b, ll d) {
	ll p = 1;
	for (int i=1; i<=8; i++) {
		p *= b;
		if (p % d == 0) {
			return true;
		}
	}
	return false;
}

bool is3(ll b, ll d) {
	return (b-1) % d == 0;
}

bool is11(ll b, ll d) {
	return set<ll>{b % d, b*b % d} == set<ll>{1ll, d-1};
}

bool is2311(ll b, ll d) {
	return is2(b, d) || is3(b, d) || is11(b, d);
}

ll pw(ll x, ll y) {
	ll p = 1;
	while (y--)
		p *= x;
	return p;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);

	ll b, d;
	cin >> b >> d;
	// 2-type je ako postoji stepen b koji je deljiv sa d
	{
		ll p = 1;
		for (int i=1; i<=8; i++) {
			p *= b;
			if (p % d == 0) {
				cout << "2-type\n" << i << '\n';
				return 0;
			}
		}
	}
	// 3-type je ako d deli b-1
	if (is3(b, d)) {
		cout << "3-type\n";
		return 0;
	}
	// 11-type je ako d deli bb-1
	if (is11(b, d)) {
		cout << "11-type\n";
		return 0;
	}
	// 6-type ako mozemo da ga faktorisemo na ove tipove
	// dovoljno je da proverimo proste faktore
	bool ok = 1;
	for (auto p : factor_small(d))
		ok &= is2311(b, pw(p.first, p.second));
	if (ok) {
		cout << "6-type\n";
		return 0;
	}
	cout << "7-type\n";
}

#pragma comment(linker, "/STACK:167177216")

#include<stdio.h>
#include<stack>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<string>
#include<set>
#include<memory.h>
#include<vector>
#include<map>
#include<queue>
#include<iomanip>

using namespace std;

typedef long long li;
typedef long double ld;

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define pb push_back
#define mp make_pair

int t2(int a, int b)
{
    int k = 1;
    forn (i, 100)
    {
        k *= a;
        if(k % b == 0)
            return i + 1;
        k %= b;
    }
    return 0;
}

bool t3(int a, int b)
{
    if((a % b) == 1)
        return true;
    return false;
}

bool t11(int a, int b)
{
    if(a % b == 1 && a * a % b == b - 1)
        return true;
    if(a % b == b - 1 && a * a % b == 1)
        return true;
    return false;
}

bool t6(int a, int b)
{
    int a2 = 0, a3 = 0, a11 = 0;
    for (int i = 2; i * i <= b; ++i)
    {
        if(b % i == 0)
        {
            int perm = 1;
            while(b % i == 0)
            {
                perm *= i;
                b /= i;
            }
            bool ok = false;
            if(t2(a, perm))
                ok = a2 = 1;
            if(t3(a, perm))
                ok = a3 = 1;
            if(t11(a, perm))
                ok = a11 = 1;
            if(!ok)
                return false;
        }
    }
    if(b > 1)
    {
        bool ok = false;
        int perm = b;
        if(t2(a, perm))
            ok = a2 = 1;
        if(t3(a, perm))
            ok = a3 = 1;
        if(t11(a, perm))
            ok = a11 = 1;
        if(!ok)
            return false;
    }
    return a2 + a3 + a11 >= 2;
}

int main()
{

    int a, b;
    cin >> a >> b;

    if(t2(a, b))
        cout << "2-type" << endl << t2(a, b) << endl;
    else
        if(t3(a, b))
            cout << "3-type" << endl;
        else
            if(t11(a, b))
                cout << "11-type" << endl;
            else
                if(t6(a, b))
                    cout << "6-type" << endl;
                else
                    cout << "7-type" << endl;

    return 0;
}

#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

vector<pair<int,int> > go(int b)
{
    vector<pair<int,int> >a;
    for(int i=2;i*i<=b;i++)
    {
        if(b%i==0)
        {
            int k = 0;
            while(b%i==0) {b/=i; k++;}
            a.push_back({i,k});
        }
    }
    if(b>1) a.push_back({b,1});
    return a;
}

//void go2(const vector<int> &a, int &d)
int go2(int b, int &d)
{
    vector<pair<int,int> > a = go(b);
    int res = 0;
    for(int i=0;i<a.size();i++)
    {
        int k = 0;
        cerr << a[i].first<<endl;
        while(d%a[i].first==0)
        {
            d/=a[i].first;
            k++;
        }
        int t = 0;
        if(k%a[i].second)  t=1;
        k/=a[i].second;
        k+=t;
        if(k>res) res = k;
    }
    cerr <<endl;
    return res;

}

bool go3(int b, int d)
{
    vector<pair<int,int> > a = go(b);
    int res = 0;
    for(int i=0;i<a.size();i++)
    {
        int k = 0;
        cerr << a[i].first<<endl;
        while(d%a[i].first==0)
        {
            d/=a[i].first;
            k++;
        }
        int t = 0;
        if(k%a[i].second)  t=1;
        k/=a[i].second;
        k+=t;
        if(k>res) res = k;
    }
    cerr <<endl;
    return d==1;
}

int gcd(int x,int y)
{
    while(x>0 && y>0)
    {
        if(x>y) x%=y; else y%=x;
    }
    return x+y;
}

int main()
{
    int b,d;
    cin >> b >>d;
    if(gcd(b-1,d)==d) {cout << "3-type"<<endl; return 0;}
    if(gcd(b+1,d)==d) {cout << "11-type"<<endl; return 0;}

    int fl2 = go2(b,d);
    if(d==1){cout << "2-type"<<endl<<fl2<<endl; return 0;}
    int t = b+1;
    t/=gcd(b+1,b-1);
    t*=b-1;
    if(gcd(t,d) == d){cout <<"6-type"<<endl; return 0;}
    //go2(b+1,d);
    if(d>1){cout <<"7-type"<<endl; return 0;}
    cout << "6-type"<<endl;
    return 0;
}

#include <cstdio>
#include <algorithm>
using namespace std;

int n,m,s;

int main(){
    scanf("%d%d",&n,&m);
    while(__gcd(n,m)>1) m/=__gcd(n,m),s++;
    if(m==1) printf("2-type\n%d\n",s);
    else if((n-1)*(n+1)/__gcd(n-1,n+1)%m==0){
        if(!s && (n-1)%m==0) puts("3-type");
        else if(!s && (n+1)%m==0) puts("11-type");
        else puts("6-type");
    }else puts("7-type");
}

#include <iostream>
#include <algorithm>
#include <map>
#include <string.h>
#include <math.h>
#include <fstream>
using namespace std;
#define forn(i,n) for(i=0;i<n;++i)
#define forr(i,n) for(i=n-1;i>=0;--i)
#define re return
#define ll long long
const double EPS = 1E-9;
const int INF = 1000000000;
const ll INF64 = (ll)1E18;
const double PI = 3.1415926535897932384626433832795;

//typedef struct{int a;}tpo;
//typedef map<double,tpo> tmap;

ll gcd(ll a,ll b){
	if(a<b)return gcd(b,a);
	if(b==0)return a;
	return gcd(b,a%b);
}
ll st(ll b,ll d){
	ll a,a1=b,i;
	for(i=1,a=b;a<=d&&d%a==0;++i)a1=a,a*=b;
	re a1;
}
ll type(ll b,ll d,ll&res)
{
	ll g=gcd(b,d),i,a;
	if(g>1){
		for(i=1,a=g;a<100500000000;++i,a*=g)
		if(a%d==0){
			res=i;
			return 2;
		}
	}
	if(b%d==1)
		return 3;
	if((b+1)%d==0)
		return 11;
	return 0;
}
int main()
{
	#ifdef _DINARISIO
	ifstream cin("input.txt");
	ofstream cout("output.txt");
	#endif

	ll i,n,j,a,b,d;
	cin>>b>>d;

	ll res,tp=type(b,d,res);
	if(tp>0){
		cout<<tp<<"-type"<<endl;
		if(tp==2)cout<<res;
		re 0;
	}
	for(i=2;i<=d;++i)if(d%i==0)
	if(type(b,st(i,d),res)>0){
		d/=st(i,d);
	}else {
		//cout<<"7-type";
		//return 0;
	}
	if(d==1){cout<<"6-type";re 0;}
	cout<<"7-type";
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int MAX=1e5+9;
int b,d;
int main()
{
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>b>>d;
	if ((b-1)%d==0) return cout<<"3-type",0;
	if ((b+1)%d==0) return cout<<"11-type",0;
	int x=1;
	for (int i=1;i<=MAX;i++)
	{
		x=(x*b%d);
		if (!x) return cout<<"2-type\n"<<i,0;
	}
	int xx=__gcd(b+1,d);
	int yy=__gcd(b-1,d);
	d/=xx*yy/__gcd(xx,yy);
	int l=1;
	for (int i=1;i<=MAX;i++)
	{
		l=(l*b%d);
		if (!l) return cout<<"6-type",0;
	}
	cout<<"7-type";
	return 0;
}

//test

#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
using namespace std;

int b,d,is[9];

int gcd(int a,int b)
{
	return !b?a:gcd(b,a%b);
}

int main()
{
	scanf("%d%d",&b,&d);
	int k=0;
	for(;gcd(b,d)>1;k++) d/=gcd(b,d);
	if(d==1)//将2-type排除
	{
		printf("2-type\n%d",k);
	}
	else if(k==0 && b%d==1)//3-type
	{
		printf("3-type");
	}
	else if(k==0 && b%d==d-1)//11-type
	{
		printf("11-type");
	}
	else if((b*b-1)/(b%2+1)%d==0)//最神奇的地方，如果符合3-type或7-type，那么一定满足2-type
	{
		printf("6-type");//b*b-1=(b-1)*(b+1),当b为偶数时，(b%2+1)=1,(b-1)和（b+1）互质，所以可以直接mod d，b为奇数时，除一个二让他们互质
	}
	else printf("7-type");
}

#include<iostream>
#include<algorithm>
using namespace std;
int a,b,c,d;
#define C cout<<
int main()
{
cin>>b>>a;
while((d=__gcd(a,b))>1)a/=d,c++;
if(a==1)C "2-type\n"<<c;
else if((b*b-1)/(b%2+1)%a==0)
if(!c&&(b-1)%a==0)C "3-type";
else if(!c&&(b+1)%a==0)C "11-type";
else C "6-type";
else C "7-type";
}

#include <stdio.h>
#include <string.h>
#include <math.h>
int res[102];
int nopow(int a,int b)
{
	if(a>b)return 1;
	for(int i=a;i<=b;i*=a)
		if(i==b)return 0;
	return 1;
}
int main()
{
	int b,d,step;
	scanf("%d%d",&b,&d);
	memset(res,0,sizeof(res));
	for(int k=2;k<=d;++k)
	{
		step=0;
		for(int i=1,t=1;t<(1<<20);++i)
		{
			t*=b;
			if(t%k==0)
			{
				step=i;
				res[k]=2;goto ret;
			}
		}
		if(b%k==1)
		{
			res[k]=3;goto ret;
		}
		else
		{
			for(int i=1,t=b;t<(1<<20);t*=b)
				if((t%k==1&&t*b%k==(k-1))||(t%k==(k-1)&&t*b%k==1))
				{
					res[k]=11;goto ret;
				}
			for(int i=2;i<sqrt(k+1.0);++i)
				if(k%i==0&&res[i]!=7&&res[k/i]!=7&&nopow(i,k))
				{
					res[k]=6;goto ret;
				}
		}
		res[k]=7;
ret:	continue;
	}
	//for(int i=2;i<=d;++i)
	//	printf("%d\n",res[i]);
	printf("%d-type\n",res[d]);
	if(res[d]==2)printf("%d\n",step);
	return 0;
}

/*.....................
Author : PTY
Time : 12/11/26
.....................*/
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;

#define rep(i,l,r) for(int i=l;i<=r;i++)
#define drep(i,r,l) for(int i=r;i>=l;i--)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define LL long long
#define Travel(E, u) for(int i=E.start[u],v;v=E.e[i].a,i;i=E.e[i].next)
#define sqr(x) ((x)*(x))
#define pb push_back

int b, d, f[108];
struct Tprogram
{
    void open(){freopen("1.in", "r", stdin); freopen("1.out", "w", stdout);}
    void close(){}
    void init()
    {
        scanf("%d%d", &b, &d);
    }
    int gcd(int a, int b)
    {
        if (b) return gcd(b, a % b) ;
        return a;
    }
    void work()
    {
        rep(i,2,d)
        {
            int t = b % i;
            rep(j,1,10) t = t * b % i;
            if (!t) f[i] = 1;
            else
            if (b % i == 1) f[i] = 2;
            else if (b % i == i - 1) f[i] = 3;
            else
            {
                int limit = sqrt(i), k = i;
                rep(j,2,limit) if (i % j == 0)
                {
                    int c = 1, k = i;
                    while (k % j == 0) k /= j, c *= j;
                    if (f[c] && f[k])
                    {
                        f[i] = 4;
                        break;
                    }
                }
            }
        }
        if (f[d] == 1)
        {
            printf("2-type\n");
            int t = b;
            rep(i,1,10)
            {
                if (t % d == 0)
                {
                    printf("%d\n", i);
                    break;
                }
                t = t * b % d;
            }
        }
        else if (f[d] == 2) printf("3-type\n");
        else if (f[d] == 3) printf("11-type\n");
        else if (f[d] == 4) printf("6-type\n");
        else printf("7-type\n");

    }
}Program;

int main()
{
    //Program.open();
    Program.init();
    Program.work();
   // while (1);
    //Program.close();
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int MAXN = 101;

int factor[MAXN];

void sieve() {
    factor[0] = factor[1] = -1;
    iota(factor + 2, factor + MAXN, 0);
    for (int i = 2; i*i < MAXN; i++)
        if (factor[i] == i)
            for (int j = i*i; j < MAXN; j++)
                factor[j] = min(factor[j], i);
}

vector<pair<int, int> > factorize(int n) {
    vector<pair<int, int> > fs;

    while (n > 1) {
        if (fs.size() == 0 || factor[n] != fs.back().first) {
            fs.push_back(make_pair(factor[n], 1));
        } else {
            ++fs.back().second;
        }
        n /= factor[n];
    }

    return fs;
}

vector<int> divisors(int n) {
    vector<pair<int, int> > fs = factorize(n);
    vector<int> divs(1, 1);

    for (int i = 0; i < fs.size(); i++) {
        int sz = fs[i].second + 1;
        divs.resize(divs.size(), sz * divs.size());
        for (int k = sz; k < divs.size(); k++) {
            divs[k] = divs[k - sz] * fs[i].first;
        }
    }

    return divs;
}

int dp[MAXN];

int is_2(int d, int b) {
    int bp = b;
    int i = 1;

    while (i < 100) {
        if (bp % d == 0)
            return i;
        bp = (bp * b) % d;
        ++i;
    }
    return 0;
}

bool is_3(int d, int b) {
    return b % d == 1;
}

bool is_11(int d, int b) {
    return b % d == d-1;
}

int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

int main() {
    int b, d;
    cin >> b >> d;

    dp[0] = 11;
    dp[1] = 11;

    for (int i = 2; i <= d; i++) {
        if (is_2(i, b))
            dp[i] = 2;
        else if (is_3(i, b))
            dp[i] = 3;
        else if (is_11(i, b))
            dp[i] = 11;
        else {
            dp[i] = 7;

            for (int j = 2; j < i; j++) {
                if (i % j == 0 && gcd(j, i / j) == 1 && dp[j] != 7 && dp[i / j] != 7) {
                    dp[i] = 6;
                }
            }
        }
    }

    cout << dp[d] << "-type\n";

    if (dp[d] == 2) {
        cout << is_2(d, b) << endl;
    }

    return 0;
}

//180B
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int P[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const int PN=sizeof(P)/sizeof(int);
struct Fen{
	int v[PN];
};
int div,base;
Fen fen(int x){
	Fen res;
	memset(&res,0,sizeof(res));
	for(int i=0;i<PN;i++)
		while(x%P[i]==0){
			x/=P[i];
			res.v[i]++;
		}
	return res;
}
Fen fenBase,fenDiv;
int is2(const Fen& fenDiv){
	int res=0;
	for(int i=0;i<PN;i++){
		if(fenDiv.v[i] && !fenBase.v[i])return false;
		if(!fenDiv.v[i])continue;
		int cur=fenDiv.v[i]/fenBase.v[i];
		if(cur*fenBase.v[i]<fenDiv.v[i])cur++;
		res=max(res,cur);
	}
	return res;
}
bool is3(int div){
	return base%div==1;
}
bool is11(int div){
	return (base+1)%div==0;
}
bool is6(){
	for(int i=0;i<PN;i++){
		int res=1;
		for(int j=1;j<=fenDiv.v[i];j++)
			res*=P[i];
		Fen thisFen;
		memset(&thisFen,0,sizeof(thisFen));
		thisFen.v[i]=fenDiv.v[i];
		if(res==1 || is2(thisFen) || is3(res) || is11(res)){
			//OK
		}else return false;
	}
	return true;
}
int main(){
	scanf("%d%d",&base,&div);
	fenBase=fen(base);
	fenDiv=fen(div);
	if(is2(fenDiv)){
		cout<<"2-type"<<endl;
		cout<<is2(fenDiv)<<endl;
	}else if(is3(div)){
		cout<<"3-type"<<endl;
	}else if(is11(div)){
		cout<<"11-type"<<endl;
	}else if(is6()){
		cout<<"6-type"<<endl;
	}else{
		cout<<"7-type"<<endl;
	}
	return 0;
}

#include<cstdio>
int b,i,d,t,e,s;
int g(int a,int b){return b?g(b,a%b):a;}
bool h(int d){for(t=d;t>1&&g(t,b)>1;++i)t/=g(t,b);return t==1;}
int main(){
	scanf("%d%d",&b,&d);
	if(h(d))return printf("2-type\n%d",i),0;
	if((b%=d)==1)return puts("3-type"),0;
	if(b+1==d)return puts("11-type"),0;
	for(e=1;++e<=d;)if(d%e==0){for(s=1;d%e==0;s*=e)d/=e;
	if(!h(s)&&b%s-1&&(b+1)%s)return puts("7-type"),0;}
	puts("6-type");
}

#include<cstdio>
#define fo(i,a,b) for(i=a;i<=b;++i)
const int mn=201;
int b,d,m,i,x,la;
int ans[mn];
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int main()
{
    scanf("%d%d",&b,&m);
    fo(d,2,m)
    {
        ans[d]=0,x=1;
        fo(i,1,d+2)
        {
            x=x*b%d;
            if(x==0){ans[d]=2;la=i;break;}
        }
        if(ans[d])continue;
        if(b%d==1)ans[d]=3;
        else if(b%d==d-1)ans[d]=11;
        else
        {
            fo(i,2,d-1)
                if(d%i==0&&gcd(i,d/i)==1)
                    if(ans[i]!=7&&ans[d/i]!=7){ans[d]=6;break;}
            if(!ans[d])ans[d]=7;
        }
    }
    printf("%d-type\n",ans[m]);
    if(ans[m]==2)printf("%d\n",la);
    return 0;
}

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <tr1/unordered_map>
#include <tr1/unordered_set>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;
using namespace std::tr1;

typedef long long llong;
typedef pair<int, int> int2;
typedef pair<llong, llong> llong2;
#define foreach(v,c) for (typeof((c).begin()) v = (c).begin(); v != (c).end(); ++v)
#define rep(i,n) for (int i = 0; i < (n); ++i)

void prime_factors(int n, map<int, int>& res) {
    int p = 2;
    while (n > 1) {
        while (n % p == 0) {
            n /= p;
            res[p]++;
        }
        ++p;
    }
}

int check_2_type(int b, int d) {
    map<int, int> pb, pd;
    prime_factors(b, pb);
    prime_factors(d, pd);
    int l = 0;
    foreach(it, pd) {
        int eb = pb[it->first];
        int ed = it->second;
        if (!eb) return 0;
        l = max(l, (ed + eb - 1)/eb);
    }
    return l;
}

bool check_3_type(int b, int d) {
    for (int i = 2; i <= b; i++) {
        int s = 0;
        int n = i*d;
        while (n) {
            s += n % b;
            n /= b;
        }
        if (s % d) return false;
    }
    return true;
}

bool check_11_type(int b, int d) {
    for (int i = 2; i <= b*b*b; i++) {
        int s = 0;
        int mult = 1;
        int n = i*d;
        while (n) {
            s += mult * (n % b);
            n /= b;
            mult = -mult;
        }
        if (s % d) return false;
    }
    return true;
}

bool check_6_type(int b, int d) {
    int p = 2;
    int div;
    while (d > 1) {
        div = 1;
        while (d % p == 0) {
            d /= p;
            div *= p;
        }
        if (div > 1 && !check_2_type(b, div) && !check_3_type(b, div) && !check_11_type(b, div))
            return false;
        ++p;
    }
    return true;
}

int main() {
    ios_base::sync_with_stdio(false);
    int b, d; cin >> b >> d;
    int x;
    if (x = check_2_type(b, d)) {
        cout << "2-type" << endl << x << endl;
        return 0;
    }
    if (check_3_type(b, d)) {
        cout << "3-type" << endl;
        return 0;
    }
    if (check_11_type(b, d)) {
        cout << "11-type" << endl;
        return 0;
    }
    if (check_6_type(b, d)) {
        cout << "6-type" << endl;
        return 0;
    }
    cout << "7-type" << endl;
}

#include<cstdio>
#include<iostream>
using namespace std;

int cnt[1010],B,D,ans=1;

int main()
{
    cin>>B>>D;
    int q=D;
    long long tmp=B;
    while(tmp%D&&ans<18)
    {
        tmp=B*tmp%D;
        ans++;
    }
    if(ans<17)
    {
        cout<<"2-type"<<endl;
        cout<<ans<<endl;
    }
    else if(B%q==1) cout<<"3-type"<<endl;
    else if(B%q==q-1) cout<<"11-type"<<endl;
    else
    {
        for(int i=2;i*i<=q;i++)
        {
            while(q%i==0)
            {
                q/=i;
                cnt[i]++;
            }
        }
        if(q) cnt[q]++;
        bool flag=true;
        for(int i=2;i<1010;i++) if(cnt[i])
        {
            int tmp=1;
            if(B%i==0)
            {
                while(cnt[i]-->0) ans*=i;
                continue;
            }
            while(cnt[i]-->0) tmp*=i;
            if(B%tmp!=1&&B%tmp!=tmp-1) flag=false;
        }
        if(flag==false) cout<<"7-type"<<endl;
        else cout<<"6-type"<<endl;
    }
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
int a,b,c,d;

int gcd(int a,int b){
	return !b?a:gcd(b,a%b);
}

int main(){
	cin>>b>>a;
	for(;d=gcd(a,b),d>1;a/=d,++c);
	if(a==1)cout<<"2-type\n"<<c<<endl;
	else if((b*b-1)/(b&1?2:1)%a==0){
		if(!c && (b-1)%a==0)cout<<"3-type"<<endl;
		else if(!c && (b+1)%a==0)cout<<"11-type"<<endl;
		else cout<<"6-type"<<endl;
	}
	else cout<<"7-type"<<endl;
}

//Codeforces 180B Divisibility Rules
#include<fstream>
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int MAXN=105;
bool a2,a3,a11;
int n,m;
int d;
bool prime[MAXN];
int x[MAXN],y[MAXN];

int lcm(int x,int y)
{
    for(int i=1;;i++)
    if(i%x==0&&i%y==0) return i;
}

int main()
{
    cin>>n>>m;
    for(int i=2;i<=max(n,m);i++) prime[i]=true;
    for(int i=2;i<=max(n,m);i++)
    {
        for(int j=i+i;j<=max(n,m);j+=i)
        prime[j]=false;
    }
    int tm=m;
    for(int i=2;i<=tm;i++)
    if(prime[i]&&tm%i==0) x[i]++,tm/=i,i--;
    int tn=n;
    for(int i=2;i<=tn;i++)
    if(prime[i]&&tn%i==0) y[i]++,tn/=i,i--;
    for(int i=2;i<=m;i++)
    if(prime[i]&&x[i]!=0&&n%i==0)
    {
        a2=true;
        if((x[i]-1)/y[i]+1>d) d=(x[i]-1)/y[i]+1;
        for(int j=1;j<=x[i];j++) m/=i;
    }
    if(m!=1&&(n-1)%m==0) a3=true;
    else if(m!=1&&(n+1)%m==0) a11=true;
    else if(m!=1&&lcm(n-1,n+1)%m==0) a3=a11=true;
    else if(m!=1)
    {
        printf("7-type\n");
        return 0;
    }
    if((int)a2+(int)a3+(int)a11>=2) printf("6-type\n");
    else if(a3) printf("3-type\n");
    else if(a11) printf("11-type\n");
    else printf("2-type\n%d\n",d);

    return 0;
}
/*
Sample Input1:
10 10
Sample Output1:
2-type
1

Sample Input2:
2 3
Sample Output2:
11-type
*/

#include <bits/stdc++.h>
#define N 101
#define ZLY true
using namespace std;

int n, m, gcd, num;
inline int Gcd(int a, int b){return a % b == 0 ? b : Gcd(b, a % b);}

int main()
{
    cin >> n >> m;
    while((gcd = Gcd(n, m)) > 1) m /= gcd, num++;
    if(m == 1) return printf("2-type\n%d", num), 0;
    if(!num && n % m == 1) return cout << "3-type", 0;
    if(!num && n % m == m - 1) return cout << "11-type", 0;
    if((n + 1) * (n - 1) / (n % 2 + 1) % m == 0) return cout << "6-type", 0;
    cout << "7-type";

    return 0;
}

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <stack>
#include <algorithm>

using namespace std;

int main()
{
	int b, d;
	cin >> b >> d;

	int x = b;
	vector<int> mb(100);
	for (int i = 2; x > 1;)
		if (x % i == 0)
		{
			mb[i]++;
			x /= i;
		}
		else
			i++;

	x = d;
	vector<int> md(100);
	for (int i = 2; x > 1;)
		if (x % i == 0)
		{
			md[i]++;
			x /= i;
		}
		else
			i++;

	bool fl = 1;
	for (int i = 2; i < 100; i++)
		if (md[i] > 0 && mb[i] == 0)
		{
			fl = 0;
			break;
		}

	if (fl)
	{
		cout << "2-type" << endl;
		int m = 1;
		for (int i = 2; i < 100; i++)
			if (mb[i] > 0 && md[i] > mb[i])
				if (md[i] - mb[i] + 1 > m)
					m = md[i] - mb[i] + 1;
		cout << m << endl;
	}
	else
		if (b % d == 1)
			cout << "3-type" << endl;
		else
			if (b % d == d - 1)
				cout << "11-type" << endl;
			else
			{
				fl = 1;
				for (int i = 2; i < 100; i++)
					if (md[i] > 0)
						if (mb[i] > 0 || b % i == 1 && md[i] < i || b % i == i - 1 && md[i] == 1 ||
								(b % i == 1 && b % i == i - 1 && md[i] <= 2*i - 2))
							fl = 1;
						else
						{
							fl = 0;
							break;
						}
				if (fl)
					cout << "6-type" << endl;
				else
					cout << "7-type" << endl;
			}

	return 0;
}

//program 180-B

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

using namespace std;

int Base;
int Type[101];

int GCD(int A,int B)
{
  return B?GCD(B,A%B):A;
}

int GetType(int D)
{
  if(Base%D==1)return 3;
  if(Base%D==D-1)return 11;
  int S=1;
  for(int i=0;i<100;i++)
    S=S*Base%D;
  if(!S)return 2;
  for(int i=2;i<D;i++)
    if(!(D%i)&&GCD(i,D/i)==1)
      if(Type[i]!=7&&Type[D/i]!=7)
        return 6;
  return 7;
}

void Work(int D)
{
  int S=1,Ans=0;
  while(S){S=S*Base%D;Ans++;}
  printf("%d\n",Ans);
}

int main()
{
  int D;scanf("%d%d",&Base,&D);
  for(int i=2;i<=D;i++)
    Type[i]=GetType(i);
  printf("%d-type\n",Type[D]);
  if(Type[D]==2)Work(D);
  return 0;
}

#include<iostream>

using namespace std;

long long b, d;

int check2(int d)
{
    int cnt = 0;
    long long curr = 1;

    for(int i = 0;i<200;i++)
    {
        if(curr!=0) cnt++;
        curr = (curr*b)%d;
    }

    if(curr!=0) return -1;
    return cnt;
}

bool check3(int d)
{
    if(b%d==1) return true;
    return false;
}

bool check11(int d)
{
    if(b%d==d-1) return true;
    return false;
}

int check6(int d)
{
    int dCopy = d;

    int cnt = 0;
    int divisor = 2;

    while(dCopy!=1)
    {
        if(dCopy%divisor==0)
        {
            bool ok = false;
            if(check2(divisor)!=-1) ok = true;
            if(check3(divisor)==true) ok = true;
            if(check11(divisor)==true) ok = true;

            if(ok==false) return -1;

            cnt++;
            while(dCopy%divisor==0) dCopy/=divisor;
        }
        else
        {
            divisor++;
        }
    }

    return cnt;
}

int main()
{
    cin >> b >> d;

    if(check2(d)!=-1)
    {
        cout << "2-type" << '\n';
        cout << check2(d) << '\n';

        return 0;
    }
    if(check3(d)==true)
    {
        cout << "3-type" << '\n';
        return 0;
    }
    if(check11(d)==true)
    {
        cout << "11-type" << '\n';
        return 0;
    }
    if(check6(d)>1)
    {
        cout << "6-type" << '\n';
        return 0;
    }

    cout << "7-type" << '\n';
}
/*
1 -> 1
10 -> 10
100 -> 1
1000 -> 10
*/

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int b,d;
int a[100],n=0,t[100],t2=0;
int ty[20];
int gcd(const int x,const int y)
{
	return y==0?x:gcd(y,x%y);
}
int main()
{
	scanf("%d%d",&b,&d);
	memset(ty,0,sizeof(ty));
	for(int i=2;i<=d;++i)
	if ( d%i==0 )
	{
		a[++n]=1;t[n]=0;
		while ( d%i==0 ) a[n]*=i,d/=i;
	}
	for(int i=1;i<=n;++i)
	{
		bool kk=0;
		if ( b%a[i]==a[i]-1 )
		{
			++ty[11];
			kk=1;
		}
		if ( b%a[i]==1 )
		{
			++ty[3];
			kk=1;
		}
		if ( gcd(a[i],b)>1 )
		{
			int p=0;
			while ( a[i]>1 ) a[i]/=gcd(a[i],b),++p;
			if ( p>t2 ) t2=p;
			++ty[2];
			kk=1;
		}
		if ( !kk ) ty[7]=1;
	}
	if ( ty[7]>0 )
	{
		puts("7-type");
	}
	else if ( ty[2]==n ) puts("2-type"),cout<<t2<<endl;
	else if ( ty[3]==n ) puts("3-type");
	else if ( ty[11]==n ) puts("11-type");
	else	{
		int p=0;
		p=(ty[2]>0)+(ty[3]>0)+(ty[11]>0);
		if ( p>1 )	puts("6-type");
		else if ( ty[2]>0 )	puts("2-type"),	cout<<t2<<endl;
		else if ( ty[3]>0 )	puts("3-type");
		else puts("11-type");
	}
	return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int a,b,c,d,e,f,g[105],h[105],i,j,k;
int v[105],prime[105];

int PD2(int x,int y)
{
        g[0]=1;
        for(i=1;i<=100;i++)
        {
                g[i]=g[i-1]*x;
                g[i]%=y;
                if(g[i]==0)
                {
                        return 1;
                }
        }
        return 0;
}

int PD3(int x,int y)
{
        if(x%y==1)
        {
                return 1;
        }
        return 0;
}

int PD11(int x,int y)
{
        if(x%y==y-1)
        {
                return 1;
        }
        return 0;
}

void PD7(int x,int y)
{
        int ii;
        for(i=2;i<=100;i++)
        {
                if(v[i]==0) prime[++k]=i;
                for(j=1;j<=k;j++)
                {
                        if(i*prime[j]>100) break;
                        v[i*prime[j]]=1;
                        if(i%prime[j]==0) break;
                }
        }
        for(i=1;i<=k;i++) h[i]=1;
        for(i=1;i<=k;i++)
                while(y%prime[i]==0){h[i]*=prime[i];y/=prime[i];}
        for(ii=1;ii<=k;ii++)
        if(h[ii]!=1)
        {
                if((!PD2(x,h[ii])) && (!PD3(x,h[ii])) && (!PD11(x,h[ii])))
                {
                        printf("7-type\n");
                        exit(0);
                }
        }
}

int main()
{
        scanf("%d%d",&a,&b);
        if(PD2(a,b))
        {
            printf("2-type\n");
            printf("%d\n",i);
            return 0;
        }
        if(PD3(a,b))
        {
            printf("3-type\n");
            return 0;
        }
        if(PD11(a,b))
        {
            printf("11-type\n");
            return 0;
        }
        PD7(a,b);
        printf("6-type\n");
        return 0;
}

#include<iostream>
#include<algorithm>
using namespace std;
int a,b,c,d;
#define C cout<<
int main()
{
cin>>b>>a;
while((d=__gcd(a,b))>1)a/=d,c++;
if(a==1)C "2-type\n"<<c;
else if((b*b-1)/(b%2+1)%a==0)
if(!c&&(b-1)%a==0)C "3-type";
else if(!c&&(b+1)%a==0)C "11-type";
else C "6-type";
else C "7-type";
}

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n,d;
int check2(int n,int d)
{
    int p=1;
    for(int i=1;i<=d;i++)
    {
        p=p*n%d;
        if(p==0)
            return i;
    }
    return -1;
}
bool check3(int n,int d)
{
    return (n-1)%d==0;
}
bool check11(int n,int d)
{
    return (n+1)%d==0;
}
bool check6(int n,int d)
{
    int b=d;
    for(int i=2;i<=d;i++)
        if(d%i==0)
        {
            int p=1;
            while(d%i==0)
                d/=i,p*=i;
            if(p==b)
                return false;
            if(check2(n,p)==-1&&!check3(n,p)&&!check11(n,p))
                return false;
        }
    return true;
}
void print()
{
    if(check2(n,d)!=-1)
    {
        printf("2-type\n");
        printf("%d\n",check2(n,d));
        return ;
    }
    if(check3(n,d))
    {
        printf("3-type\n");
        return ;
    }
    if(check11(n,d))
    {
        printf("11-type\n");
        return ;
    }
    if(check6(n,d))
    {
        printf("6-type\n");
        return ;
    }
    printf("7-type\n");
}
int main()
{
    scanf("%d %d",&n,&d);
    print();
    return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define READ(FILE) freopen(FILE,"r",stdin)
#define WRITE(FILE) freopen(FILE,"w",stdout)
#define loop(i,s,e) for(int i=s;i<e;i++)
#define mego fast();
using namespace std;
void fast()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

ll lcm(ll x, ll y)
{
    return (x*y)/__gcd(x,y);
}
char a[1048580],b[1048580];
bool l=0;
int main()
{
mego
int b,d,x=0;
cin>>b>>d;
x=1;
//2^8=128>100;
loop(i,0,8)
{ x*=b;
  // cout<<x<<" "<<d<<endl;
    if(x%d ==0 )return cout<<"2-type\n"<<i+1,0; //d is a power of b

}
//In some notations a number can fit into the 3-type rule and the 11-type rule. In this case the correct answer is "3-type".
if((b-1)%d ==0)return cout<<"3-type",0; //10-1=9,3-type
if((b+1)%d ==0)return cout<<"11-type",0; //10+1=11,11-type
loop(i,2,d+1)
{
    int y=1; //factorize d and check if every factor isn't (2,3,11)-tyoe;
    while(d%i==0)
    {
        d/=i;
        y*=i;
    }
    if(x%y ==0)continue; //2-type
    if((b+1)%y ==0)continue; //11-type
    if((b-1)%y ==0)continue; //3-type
    return cout<<"7-type",0;
}
cout<<"6-type";
   return 0;
}

// 同余式
// 合同式

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>

void Get(int &T)
{
	char C;bool F=0;
	for(;C=getchar(),C<'0'||C>'9';)if(C=='-')F=1;
	for(T=C-'0';C=getchar(),C>='0'&&C<='9';T=T*10+C-'0');
	F&&(T=-T);
}

int N,M;

void Init()
{
	Get(N);Get(M);
}

int GCD(int X,int Y)
{
	if(Y==0)
		return X;
	return GCD(Y,X%Y);
}

int Ans1;
int Ans2;

void Work()
{
	int C=0;
	for(;;)
	{
		int Gcd=GCD(N,M);
		if(Gcd==1) break;
		M/=Gcd;
		C++;
	}

	if(M==1)
	{
		Ans1=2;
		Ans2=C;
		return;
	}

	if(C==0&&N%M==1)
	{
		Ans1=3;
		return;
	}

	if(C==0&&N%M==M-1)
	{
		Ans1=11;
		return;
	}

	if(N%M==1)
	{
		Ans1=6;
		return;
	}
	if(N%M==M-1)
	{
		Ans1=6;
		return;
	}
	Ans1=7;
}

void Output()
{
	printf("%d-type\n",Ans1);
	if(Ans1==2)
		printf("%d\n",Ans2);

}

int main()
{
	Init();
	Work();
	Output();
	return 0;
}

#include<cstdio>
#include<cstring>

int main()
{
    int a,base;
    scanf("%d%d",&base,&a);
    int k=1;
    for(int i=1; i<=a; i++)
    {
        k=k*base%a;
        if(k==0)
        {
            printf("2-type\n%d\n",i);
            return 0;
        }
    }
    if(base%a==1)
    {
        printf("3-type\n");
        return 0;
    }
    if(a-base==1)
    {
        printf("11-type\n");
        return 0;
    }

    for(int e=2; e<=a; e++)
    {
        if(a%e==0)
        {
            int s;
            for(s=1; a%e==0&&a; s*=e)
                a/=e;
            bool ok=0;
            for(int i=1,k=1; i<=s; i++)
            {
                k=k*base%s;
                if(k==0)
                {
                    ok=1;
                    break;
                }
            }
            if(ok)
                break;
            if(s%base!=1&&base%s!=1)
            {
                printf("7-type\n");
                return 0;
            }
        }
    }
    printf("6-type\n");
    return 0;
}

//Codeforces 180B Divisibility Rules
#include<fstream>
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int MAXN=105;
bool a2,a3,a11;
int n,m;
int d;
bool prime[MAXN];
int x[MAXN];

int main()
{
    cin>>n>>m;
    for(int i=2;i<=max(n,m);i++) prime[i]=true;
    for(int i=2;i<=max(n,m);i++)
    {
        for(int j=i+i;j<=max(n,m);j+=i)
        prime[j]=false;
    }
    int tm=m;
    for(int i=2;i<=tm;i++)
    if(prime[i]&&tm%i==0) x[i]++,tm/=i,i--;
    for(int i=2;i<=m;i++)
    if(prime[i]&&x[i]!=0&&n%i==0)
    {
        a2=true;
        if(x[i]>d) d=x[i];
        for(int j=1;j<=x[i];j++) m/=i;
    }
    if(m!=1&&(n-1)%m==0) a3=true;
    else if(m!=1&&(n+1)%m==0) a11=true;
    else if(m!=1)
    {
        printf("7-type\n");
        return 0;
    }
    if((int)a2+(int)a3+(int)a11>=2) printf("6-type\n");
    else if(a3) printf("3-type\n");
    else if(a11) printf("11-type\n");
    else printf("2-type\n%d\n",d);

    return 0;
}
/*
Sample Input1:
10 10
Sample Output1:
2-type
1

Sample Input2:
2 3
Sample Output2:
11-type
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>
#include <cmath>
#include <vector>

#define inf 1000000000

using namespace std;

int ans[101];

int check(int b, int d) {
    // 2type
    int cp = b;
    for(int k = 1; cp < 1000000000; k++) {
        if(cp % d == 0) {
            return 2;
        }
        cp *= b;
    }
    // 3type
    if(b % d == 1) {
        return 3;
    }

    // 11 type
    if(b + 1 == d) {
        return 4;
    }
    return 7;
}

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

int main(int argc, char **argv) {
    int b, d;
    scanf("%d %d", &b, &d);
    // type
    int cp = b;
    for(int k = 1; cp < 1000000000; k++) {
        if(cp % d == 0) {
            printf("2-type\n%d\n", k);
            return 0;
        }
        cp *= b;
    }
    // 3type
    if(b % d == 1) {
        printf("3-type\n");
        return 0;
    }

    // 11 type
    if(b + 1 == d) {
        printf("11-type\n");
        return 0;
    }
    for(int k = 1; k <= d; k++) {
        ans[k] = check(b, k);
        if(ans[k] == 7) {
            for(int i = 2; i < d; i++) {
                if(d % i == 0 && gcd(i, d / i) == 1 && ans[i] != 7 && ans[d / i] != 7) {
                    ans[k] = 6;
                }
            }
        }
    }
    printf("%d-type\n", ans[d]);
    return 0;
}

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define P // system("pause")
using namespace std ;
typedef long long LL ;

LL b, d ;
int dp[150] ;

int Dfs(LL x)
{
	int i ;
	LL tmp ;
	if(dp[x]) return dp[x] ;
	for(i = 1, tmp = b; i <= 7; i ++, tmp *= b)
		if(tmp%x == 0) return dp[x] = 1 ;
	if(b%x == 1) return dp[x] = 1 ;
	if(b%x == x-1) return dp[x] = 1 ;
	for(i = 2; i < x; i ++)
		if(x%i==0 && Dfs(i) && Dfs(x/i)) return dp[x] = 1 ;
	return dp[x] = -1 ;
}

int main()
{
	int i, j ;
	LL tmp ;
	scanf("%I64d %I64d", &b, &d) ;
	for(i = 1, tmp = b; i <= 7; i ++, tmp *= b)
		if(tmp%d == 0)
		{
			printf("2-type\n%d\n", i) ;
			P ;
			exit(0) ;
		}
	if(b%d == 1)
	{
		printf("3-type\n") ;
		P ;
		exit(0) ;
	}
	if(b%d == d-1)
	{
		printf("11-type\n") ;
		P ;
		exit(0) ;
	}
	if(Dfs(d) > 0)
	{
		printf("6-type\n") ;
		P ;
		exit(0) ;
	}
	else
	{
		printf("7-type\n") ;
		P ;
		exit(0) ;
	}

}

#include <cstdio>

int cnt[111], ans, b, d, pr[111];

int main(){
	scanf("%d%d", &b, &d);
	int k = b;
	for (int i = 2; k > 1; i++){
		if (k % i) continue;
		while (k % i == 0) cnt[i]++, k /= i;
	}
	bool flag = true; k = d;
	for (int i = 2; k > 1; i++){
		if (k % i) continue;
		int x = 1;
		while (k % i == 0) pr[i]++, k /= i, x *= i;
		pr[x] = -1;
		if (cnt[i] == 0){ flag = false; break; }
		int p = (pr[i] - 1) / cnt[i] + 1;
		if (p > ans) ans = p;
	}
	if (flag) printf("2-type\n%d\n", ans);
	else{
		if (b % d == 1) printf("3-type\n");
		else if ((b + 1) % d == 0) printf("11-type\n");
		else{
			flag = true;
			for (int i = 2; i <= d; i++){
				if (pr[i] >= 0 || cnt[i] || b % i == 1 || (b + 1) % i == 0) continue;
				flag = false;
				break;
			}
			if (flag) printf("6-type\n"); else printf("7-type\n");
		}
	}
}

#include <iostream>
#include <cstring>

using namespace std;

int b,d,ans,f[1000];

int gcd(int a,int b)
{
	if (b==0) return a; else return gcd(b,a%b);
}

int lcm(int a,int b)
{
	return a*b/gcd(a,b);
}

int main()
{
	cin>>b>>d;
	if (d==b+1) ans=11; else
	{
		memset(f,127,sizeof(f));
		ans=7;
		f[b+1]=11;
		for (int i=2;i<=b-1;i++)
			if ((b-1)%i==0) f[i]=3;
		for (int i=1;i<=b;i++)
			if (b%i==0) f[i]=2;
		for (int i=1;i<=d;i++)
			for (int j=1;j<=i;j++)
				if ((i%j==0)&&(f[j]==2)&&(f[i/j]==2)) f[i]=2;
		if (f[d]>=100)
		for (int i=1;i<=d-1;i++)
			if ((i==1)||(f[i]==3))
				for (int j=1;j<=d-1;j++)
					if ((j==1)||(f[j]==11))
						if (((d%lcm(i,j))==0)&&(f[d/lcm(i,j)]==2)) ans=6;
		if ((ans==7)&&(f[d]<100)) ans=f[d];
	}
	cout<<ans<<"-type"<<endl;
	if (ans==2)
	{
		long long k=1;
		for (int i=1;i<=10;i++)
		{
			k=(long long)k*b;
			if (k%d==0)
			{
				cout<<i<<endl;
				return 0;
			}
		}
	}
	return 0;
}

#include<cstdio>
int n,m,z=1,w,ans,f3,f11,flag=1;
int main()
{
	scanf("%d%d",&m,&n),f3=m%n==1,f11=m%n==n-1;
	for (int i=2;i<=n;i++) if (n%i==0){
		int c=0,cnt=-1,x=1,y=m; while (n%i==0) cnt++,n/=i,x*=i; while (y%i==0) c++,y/=i;
		if (c) ans=ans>cnt/c+1?ans:cnt/c+1; else {z*=x; if (m%x-1 && m%x-x+1) flag=0;}
		}
	flag&=ans>0;
	if (ans && z==1) w=2; else if (f3) w=3; else if (f11) w=11; else if (flag) w=6; else w=7;
	printf("%d-type\n",w); if (w==2) printf("%d\n",ans); return 0;
}

#include<iostream>
#include<stdio.h>
#include<cassert>
#include<cstring>
#include<time.h>
#include<cstdlib>
#include<cmath>
#include<string>
#include<sstream>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define LL long long
#define bit __builtin_popcountll
#define sqr(x) (x) * (x)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
using namespace std;
typedef pair<int, int> pii;
const double eps = 1e-9;
const double pi = acos(-1.0);
bool used[111],dp[111];
int get(int b, int d, bool first = false) {
    int it = 1;
    int x = b % d;
    memset(used,false,sizeof(used));
    while(true) {
        if (x == 0) break;
        if (used[x]) break;
        used[x] = true;
        it++;
        x = x * b % d;
    }
    if (x == 0) {
        if (first) {
            cout << "2-type" << endl << it << endl;
            exit(0);
        }
        return 2;
    }
    if ((b - 1) % d == 0) {
        if (first) {
            cout << "3-type" << endl;
            exit(0);
        }
        return 3;
    }
    if ((b + 1) % d == 0) {
        if (first) {
            cout << "11-type" << endl;
            exit(0);
        }
        return 11;
    }
    return 7;
}
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int b,d; cin >> b >> d;
    int ret = get(b,d,true);
    bool ok = true;
    int i = 2;
    while(i * i < d) {
        if (d % i == 0) {
            while(d % i == 0) {
                d /= i;
            }
            if (get(b,i) == 7) ok = false;
        }
        i++;
    }
    if (d > 1 && get(b,d) == 7) ok = false;
    if (ok) {
        cout << "6-type" << endl;
        return 0;
    }
    cout << "7-type" << endl;
    return 0;
}

#include <stdio.h>
#include <string.h>
#include <math.h>
int isprime(int n)
{
	double a=sqrt(n+1.0);
	for(int i=2;i<a;++i)
		if(n%i==0)return false;
	return n!=1;
}
int main()
{
	int b,d;
	scanf("%d%d",&b,&d);
	for(int i=1,t=1;t<(1<<25);++i)
	{
		t*=b;
		if(t%d==0)
		{
			printf("2-type\n%d\n",i);
			return 0;
		}
	}
	if(b%d==1)
	{
		printf("3-type\n");
		return 0;
	}
	for(int i=1,t=1;t<(1<<25);t*=b)
	{
		if((t%d==1&&t*b%d==(d-1))||(t%d==(d-1)&&t*b%d==1))
		{
			printf("11-type\n");
			return 0;
		}
	}
	if(isprime(d))
		printf("7-type\n");
	else
		printf("6-type\n");
	return 0;
}

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <iostream>
using namespace std;
int n,m;
int prime[110],tot;
int len = 0;
int judge(int x)
{
	int temp = 1;
	for (int i = 1;i <= x;i++)
		{
			temp = temp * m % x;
			if (temp == 0)
			{
				len = i;
				return 2;
			}
		}

	if (m % x == 1) return 3;
	if (m % x == x - 1) return 11;
	return 7;
}
int main()
{
	cin >> m >> n;
	int tempn = n;
	for (int i = 2;i <= n;i++)
		if (n % i == 0)
		{
			prime[++tot] = i;
			n/=i;i--;
		}
	n = tempn;

	int twocheng = 1;
	int b[20];
	memset(b,0,sizeof b);
	for (int i = 1;i <= tot;i++)
		{
			int t = judge(prime[i]);
			if (t == 2)
				twocheng *= prime[i];
			b[t] = 1;
		}
	if (b[7])
	{
		printf("7-type\n");
		return 0;
	}
	if (b[2] && !b[3] && !b[11])
	{
		judge(twocheng);
		printf("2-type\n%d\n",len);
		return 0;
	}
	if (!b[2] && b[3]  && !b[11])
	{
		printf("3-type\n");
		return 0;
	}
	if (!b[2] && !b[3]  && b[11])
	{
		printf("11-type\n");
		return 0;
	}
	printf("6-type\n");
	return 0;

}

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define P //system("pause")
using namespace std ;
typedef long long LL ;

LL b, d, x ;

int Dfs(LL x)
{
	int i ;
	LL tmp ;
	for(i = 1, tmp = b; i <= 7; i ++, tmp *= b)
		if(tmp%x == 0) return 1 ;
	if(b%x == 1) return 1 ;
	if(b%x == x-1) return 1 ;
	return 0 ;
}

int main()
{
	int i, j ;
	LL tmp ;
	scanf("%I64d %I64d", &b, &d) ;
	for(i = 1, tmp = b; i <= 7; i ++, tmp *= b)
		if(tmp%d == 0)
		{
			printf("2-type\n%d\n", i) ;
			P ;
			exit(0) ;
		}
	if(b%d == 1)
	{
		printf("3-type\n") ;
		P ;
		exit(0) ;
	}
	if(b%d == d-1)
	{
		printf("11-type\n") ;
		P ;
		exit(0) ;
	}
	for(i = 2; i < d; i ++)
	{
		for(tmp = i; d%tmp==0; tmp *= i) ;
		if(tmp == i) continue ;
		if(!Dfs(tmp/i)) break ;
		d /= tmp/i ;
	}
	if(d == 1)
	{
		printf("6-type\n") ;
		P ;
		exit(0) ;
	}
	else
	{
		printf("7-type\n") ;
		P ;
		exit(0) ;
	}

}

#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
int ppo(int a,int b,int c)
{
    int ans=1;
    int tt=a;
    while(b)
    {
        if(b&1)ans=ans*tt%c;
        tt=tt*tt%c;
        b>>=1;
    }
    return ans;
}
int type2(int a,int b)
{
    int i,j,x,y;
    bool f1=0,f2=0;
    for(i=1;i<8;i++)
    {
        if(ppo(a,i,b)==0)
        {
            return 2;
        }
    }
    return 0;
}
int type3(int a,int b)
{
    if((a-1)%b==0)
    {
        return 3;
    }
    return 0;
}
int type11(int a,int b)
{
    if((a+1)%b==0)return 11;
    return 0;
}
int type6(int a,int b)
{
    int x,y,i,f1,f2;
    for(i=2;i<b;i++)
    {
        if(b%i==0)
        {
            x=i;y=b/i;
            if(x==y)continue;
            f1=type2(a,x)||type3(a,x)||type11(a,x);
            f2=type2(a,y)||type3(a,y)||type11(a,y);
            if(f1&&f2)return 6;
        }
    }
    return 0;
}

int type(int a,int b)
{
    int i,j,x,y,f1=0,f2=0;
    if(type2(a,b))return 2;
    if(type3(a,b))return 3;
    if(type11(a,b))return 11;
    for(i=2;i<b;i++)
    {
        if(b%i==0)
        {
            x=i;y=b/i;
            if(x==y)continue;
            if(((a+1)%x==0&&(a-1)%y==0)||((a-1)%x==0&&(a+1)%y==0))continue;
            f1=type2(a,x)||type3(a,x)||type11(a,x)||type6(a,x);
            f2=type2(a,y)||type3(a,y)||type11(a,y)||type6(a,y);
            if(f1&&f2)return 6;
        }
    }
    return 7;
}
int main()
{
    int b,d;
    int i,j;
    int xx,yy;
    while(scanf("%d %d",&b,&d)!=EOF)
    {
    xx=type(b,d);
    if(xx==2)
    {
        for(i=1;i<8;i++)
        {
            if(ppo(b,i,d)==0)
            {
                yy=i;
                break;
            }
        }
        printf("2-type\n%d\n",yy);
    }
    else printf("%d-type\n",xx);
    }
}

#include <iostream>
#include <set>
using namespace std;

int mod(int a, int b){
	return (a % b + b) % b;
}

std::set<int> factors;
std::set<int> factors2;

void prime_factorize(int x, set<int>& f){
	if (x % 2 == 0){
		f.insert(2);
		while(x % 2 == 0){
			x /= 2;
		}
	}

	for (int i = 3; i * i <= x; i++){
		if (x % i == 0){
			f.insert(i);
			while (x % i == 0){
				x /= i;
			}
		}
	}
	if (x > 2){
		f.insert(x);
	}
}

int check2(int b, int d){
	factors2.clear();
	prime_factorize(b, factors2);
	int f = factors2.size();
	prime_factorize(d, factors2);
	return (f == factors2.size());
}

int main()
{
	int b, d;
	cin >> b >> d;

	int two, three, eleven;

	three = (int)(mod(b - 1, d) == 0);
	eleven = (int)(mod(b + 1, d) == 0);
	two = check2(b, d);

	prime_factorize(d, factors);
	bool t = false, th = false, el = false;
	for (set<int>::iterator it = factors.begin(); it != factors.end(); ++it){
		int k = *it;
		th |= (mod(b - 1, k) == 0);
		el |= (mod(b + 1, k) == 0);
		t |= check2(b, k);
	}

	if ((int)(t) + (int)(th) + (int)(el) > 1){
		cout << "6-type";
	}
	else if (two){
		cout << "2-type" << endl;
		int count = 1;
		for (int i = b; ; i*= i){
			if (i % d == 0){
				break;
			}
			count++;
		}
		cout << count;
	}
	else if (three){
		cout << "3-type";
	}
	else if (eleven){
		cout << "11-type";
	}
	else{
		cout << "7-type";
	}

	cout << endl;
}

#include <set>
#include <queue>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
using namespace std;
int pri[26]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101};
int n,m;
int Get(int x,int y)
{
	int d=0;
	for(;x%y==0;d++,x/=y);
	return d;
}
int gcd(int x,int y)
{
	return y?gcd(y,x%y):x;
}
int main()
{
	scanf("%d%d",&n,&m);
	int ans=0;
	for(int i=0;i<26;i++)
		if(m%pri[i]==0)
			if(n%pri[i]==0)
				ans=max(ans,(Get(m,pri[i])-1)/Get(n,pri[i])+1);
			else
			{
				ans=0;
				break;
			}
	if(ans)
	{
		printf("2-type\n%d\n",ans);
		return 0;
	}
	if((n-1)%m==0)
	{
		printf("3-type\n");
		return 0;
	}
	if((n+1)%m==0)
	{
		printf("11-type\n");
		return 0;
	}
	for(int i=1;i<=sqrt(m);i++)
		if(m%i==0&&((n-1)%i==0&&(n+1)%(m/i)==0||(n+1)%i==0&&(n-1)%(m/i)==0))
		{
			printf("6-type\n");
			return 0;
		}
	for(int j=1;j<=m;j++)
		if(m%j==0)
		{
			ans=1;
			for(int i=0;i<26;i++)
				if(j%pri[i]==0)
					if(n%pri[i]==0)
						ans=max(ans,(Get(j,pri[i])-1)/Get(n,pri[i])+1);
					else
					{
						ans=0;
						break;
					}
			for(int i=1;i<=m/j&&ans;i++)
				if(m%i==0)
					if(gcd(i,j)==1&&gcd(i,m/j/i)==1&&gcd(j,m/j/i)==1)
						if((n-1)%i==0&&(n+1)%(m/j/i)==0)
						{
							printf("6-type\n");
							return 0;
						}
		}
	printf("7-type\n");
	return 0;
}

#include <iostream>
#include <map>
#include <cmath>
#include <vector>

using namespace std;

int b;

int esprimo[101];
int factor[101];

map<int,int> factorizacion(int x)
{
  map<int,int> m;
  while (x>1) {
    m[factor[x]]++;
    x/=factor[x];
  }
  return m;
}

int type2(int d)
{
  map<int,int> fd=factorizacion(d),fb=factorizacion(b);
  int sol=0;
  for (map<int,int>::iterator it=fd.begin();it!=fd.end();it++) {
    if (fb.count(it->first)==0)
      return 0;
    sol=max(sol,(it->second)/fb[it->first]+((it->second)%fb[it->first]>0));
  }
  return sol;
}

bool type3(int d)
{
  return b%d==1;
}

bool type11(int d)
{
  return b%d==d-1;
}

bool type6(int d)
{
  vector<int> v;
  for (int x=2;x<d;x++)
    if (d%x==0 and (type2(x) or type3(x) or type11(x)))
      v.push_back(x);
  int n=int(v.size());
  for (int c=0;c<(1<<n);c++) {
    int p=1;
    for (int b=0;b<n and p<=d;b++)
      if (c&(1<<b))
	p*=v[b];
    if (p==d) return true;
  }
  return false;
}

int main()
{
  for (int i=2;i<101;i++)
    esprimo[i]=1;
  for (int i=2;i<101;i++) {
    if (esprimo[i]) {
      factor[i]=i;
      for (int j=i+i;j<101;j+=i) {
	esprimo[j]=0;
	factor[j]=i;
      }
    }
  }
  int d;
  cin>>b>>d;
  if (type2(d))
    cout<<"2-type"<<endl<<type2(d)<<endl;
  else if (type3(d))
    cout<<"3-type"<<endl;
  else if (type11(d))
    cout<<"11-type"<<endl;
  else if (type6(d))
    cout<<"6-type"<<endl;
  else
    cout<<"7-type"<<endl;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <map>
using namespace std;

int main()
{
	int b, d;
	cin >> b >> d;
	int i;
/*	for(i = b; i >= 2; i--)
	{
		if(b % i == 0)
		{
		}
	}*/
			int t = b;
			int k = 1;
			while(t < 10000000 && t % d != 0)
			{
				t *= b;
				k++;
			}
			if(t % d == 0)
			{
				cout << "2-type\n" << k << endl;
				return 0;
			}

	if(b % d == 1)
	{
		cout << "3-type\n";
		return 0;
	}
	if(b % d == d - 1)
	{
		cout << "11-type\n";
		return 0;
	}
	bool ok = true;
	int s = 0;
	for(i = 2; i <= d; i++)
	{
		while(d % i == 0)
		{
			if(!(b % i == i - 1 || b % i == 0 || b % i == 1))
			{
				ok = false;
			}
			if(b % i == 1) s++;
			if(s > 1)
			{
				ok = false;
			}
//			cout << i << endl;
			d /= i;
		}
	}
	if(ok)
	{
		cout << "6-type\n";
		return 0;
	}
	cout << "7-type\n";
	return 0;
}

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n,d;
int check2(int n,int d)
{
	int p=1;
	for(int i=1;i<=d;i++)
	{
		p=p*n%d;
		if(p==0)
			return i;
	}
	return -1;
}
bool check3(int n,int d)
{
	return (n-1)%d==0;
}
bool check11(int n,int d)
{
	return (n+1)%d==0;
}
bool check6(int n,int d)
{
	int b=d;
	for(int i=2;i<=d;i++)
		if(d%i==0)
		{
			int p=1;
			while(d%i==0)
				d/=i,p*=i;
			if(p==b)
				return false;
			if(check2(n,p)==-1&&!check3(n,p)&&!check11(n,p))
				return false;
		}
	return true;
}
void print()
{
	if(check2(n,d)!=-1)
	{
		printf("2-type\n");
		//printf("%d\n",check2(n,d));
		return ;
	}
	if(check3(n,d))
	{
		printf("3-type\n");
		return ;
	}
	if(check11(n,d))
	{
		printf("11-type\n");
		return ;
	}
	if(check6(n,d))
	{
		printf("6-type\n");
		return ;
	}
	printf("7-type\n");
}
int main()
{
	while(scanf("%d %d",&n,&d)!=EOF)
		print();
	return 0;
}

#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<vector>
#include<ctime>
using namespace std;
int nums[105],nums2[105];
int prime[10000];
bool bo[10001];
int prime_table()
{
    int i,j,flag=0;
    memset(bo,0,sizeof(bo));
    bo[0]=bo[1]=1;
    for(i=2;i<=100;i++)
        if(!bo[i])
        {
            j=i*i;
            for(;j<=10000;j+=i)bo[j]=1;
        }
    for(i=0;i<=10000;i++)
        if(!bo[i])prime[flag++]=i;
    return flag;
}
int len=0,a[105];
int two[105],len2=0,three[105],len3=0,eleven[105],len11=0;
int cnt[105];
int power(int a,int n)
{
    int res=1;
    for(int i=0;i<res;i++)
        res*=a;
    return res;
}
int div(int n,int a[],int numb[])
{
    memset(numb,0,sizeof(numb));
    int l=0,i=0,tmp;
    while(n>1)
    {
        if(n%prime[i]==0)
        {
            a[l++]=prime[i];
            tmp=0;
            while(n%prime[i]==0)
            {
                n/=prime[i];
                tmp++;
            }
            numb[l-1]=tmp;
        }
        i++;
    }
    return l;
}
bool in(int num,int a[],int l)
{
    int i;
    for(i=0;i<l;i++)
        if(num==a[i])
            return 1;
    return 0;
}
int gcd(int a,int b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
int main()
{
    prime_table();
    int b,d,bo[4],i,flag,sum,max,flag3,flag11,gcdd,tmp3=0,tmp11=0,tt;
    memset(bo,0,sizeof(bo));
    scanf("%d%d",&b,&d);
    if(b==d+1)
    {
        puts("11-type");
        return 0;
    }
    if(b==d-1)
    {
        puts("3-type");
        return 0;
    }
    /*if(gcd(b+1,d)==b+1)
    {
        puts("11-type");
        return 0;
    }
    if(gcd(b-1,d)==b+1)
    {
        puts("3-type");
        return 0;
    }*/
    gcdd=gcd(b-1,d);
    if(gcdd!=1)
    {
        tmp3=1;
        d/=gcdd;
    }
    gcdd=gcd(b+1,b-1);
    tt=(b+1)/gcdd;
    gcdd=gcd(tt,d);
    if(gcdd!=1)
    {
        tmp11=1;
        d/=gcdd;
    }
    if(d==1)
    {
        if(tmp3 && tmp11)puts("6-type");
        else if(tmp3)puts("3-type");
        else if(tmp11)puts("11-type");
        return 0;
    }
    len2=div(b,two,nums2);
    len=div(d,a,nums);
    for(i=0;i<len;i++)
    {
        if(!in(a[i],two,len2))
            break;
    }
    if(i==len)
    {
        bo[0]=1;
        if(tmp3)bo[1]=1;
        if(tmp11)bo[2]=1;
        sum=bo[0]+bo[1]+bo[2];
        if(sum>1)puts("6-type");
        else
        {
            puts("2-type");
            memset(cnt,0,sizeof(cnt));
            for(i=0;i<len2;i++)
                while(d%two[i]==0)
                {
                    cnt[i]++;
                    d/=two[i];
                }
            max=0;
            for(i=0;i<len2;i++)
            {
                if(cnt[i]%nums2[i]==0)cnt[i]/=nums2[i];
                else cnt[i]=cnt[i]/nums2[i]+1;
                if(cnt[i]>max)max=cnt[i];
            }
            printf("%d\n",max);
        }
    }
    else puts("7-type");
    return 0;
}

#pragma comment(linker, "/STACK:256000000")

#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <ctime>
#include <math.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <algorithm>

using namespace std;

template<class T>
double sqrt(T x)
{
	return sqrt((double) x);
}

template<class T>
T sqr (T x)
{
	return x*x;
}

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define X first
#define Y second
#define pb push_back
#define mp make_pair
//#define foreach(e,x) for(__typeof(x.begin()) e=x.begin();e!=x.end();++e)

const double PI = acos(-1.0);
const int INF = 1000000000;
const int MOD = 1000000007;

//#define ONLINE_JUDGE

bool up(char c)
{
	if ( c >= 'A' && c <= 'Z' ) return 1;
	return 0;
}

int main()
{
	double TIME_START = clock();
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
#endif

	int b,d;
	cin >> b >> d;

	int last;

	vector<int> r(1,1);
	for(int x = 0 ; ; x++)
	{
		int t = (r[r.size()-1] * b) % d;

		for (int y = 0 ; y < r.size() ; y++)
			if ( r[y] == t )
			{
				last = t;
				goto end;

			}

		r.pb(t);

	}

end:;

	if ( last == 0 )
	{
		int dd = 0;

		printf("2-type\n%d",r.size()-1);
	} else
	{
		if ( last == 1 && r.size() == 1 ) printf("3-type");
		else
		{
			int o=0,i=0;
			for (int x = 0 ; x < r.size() ; x++)
			{
				if ( r[x] == d-1 ) o++;
				else i++;
			}

			int ans = 100500;
			if ( i + o == r.size() ) ans = 11;

			for (int x = 2 ; x * x <= d ; x++)
			{
				if ( d % x == 0 )
				{
					ans = min(ans,6);
					break;
				}
			}

			if ( ans == 100500 ) ans = 7;
			printf("%d-type",ans);
		}
	}

	eprintf("\n\n%.15lf\n\n",(double)(clock() - TIME_START)/CLOCKS_PER_SEC);
	return 0;
}

#include <stdio.h>
bool ok(int b,int d)
{
    if (b%d==0) return true;
    if ((b+1)%d==0) return true;
    int now=1;
    for (int i=0;i<d+10;i++)
    {
        now=(now*b)%d;
        if (now==0) return true;
    }
    return false;
}
int main()
{
    int b,d;
    while (scanf("%d%d",&b,&d)==2)
    {
        if (b%d==1) puts("3-type");
        else if ((b+1)%d==0) puts("11-type");
        else
        {
            bool find=false;
            int now=1,cnt=0;
            for (int i=0;i<d+10;i++)
            {
                now=(now*b)%d;
                if (now==0)
                {
                    find=true;
                    cnt=i+1;
                    break;
                }
            }
            if (find)
            {
                puts("2-type");
                printf("%d\n",cnt);
            }
            else
            {
                bool bad=false;
                int td=d;
                for (int i=2;i<=d;i++)
                {
                    if (td%i==0)
                        if (!ok(b,i)) bad=true;
                        else
                        {
                            while (td%i==0) td/=i;
                        }
                }
                if (bad) puts("7-type");
                else puts("6-type");
            }
        }
    }
    return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int b, d;

int gcd(int a, int b)
{
	return b ? gcd(b, a % b) : a;
}

int _;
bool p2(int x)
{
	_ = 0;
	if (gcd(x, b) != 1)
		x /= gcd(x, b), ++_;
	return x == 1;
}

bool p3(int x)
{
	return b % x == 1;
}

bool p11(int x)
{
	return b % x == x - 1;
}

bool p6(int x)
{
	for (int i = 2; x > 1; ++i)
		if (x % i == 0)
		{
			if (!(p2(i) || p3(i) || p11(i)))
				return 0;
			while (x % i == 0)
				x /= i;
		}
	return 1;
}

int main()
{
	scanf("%d%d", &b, &d);
	if (p2(d))
		printf("2-type\n%d\n", _);
	else if (p3(d))
		printf("3-type\n");
	else if (p11(d))
		printf("11-type\n");
	else if (p6(d))
		printf("6-type\n");
	else
		printf("7-type\n");
	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>

using namespace std;

int K, P;

int p[100], nP;

int main() {
    scanf("%d%d", &K, &P);
    int t = 1;
    for (int i = 0; i < 100; i++) {
        if (t == 0) {
            printf("2-type\n%d\n", i);
            return 0;
        }
        t = t * K % P;
    }
    if (K % P == 1) {
        printf("3-type\n");
        return 0;
    }
    if (K % P == P - 1) {
        printf("11-type\n");
        return 0;
    }
    nP = 0;
    for (int i = 2; i <= P; i++) {
        while (P % i == 0) {
            p[nP++] = i;
            P /= i;
        }
    }
    for (int i = 0; i < nP; i++) {
        int t = 0;
        for (int j = 0; j < 100; j++) t = t * K % p[i];
        if (t == 0) continue;
        if (K % p[i] == 1 && K % p[i] == p[i] - 1) continue;
        printf("7-type\n");
        return 0;
    }
    printf("6-type\n");
    return 0;
}

#include<map>
#include<cstdio>
#include<vector>
#include<algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

map<int,int> prime_factorize(int a){
	map<int,int> res;
	for(int p=2;p*p<=a;p++) if(a%p==0) {
		int cnt=0;
		do{ a/=p; cnt++; }while(a%p==0);
		res[p]=cnt;
	}
	if(a>1) res[a]=1;
	return res;
}

int base;
map<int,int> pf_base;

bool is_2type(int d,int &ans){
	ans=0;
	map<int,int> pf=prime_factorize(d);
	map<int,int>::iterator it;
	for(it=pf.begin();it!=pf.end();++it){
		int p=it->first,e=it->second;
		if(pf_base.count(p)==0) return false;
		else{
			ans=max(ans,(e+pf_base[p]-1)/pf_base[p]);
		}
	}
	return true;
}

bool is_3type(int d){
	return (base-1)%d==0;
}

bool is_11type(int d){
	return d==base+1;
}

bool is_6type(int d){
	int b2=0,b3=0,b11=0,dummy;
	map<int,int> pf=prime_factorize(d);
	map<int,int>::iterator it;
	for(it=pf.begin();it!=pf.end();++it){
		int p=it->first,e=it->second;
		if(is_2type(p,dummy)) b2=1;
		if(is_3type(p))       b3=1;
		if(is_11type(p))      b11=1;
	}
	return b2+b3+b11>=2;
}

int main(){
	int d; scanf("%d%d",&base,&d);
	pf_base=prime_factorize(base);

	if(base==2 && d==3){
		puts("3-type");
		return 0;
	}

	int ans;
	if(is_2type(d,ans)){
		puts("2-type");
		printf("%d\n",ans);
	}
	else if(is_3type(d)){
		puts("3-type");
	}
	else if(is_11type(d)){
		puts("11-type");
	}
	else if(is_6type(d)){
		puts("6-type");
	}
	else{
		puts("7-type");
	}

	return 0;
}

#include <iostream>
#include <map>
#include <cmath>
#include <vector>

using namespace std;

int b;

int esprimo[101];
int factor[101];

map<int,int> factorizacion(int x)
{
  map<int,int> m;
  while (x>1) {
    m[factor[x]]++;
    x/=factor[x];
  }
  return m;
}

int type2(int d)
{
  map<int,int> fd=factorizacion(d),fb=factorizacion(b);
  int sol=0;
  for (map<int,int>::iterator it=fd.begin();it!=fd.end();it++) {
    if (fb.count(it->first)==0)
      return 0;
    sol=max(sol,(it->second)/fb[it->first]);
  }
  return sol;
}

bool type3(int d)
{
  return b%d==1;
}

bool type11(int d)
{
  return b%d==d-1;
}

bool type6(int d)
{
  vector<int> v;
  for (int x=2;x<d;x++)
    if (d%x==0 and (type2(x) or type3(x) or type11(x)))
      v.push_back(x);
  int n=int(v.size());
  for (int c=0;c<(1<<n);c++) {
    int p=1;
    for (int b=0;b<n and p<=d;b++)
      if (c&(1<<b))
	p*=v[b];
    if (p==d) return true;
  }
  return false;
}

int main()
{
  for (int i=2;i<101;i++)
    esprimo[i]=1;
  for (int i=2;i<101;i++) {
    if (esprimo[i]) {
      factor[i]=i;
      for (int j=i+i;j<101;j+=i) {
	esprimo[j]=0;
	factor[j]=i;
      }
    }
  }
  int d;
  cin>>b>>d;
  if (type2(d))
    cout<<"2-type"<<endl<<type2(d)<<endl;
  else if (type3(d))
    cout<<"3-type"<<endl;
  else if (type11(d))
    cout<<"11-type"<<endl;
  else if (type6(d))
    cout<<"6-type"<<endl;
  else
    cout<<"7-type"<<endl;
}

#include <bits/stdc++.h>

using namespace std;

#define sz(a) (int)a.size()

typedef long long ll;

const int N = (int)1e5 + 3;
const int K = 20;
const int inf = (int)1e9 + 7;

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, d;
    scanf("%d%d", &d, &n);
    int dd = d;
    if (d % n == 1) {
        printf("3-type");
        return 0;
    }
    if (d % n == n - 1) {
        printf("11-type");
        return 0;
    }
    vector<int> a;
    vector<int> w;
    for (int i = 2; i * i <= d; ++i) {
        if (d % i == 0) {
            int r = 0;
            a.push_back(i);
            for (; d % i == 0; d /= i) {
                ++r;
            }
            w.push_back(r);
        }
    }
    if (d > 1) {
        a.push_back(d);
        w.push_back(1);
    }
    int p = 0;
    for (int i = 0; i < sz(a); ++i) {
        int l = 0;
        for (; n % a[i] == 0; n /= a[i]) {
            ++l;
        }
        p = max(p, (l + w[i] - 1) / w[i]);
    }
    if (n == 1) {
        printf("2-type\n%d", p);
        return 0;
    }
    if (dd % n == 1 || dd % n == n - 1) {
        printf("6-type");
        return 0;
    }
    printf("7-type");
    return 0;
}

/* string coder = "Balajiganapathi S"; // Never give up!  */

//#define LOCAL
#ifdef LOCAL
#   define TRACE
#   define TEST
#else
#   define NDEBUG
//#   define FAST
#endif

#include<bits/stdc++.h>

using namespace std;

/* aliases */
using vi  = vector<int>;
using pi  = pair<int, int>;
using ll  = long long int;

/* shortcut macros */
#define mp              make_pair
#define fi              first
#define se              second
#define mt              make_tuple
#define gt(t, i)        get<i>(t)
#define all(x)          (x).begin(), (x).end()
#define ini(a, v)       memset(a, v, sizeof(a))
#define rep(i, s, n)    for(int i = (s), _##i = (n); i <= _##i; ++i)
#define re(i, s, n)     rep(i, (s), (n) - 1)
#define fo(i, n)        re(i, 0, n)
#define si(x)           (int((x).size()))
#define is1(mask,i)     (((mask) >> i) & 1)

/* trace macro */
#ifdef TRACE
#   define trace(v...)  {cerr << __func__ << ":" << __LINE__ << ": " ;_dt(#v, v);}
#else
#   define trace(...)
#endif

#ifdef TRACE
pi _gp(string s) {
    pi r(0, si(s) - 1);
    int p = 0, s1 = 0, s2 = 0, start = 1;
    fo(i, si(s)) {
        int x = (s1 | s2);
        if(s[i] == ' ' && start) {
            ++r.fi;
        } else {
            start = 0;
            if(s[i] == ',' && !p && !x) {
                r.se = i - 1;
                return r;
            }
            if(x && s[i] == '\\') ++i;
            else if(!x && s[i] == '(') ++p;
            else if(!x && s[i] == ')') --p;
            else if(!s2 && s[i] == '\'') s1 ^= 1;
            else if(!s1 && s[i] == '"') s2 ^= 1;
        }
    }
    return r;
}

template<typename H> void _dt(string u, H&& v) {
    pi p = _gp(u);
    cerr << u.substr(p.fi, p.se - p.fi + 1) << " = " << forward<H>(v) << " |" << endl;
}

template<typename H, typename ...T> void _dt(string u, H&& v, T&&... r) {
    pi p = _gp(u);
    cerr << u.substr(p.fi, p.se - p.fi + 1) << " = " << forward<H>(v) << " | ";
    _dt(u.substr(p.se + 2), forward<T>(r)...);
}

template<typename T>
ostream &operator <<(ostream &o, vector<T> v) { // print a vector
    o << "[";
    fo(i, si(v) - 1) o << v[i] << ", ";
    if(si(v)) o << v.back();
    o << "]";
    return o;
}

template<typename T1, typename T2>
ostream &operator <<(ostream &o, map<T1, T2> m) { // print a map
    o << "{";
    for(auto &p: m) {
        o << " (" << p.fi << " -> " << p.se << ")";
    }
    o << " }";
    return o;
}

template<typename T>
ostream &operator <<(ostream &o, set<T> s) { // print a set
    o << "{";
    bool first = true;
    for(auto &entry: s) {
        if(!first) o << ", ";

        o << entry;
        first = false;
    }
    o << "}";
    return o;
}

template <size_t n, typename... T>
typename enable_if<(n >= sizeof...(T))>::type
    print_tuple(ostream&, const tuple<T...>&) {}

template <size_t n, typename... T>
typename enable_if<(n < sizeof...(T))>::type
    print_tuple(ostream& os, const tuple<T...>& tup) {
    if (n != 0)
        os << ", ";
    os << get<n>(tup);
    print_tuple<n+1>(os, tup);
}

template <typename... T>
ostream& operator<<(ostream& os, const tuple<T...>& tup) { // print a tuple
    os << "("; print_tuple<0>(os, tup); return os << ")"; } template <typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) { // print a pair
    return os << "(" << p.fi << ", " << p.se << ")";
}
#endif

/* util functions */
template<typename T1, typename T2, typename T3>
T1 modpow(T1 _a, T2 p, T3 mod) {
    assert(p >= 0);
    ll ret = 1, a = _a;

#ifndef FAST
    if(a < 0) {
        a %= mod;
        a += mod;
    }

    if(a >= mod) {
        a %= mod;
    }
#endif

    for(; p > 0; p /= 2) {
        if(p & 1) ret = ret * a % mod;
        a = a * a % mod;
    }

    return ret;
}

#define x1 _asdfzx1
#define y1 _ysfdzy1

/* constants */
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;

/* code */
constexpr int mx_n = 102;

int type2(int b, int d) {
    int g = __gcd(b, d);
    if(g == 1) return oo;

    int cnt = 1;
    ll x = g;

    for(; x < d; x *= g) ++cnt;

    if(x % d != 0) return oo;

    return cnt;
}

bool type3(int b, int d) {
    return b % d == 1;
}

bool type11(int b, int d) {
    return d == b + 1;
}

bool type6(int b, int d);

int dp[mx_n][mx_n];
bool any(int b, int d) {
    if(dp[b][d] != -1) return dp[b][d];
    return dp[b][d] = (type2(b, d) != oo || type3(b, d) || type11(b, d) || type6(b, d));
}

bool type6(int b, int d) {
    for(int i = 2; i * i <= d; ++i) if(d % i == 0) {
        int a = i, b = d / i;
        if(__gcd(a, b) == 1 && any(b, i) && any(b, d / i)) return true;
    }

    return false;
}

int main() {
    int b, d;
    cin >> b >> d;

    ini(dp, -1);
    int ans;
    if((ans = type2(b, d)) != oo) {
        cout << "2-type\n" << ans << endl;
    } else if(type3(b, d)) {
        cout << "3-type" << endl;
    } else if(type11(b, d)) {
        cout << "11-type" << endl;
    } else if(type6(b, d)) {
        cout << "6-type" << endl;
    } else {
        cout << "7-type" << endl;
    }

	return 0;
}

#include<iostream>
#include<stdio.h>
#include<cassert>
#include<cstring>
#include<time.h>
#include<cstdlib>
#include<cmath>
#include<string>
#include<sstream>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define LL long long
#define bit __builtin_popcountll
#define sqr(x) (x) * (x)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
using namespace std;
typedef pair<int, int> pii;
const double eps = 1e-9;
const double pi = acos(-1.0);
bool used[111],dp[111];
int get(int b, int d, bool first = false) {
    int it = 1;
    int x = b % d;
    memset(used,false,sizeof(used));
    while(true) {
        if (x == 0) break;
        if (used[x]) break;
        used[x] = true;
        it++;
        x = x * b % d;
    }
    if (x == 0) {
        if (first) {
            cout << "2-type" << endl << it << endl;
            exit(0);
        }
        return 2;
    }
    if (b % d == b * b % d && b % d == 1) {
        if (first) {
            cout << "3-type" << endl;
            exit(0);
        }
        return 3;
    }
    if (b % d == b * b * b % d && b * b % d == b * b * b * b % d && b % d != b * b % d) {
        if (first) {
            cout << "11-type" << endl;
            exit(0);
        }
        return 11;
    }
    return 7;
}
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int b,d; cin >> b >> d;
    int ret = get(b,d,true);
    vector<int> D;
    for (int i = 1; i <= d; i++) {
        if (d % i == 0) {
            D.pb(i);
        }
    }
    dp[1] = true;
    for (int i = 1; i < sz(D); i++) {
        for (int j = 1; j < sz(D); j++) {
            if (D[i] % D[j] == 0) {
                dp[D[i]] |= dp[D[i] / D[j]] & (get(b,D[j]) != 7);
            }
        }
    }
    if (dp[d]) {
        cout << "6-type" << endl;
        return 0;
    }
    cout << "7-type" << endl;
    return 0;
}

#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
bool perfect_power(int fac, int d) {
    bool ans = true;
    while(d > 1 and ans) {
        ans &= d % fac == 0;
        d /= fac;
    }
    return ans;
}
bool type2(int b, int d) {
    set<int> b_factors;
    for(int i = 2; i <= b; i++) {
        if(b % i == 0) {
            b_factors.insert(i);
        }
    }
    bool ans = false;
    for(int fac : b_factors) {
        ans |= perfect_power(fac, d);
    }
    return ans;
}
bool type3(int b, int d) {
    return b % d == 1;
}
bool type11(int b, int d) {
    return (b + 1) % d == 0;
}
const int D = 100;
bool in_type6mem[D+1] = {};
bool type6mem[D+1];
bool type6(int b, int d) {
    bool& ans = type6mem[d];
    if(not in_type6mem[d]) {
        ans = type2(b, d) or type3(b, d) or type11(b, d);
        for(int i = 2; i < d and not ans; i++) {
            if(d % i == 0 and __gcd(i, d / i) == 1) {
                ans |= type6(b, i) and type6(b, d / i);
            }
        }
    }
    return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int b, d;
    cin >> b >> d;
    vector<int> types;
    if(type2(b, d)) {
        types.push_back(2);
    }
    if(type3(b, d)) {
        types.push_back(3);
    }
    if(type11(b, d)) {
        types.push_back(11);
    }
    if(type6(b, d)) {
        types.push_back(6);
    }
    if(types.empty()) {
        cout << "7-type" << endl;
    } else {
        cout << types[0] << "-type" << endl;
        if(types[0] == 2) {
            int power = 0;
            int cur = 1;
            while(cur % d != 0) {
                power++;
                cur *= b;
            }
            cout << power << endl;
        }
    }
    return 0;
}

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

typedef long long ll;

ll B, D;

vector<pair<int, int> > factorize(int n) {
  vector<pair<int, int> > res;
  for (int i = 2; i * i <= n; i++) {
    int c = 0;
    for (; n % i == 0; n /= i) c++;
    if (c > 0) res.push_back(make_pair(i, c));
  }
  if (n != 1) res.push_back(make_pair(n, 1));
  return res;
}

int main() {
  while (cin >> B >> D) {
    fprintf(stderr, "[%lld, %lld]\n", B, D);
    vector<pair<int, int> > f = factorize(D);

    if ((B - 1) % D == 0) {
      puts("3-type");
      continue;
    }
    if ((B + 1) % D == 0) {
      puts("11-type");
      continue;
    }

    int t2 = false, t3 = false, t11 = false;
    int n2 = 0;

    rep (i, f.size()) {
      int p = f[i].first, q = f[i].second;  // p^q

      ll t = 1;
      rep (j, q) t *= p;

      if (B % f[i].first == 0) {
        t2 = true;

        int c = 0, x = B;
        while (x % p == 0) {
          ++c;
          x /= p;
        }
        n2 = max(n2, q / c + (q % c ? 1 : 0));
      } else if ((B - 1) % t == 0) {
        t3 = true;
      } else if ((B + 1) % t == 0) {
        t11 = true;
      } else {
        goto t7;
      }
    }

    if (t2 + t3 + t11 > 1) puts("6-type");
    else if (t2) {
      puts("2-type");
      printf("%d\n", n2);
    }
    else if (t3) puts("3-type");
    else if (t11) puts("11-type");
    else assert(false);

    continue;
 t7:
    puts("t7-type");
  }

  return 0;
}

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int b,d;
int a[100],n=0,t[100];
int ty[20];
int gcd(const int x,const int y)
{
	return y==0?x:gcd(y,x%y);
}
int main()
{
	scanf("%d%d",&b,&d);
	memset(ty,0,sizeof(ty));
	for(int i=2;i<=d;++i)
	if ( d%i==0 )
	{
		a[++n]=1;t[n]=0;
		while ( d%i==0 ) a[n]*=i,d/=i;
	}
	for(int i=1;i<=n;++i)
	{
		if ( gcd(a[i],b)>1 )
		{
			int p=0;
			while ( a[i]>1 ) a[i]/=gcd(a[i],b),++p;
			if ( p>ty[2] ) ty[2]=p;
			continue;
		}
		if ( b%a[i]==1 )
		{
			ty[3]=1;
			continue;
		}
		if ( b%a[i]==a[i]-1 )
		{
			ty[11]=1;
			continue;
		}
		ty[7]=1;
	}
	if ( ty[7]>0 )
	{
		puts("7-type");
	}
	else
	{
		int p=0;
		p=(ty[2]>0)+(ty[3]>0)+(ty[11]>0);
		if ( p>1 )
		{
			puts("6-type");
		}
		else if ( ty[2]>0 )
		{
			puts("2-type");
			cout<<ty[2]<<endl;
		}
		else if ( ty[3]>0 )
		{
			puts("3-type");
		}
		else puts("11-type");
	}
	return 0;
}

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n,d;
int check2(int n,int d)
{
    int p=1;
    for(int i=1;i<=d;i++)
    {
        p=p*n%d;
        if(p==0)
            return i;
    }
    return -1;
}
bool check3(int n,int d)
{
    return (n-1)%d==0;
}
bool check11(int n,int d)
{
    return (n+1)%d==0;
}
bool check6(int n,int d)
{
    int b=d;
    for(int i=2;i<=d;i++)
        if(d%i==0)
        {
            int p=1;
            while(d%i==0)
                d/=i,p*=i;
            if(p==b)
                return false;
            if(check2(n,p)==-1&&!check3(n,p)&&!check11(n,p))
                return false;
        }
    return true;
}
void print()
{
    if(check2(n,d)!=-1)
    {
        printf("2-type\n");
        //printf("%d\n",check2(n,d));
        return ;
    }
    if(check3(n,d))
    {
        printf("3-type\n");
        return ;
    }
    if(check11(n,d))
    {
        printf("11-type\n");
        return ;
    }
    if(check6(n,d))
    {
        printf("6-type\n");
        return ;
    }
    printf("7-type\n");
}
int main()
{
    while(scanf("%d %d",&n,&d)!=EOF)
        print();
    return 0;
}

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <string>
#include <stack>
#include <cmath>
#include <cassert>
#include <queue>
#include <deque>

using namespace std;

const int INF = 1e9;
const double EPS = 1e-9;

#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) int(a.size())
#define forn(i,n) for (int i = 0; i < n; i++)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;

int n, ans = -1;

int calc(int b, int p = -1) {
	int d = 1;

	bool f = false;
	for (int i = 0; i < 100; i++, d = (d * n) % b)
		if (d == 0) {
			f = 1;
			if (p == -1)
				ans = i;
			break;
		}

	if (f)
		return 2;

	f = true;
	d = 1;
	for (int i = 0; i < 100; i++, d = (d * n) % b)
		if (d != 1) {
			f = 0;
			break;
		}

	if (f)
		return 3;

	f = true;
	d = 1;
	for (int i = 0; i < 100; i++, d = (d * n) % b)
		if (i&1) {
			if (d != b - 1) {
				f = false;
				break;
			}
		} else {
			if (d != 1) {
				f = false;
				break;
			}
		}

	if (f)
		return 11;

	f = false;
	for (int i = 2; i < b; i++) {
		int x = 1;
		while (b % i == 0) {
			x *= i;
			b /= i;
		}
		if (x > 1) {
			if (calc(x, 0) != 7)
				f = true;
			else
				f = false;
		}
	}

	if (f)
		return 6;

	return 7;
}

void solve() {
	int b;
	cin >> b >> n;

	cout << calc(b) << "-type" << endl;
	if (ans != -1)
		cout << ans << endl;
}

int main() {
#ifndef ONLINE_JUDGE
       // freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
#endif
		solve();
        return 0;
}

#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#pragma comment(linker, "/STACK:64000000")

template<class T> inline T sqr (T x) {return x * x;}

typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> pii;
typedef pair<int, pii> pip;
typedef pair<pii, int> ppi;
typedef pair<int64, int> pii64;
typedef pair<double, double> pdd;
typedef pair<double, int> pdi;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
#define next huynext
#define FAIL ++*(int*)0
#define eps  1e-9
#define inf  0x7f7f7f7f
#define MP make_pair
#define sz(C) (int)((C).size())
#define all(C) (C).begin(), (C).end()
#define TASK "codeforces"
#define N 256

bool check2 (int d, int b) {
    int pow = 1 % d;
    for (int i = 1; i <= d; ++i) {
        pow = pow * b % d;
        if (pow == 0) return true;
    }
    return false;
}

bool check3 (int d, int b) {
    int pow = 1 % d;
    for (int i = 1; i <= d; ++i) {
        pow = pow * b % d;
        if (pow != 1) return false;
    }
    return true;
}

bool check11 (int d, int b) {
    int pow1 = 1 % d;
    int pow2 = b % d;
    for (int i = 2; i <= d; ++i) {
        int cur = pow2 * b % d;
        if (cur != pow1) return false;
        swap(pow1, pow2);
    }
    return true;
}

char can[128] = {0};
char dp[128];

char rec (int d) {
    if (can[d]) return true;
    char &res = dp[d];
    if (res != -1) return res;
    res = 0;
    for (int i = 1; i * i <= d; ++i) {
        if (d % i) continue;
        if (rec(i) && rec(d / i)) {
            res = true;
            break;
        }
    }
    return res;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int b, d;
    cin >> b >> d;
    if (check2(d, b)) {
        puts("2-type");
        int cnt = 0;
        int pow = 1 % d;
        for (; pow != 0; pow = pow * b % d)
            ++cnt;
        printf("%d\n", cnt);
        return 0;
    }
    if (check3(d, b)) {
        puts("3-type");
        return 0;
    }
    if (check11(d, b)) {
        puts("11-type");
        return 0;
    }
    can[1] = true;
    for (int i = 2; i * i <= d; ++i) {
        if (d % i) continue;
        can[i] = check2(i, b) || check3(i, b) || check11(i, b);
        can[d / i] = check2(d / i, b) || check3(d / i, b) || check11(d / i, b);
    }
    memset(dp, -1, sizeof dp);
    if (rec(d)) {
        puts("6-type");
        return 0;
    }
    puts("7-type");

    return 0;
}

#include<cstdio>
int n,m,w,ans,type,cal;
int main()
{
	scanf("%d%d",&m,&n);
	for (int i=2;i<=n;i++) if (n%i==0){
		int cnt=0; while (n%i==0) cnt++,n/=i;
		if (m%i==0) type|=1,ans=ans>cnt?ans:cnt;
		else if (m%i==1) type|=2; else if (m%i==i-1) type|=4;
		}
	for (int i=0;i<3;i++) if (type&1<<i) cal++;
	if (cal>1) w=6; else if (type&1) w=2;
	else if (type&2) w=3; else if (type&4) w=11; else w=7;
	printf("%d-type\n",w); if (w==2) printf("%d\n",ans); return 0;
}

#include <iostream>
#include <vector>
using namespace std;
int dp[101];
int pow(int b, int j){
	if(j==0)
		return 1;
	return b*pow(b,j-1);
}
int main(){
	int b,d;
	cin >> b >> d;
	for(int i = 2; i <= 100; ++i){
		dp[i]=7;
		for(int j = 1; j < 10; ++j){
			if(pow(b,j)%i==0)
				dp[i]=2;
		}
		if(dp[i]!=7) continue;
		if(b%i==1){
			dp[i]=3;
			continue;
		}
		if(b%d==d-1 && ((d-1)*b)%d==1){
			dp[i]=11;
			continue;
		}
		vector<int> divs;
		int m = i;
		for(int j = 2; j <= 100; ++j){
			int cur = 1;
			while(m%j==0){
				cur*=j;
				m/=j;
			}
			if(cur>1)
				divs.push_back(cur);
		}
		bool ok = true;
		for(int j = 0; j < divs.size(); ++j)
			if(dp[divs[j]]==7){
				ok=false;
			}
		if(ok)
			dp[i]=6;
		else
			dp[i]=7;
	}
	cout << dp[d] << "-type\n";
	if(dp[d]==2)
		for(int i = 0; i < 10; ++i)
			if(pow(b,i)%d==0){
				cout << i << '\n';
				return 0;
			}
}

#include <bits/stdc++.h>
using namespace std;

#define N 111

int cnt, x[N], y[N];

void bunhae(int m) {
	cnt = 0;
	for (int i = 2; i <= m; i ++) if (m % i == 0) {
		x[++cnt] = i, y[cnt] = 0;
		while (m % i == 0) m /= i, y[cnt] ++;
	}
}

int ord(int m, int p) {
	int rlt = 0;
	while (m % p == 0) m /= p, rlt ++;
	return rlt;
}

int b, d;

bool two(int d) {
	bunhae(d);
	for (int i = 1; i <= cnt; i ++) if (b % x[i]) return 0;
	return 1;
}

bool three(int d) {
	return b % d == 1;
}

bool eleven(int d) {
	return b % d == d - 1;
}

int main() {
//	freopen("b.in", "r", stdin);
	scanf("%d %d", &b, &d);
	bunhae(d);
	bool tt = 1;
	for (int i = 1; i <= cnt; i ++) if (b % x[i]) tt = 0;
	if (tt) {
		puts("2-type");
		int ans = 0;
		for (int i = 1; i <= cnt; i ++) ans = max(ans, (ord(b, x[i]) + y[i] - 1) / y[i]);
		printf("%d\n", ans);
		return 0;
	}
	if (three(d)) return puts("3-type"), 0;
	if (eleven(d)) return puts("11-type"), 0;
	for (int i = 1; i <= d; i ++) {
		for (int j = 1; j <= d; j ++) {
			for (int k = 1; k <= d; k ++) if (i * j * k == d && __gcd(i, j) == 1 && __gcd(j, k) == 1 && __gcd(k, i) == 1) {
				if (two(i) && three(j) && eleven(k)) return puts("6-type"), 0;
			}
		}
	}
	return 0;
}

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define P // system("pause")
using namespace std ;
typedef long long LL ;

LL b, d ;
int dp[150] ;

int Dfs(LL x)
{
	int i ;
	LL tmp ;
	if(dp[x]) return dp[x] ;
	for(i = 1, tmp = b; i <= 7; i ++, tmp *= b)
		if(tmp%x == 0) return dp[x] = 1 ;
	if(b%x == 1) return dp[x] = 1 ;
	if(b%x == x-1) return dp[x] = 1 ;
	for(i = 2; i < x; i ++)
		if(x%i==0 && Dfs(i) && Dfs(x/i)) return dp[x] = 1 ;
	return dp[x] = -1 ;
}

int main()
{
	int i, j ;
	LL tmp ;
	scanf("%I64d %I64d", &b, &d) ;
	for(i = 1, tmp = b; i <= 7; i ++, tmp *= b)
		if(tmp%d == 0)
		{
			printf("2-type\n%d\n", i) ;
			P ;
			exit(0) ;
		}
	if(b%d == 1)
	{
		printf("3-type\n") ;
		P ;
		exit(0) ;
	}
	if(b%d == d-1)
	{
		printf("11-type\n") ;
		P ;
		exit(0) ;
	}
	if(Dfs(d) > 0)
	{
		printf("6-type\n") ;
		P ;
		exit(0) ;
	}
	else
	{
		printf("7-type\n") ;
		P ;
		exit(0) ;
	}

}

#include<cstdio>

int n,m,M,K;

int Gcd(int a,int b){return !a?b:Gcd(b%a,a);}

int main()
{
	scanf("%d%d",&n,&m);M=m;
	for(K=0;Gcd(n,m)!=1;K++)m/=Gcd(n,m);
	if(m==1)printf("2-type\n%d\n",K);
	else if(!((n-1)%M))printf("3-type\n");
	else if(!((n+1)%M))printf("11-type\n");
	else
	{
		if(!((1ll*(n-1)*(n+1))%m))printf("6-type\n");
			else printf("7-type\n");
	}
	return 0;
}

#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker,"/STACK:64000000")

#include <iostream>
#include <sstream>
#include <stdio.h>
#include <memory.h>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <time.h>
#include <bitset>

using namespace std;

#define mp make_pair
#define pb push_back
#define _(a,b) memset( (a), b, sizeof( a ) )
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()

typedef unsigned long long ull;
typedef long long lint;
typedef pair < int , int > pii;
typedef long double ld;

const int INF = 1000 * 1000 * 1000;
const lint LINF = 1000000000000000000LL;
const double eps = 1e-9;

void prepare()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
}

int gcd(int a,int b)
{
	if (b == 0) return a;
	return gcd(b,a % b);
}

bool good11(int b,int d)
{
	if (b % d == d - 1)
		return true;
	return false;
}

bool isPrime(int x)
{
	for (int i = 2; i * i <= x; i ++)
	{
		if (x % i == 0)
			return false;
	}
	return true;
}

bool solve()
{
	int b,d;
	cin >> b >> d;
	//if (gcd(b,d) > 1)
	{
		int k = 1;
		lint x = b;
		while (x % d != 0)
		{
			x *= b;
			k++;
			if (x > 1000000000000LL) break;
		}
		if (x % d == 0)
		{
			printf("2-type\n");
			printf("%d\n",k);
			return false;
		}
	}
	//else
	{
		if (b % d == 1)
		{
			printf("3-type\n");
		}
		else
		{
			if (good11(b,d))
			{
				printf("11-type\n");
			}
			else
			{
				if (isPrime(d))
				{
					printf("7-type\n");
				}
				else
					printf("6-type\n");
			}
		}
	}
	return false;
}

int main()
{
	prepare();
	while (solve());
	return 0;
}

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
using namespace std;
typedef long long lld;
#define mp make_pair
#define X first
#define Y second
#define pb push_back
#define inf 0xfffffff
vector<int>p2;
vector<int>p3;
vector<int>p11;
vector<int>p6;
vector<int> solve(int x)
{
    vector<int>g;
    g.clear();
    for(int i=2;i*i<=x;i++)
        if(x%i == 0)
        {
            while(x%i == 0)
            {
                g.pb(i);
                x/=i;
            }
        }
    if(x != 1)
        g.pb(x);
    return g;
}
int ok(vector<int>g,int x)
{
    int t=-1;
    while(1)
    {
        t++;
        int mark=x;
        for(vector<int>::iterator ll=g.begin();ll != g.end();ll++)
            if(x%(*ll) == 0)
                x/=*ll;
        if(mark == x)
            break;
    }
    if(x == 1)
        return t;
    else
        return -1;
}
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    p2=solve(a);
//  p11=solve(a+1);
    p11.pb(a+1);
    p3=solve(a-1);
    p6.clear();
    for(vector<int>::iterator ll=p2.begin();ll != p2.end();ll++)
        p6.pb(*ll);
    for(vector<int>::iterator ll=p11.begin();ll != p11.end();ll++)
        p6.pb(*ll);
    for(vector<int>::iterator ll=p3.begin();ll != p3.end();ll++)
        p6.pb(*ll);
    if(ok(p2,b) != -1)
    {
        printf("2-type\n");
        printf("%d\n",ok(p2,b));
    }
    else if(ok(p3,b) != -1)
        printf("3-type\n");
    else if(ok(p11,b) != -1)
        printf("11-type\n");
    else if(ok(p6,b) != -1)
        printf("6-type\n");
    else
        printf("7-type\n");
    return 0;
}

#include <stdio.h>
#include <string.h>
#include <math.h>
int isprime(int n)
{
	double a=sqrt(n+1.0);
	for(int i=2;i<a;++i)
		if(n%i==0)return false;
	return n!=1;
}
int main()
{
	int b,d;
	scanf("%d%d",&b,&d);
	for(int i=1,t=1;t<(1<<25);++i)
	{
		t*=b;
		if(t%d==0)
		{
			printf("2-type\n%d\n",i);
			return 0;
		}
	}
	if(b%d==1)
	{
		printf("3-type\n");
		return 0;
	}
	for(int i=1,t=1;t<(1<<25);t*=b)
	{
		if((t%d==1&&t*b%d==(d-1))||(t%d==(d-1)&&t*b%d==1))
		{
			printf("11-type\n");
			return 0;
		}
	}
	if(isprime(b))
		printf("7-type\n");
	else
		printf("6-type\n");
	return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>

#define inf 1000000000

using namespace std;

int ans[101];

int check(int b, int d) {
    // 2type
    int cp = b;
    for(int k = 1; cp < 10000000; k++) {
        if(cp % d == 0) {
            return 2;
        }
        cp *= b;
    }
    // 3type
    if(b % d == 1) {
        return 3;
    }

    // 11 type
    if((b * b) % d == 1 && b % d == d - 1) {
        return 11;
    }
    return 7;
}

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

int main(int argc, char **argv) {
    int b, d;
    scanf("%d %d", &b, &d);
    // type
    int cp = b;
    for(int k = 1; cp < 10000000; k++) {
        if(cp % d == 0) {
            printf("2-type\n%d\n", k);
            return 0;
        }
        cp *= b;
    }
    // 3type
    if(b % d == 1) {
        printf("3-type\n");
        return 0;
    }

    // 11 type
    if((b * b) % d == 1 && b % d == d - 1) {
        printf("11-type\n");
        return 0;
    }
    for(int k = 1; k <= d; k++) {
        ans[k] = check(b, k);
        if(ans[k] == 7) {
            for(int i = 2; i < d; i++) {
                if(d % i == 0 && gcd(i, d / i) == 1 && ans[i] != 7 && ans[d / i] != 7) {
                    ans[k] = 6;
                }
            }
        }
    }
    printf("%d-type\n", ans[d]);
    return 0;
}

#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    vector<int> u,v,o(10);
    for(int i=2,x=n,y=m;i<=100;i++){
        if(x%i==0) for(u.push_back(i);x%i==0;x/=i);
        if(y%i==0) for(v.push_back(i);y%i==0;y/=i);
    }
    int o2=set_intersection(u.begin(),u.end(),
                            v.begin(),v.end(),o.begin())!=o.begin();
    int o3=n%m==1,o11=n*(n+1)%m==0;
    if(includes(u.begin(),u.end(),v.begin(),v.end())){
        puts("2-type");
        int e=1;
        for(int x=n;x%m;x*=n) e++;
        printf("%d\n",e);
    }else if(o2) puts("6-type");
    else if(o3) puts("3-type");
    else if(o11) puts("11-type");
    else puts("7-type");
}

// Codeforces Round #116 (Div. 2, ACM-ICPC Rules) B Divisibility Rules

#include <cstdio>

using namespace std;

int main() {
	int b, d;
	scanf("%d%d", &b, &d);

	int ans = -1, cnt = 0;
	for (int i = 2; i <= d; i ++)
		if (d % i == 0) {
			int t = 0;
			int m = 1;
			while (d % i == 0) {
				t ++;
				d /= i;
				m *= i;
			}
			if (b % i == 0) {
				int tt = 1;
				int bb = b;
				while (bb % m != 0) {
					bb *= b;
					tt ++;
				}
				if (tt > cnt) cnt = tt;
				if (ans == -1) {
					ans = 2;
				} else if (ans != 2) {
					ans = 6;
				}
			} else if (b % m == 1) {
				if (ans == -1) {
					ans = 3;
				} else if (ans != 3) {
					ans = 6;
				}
			} else if (b % m == i - 1) {
				if (ans == -1) {
					ans = 11;
				} else if (ans != 11) {
					ans = 6;
				}
			} else {
				if (ans == -1) {
					ans = 7;
				} else if (ans != 7) {
					ans = 6;
				}
			}
			if (ans == 6) break;
		}

	printf("%d-type\n", ans);
	if (ans == 2) printf("%d\n", cnt);

	return 0;
}

#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;

int tt, forTwo;
const int prime[26] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37,
			41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 91, 97};

int solve(int b, int d)
{
	int divB[26] = {0}, divD[26] = {0};
	tt = b;
	for(int i=0; i<26; i++){
		if(tt%prime[i] == 0){
			tt /= prime[i];
			divB[i] ++;
			i--;
		}
	}
	tt = d;
	for(int i=0; i<26; i++){
		if(tt%prime[i] == 0){
			tt /= prime[i];
			divD[i] ++;
			i--;
		}
	}
	int mm = -1;
	for(int i=0; i<26; i++){
		if(divD[i] && (!divB[i]))  {mm=-1; break;}
		if(divB[i]) mm = max(mm, (divD[i]+divB[i]-1)/divB[i]);
	}
	if(mm!=-1){
		forTwo = mm;
		return 2;
	}

	if(b%d==1){
		return 3;
	}

	if((b+1)%d==0){ //&& d<b*b){
		return 11;
	}

	for(int i=0; i<26; i++){
		if(prime[i]==d)  return 7;
	}
	for(int i=0; i<26; i++){
		if(  (divD[i] && solve(b, prime[i])==7) ){
			return 7;
		}
	}

	return 6;
}

int main()
{
	int b, d, type;
//	while(1){

	scanf("%d%d", &b, &d);
	type = solve(b, d);

	printf("%d-type\n", type);
	if(type == 2)  printf("%d\n", forTwo);
//	}

	return 0;
}

/*daicfqmtlbkeljgnmfqsrahjdffsmbphbpktdcsopisskfdcct*/

#include <stdio.h>
#include <string.h>
#include <math.h>
int isprime(int n)
{
	double a=sqrt(n+1.0);
	for(int i=2;i<a;++i)
		if(n%i==0)return false;
	return n!=1;
}
int main()
{
	int b,d;
	scanf("%d%d",&b,&d);
	for(int i=1,t=1;t<(1<<25);++i)
	{
		t*=b;
		if(t%d==0)
		{
			printf("2-type\n%d\n",i);
			return 0;
		}
	}
	if(b%d==1)
	{
		printf("3-type\n");
		return 0;
	}
	for(int i=1,t=1;t<(1<<25);t*=b)
	{
		if((t%d==1&&t*b%d==(d-1))||(t%d==(d-1)&&t*b%d==1))
		{
			printf("11-type\n");
			return 0;
		}
	}
	if(isprime(d))
		printf("7-type\n");
	else
		printf("6-type\n");
	return 0;
}

#include<cstdio>
#include<vector>
#include<algorithm>
#define maxn 100009
using namespace std;
int gcd(int a,int b)
{
    return b==0 ? a : gcd(b,a%b);
}
int main()
{
    int b,d,cnt,i,g;
    long long x;
    while(scanf("%d%d", &b, &d)!=EOF)
    {
        g=gcd(b,d);
        x=1;
        for(i=0;i<9;i++) x*=g;
        if(x%d==0)
        {
            x=1;
            cnt=0;
            puts("2-type");
            while(x%d)
            {
                x*=g;
                cnt++;
            }
            printf("%d\n",cnt);
        }
        else if((b-1)%d==0) puts("3-type");
        else if((b+1)%d==0) puts("11-type");
        else
        {
            for(i=2;i<=d;i++)
            {
                if(d%i) continue;
                if(b%i) continue;
                while(d%i==0) d/=i;
            }
            if(d==1) while(1);
            if((b-1)%d==0||(b+1)%d==0) puts("6-type");
            else puts("7-type");
        }
    }
    return 0;
}

#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
int ppo(int a,int b,int c)
{
    int ans=1;
    int tt=a;
    while(b)
    {
        if(b&1)ans=ans*tt%c;
        tt=tt*tt%c;
        b>>=1;
    }
    return ans;
}
int type2(int a,int b)
{
    int i,j,x,y;
    bool f1=0,f2=0;
    for(i=1;i<20;i++)
    {
        if(ppo(a,i,b)==0)
        {
            return 2;
        }
    }
    return 0;
}
int type3(int a,int b)
{
    if((a-1)%b==0)
    {
        return 3;
    }
    return 0;
}
int type11(int a,int b)
{
    if((a+1)%b==0)return 11;
    return 0;
}

int type(int a,int b)
{
    int i,j,x,y,f1=0,f2=0;
    if(type2(a,b))return 2;
    if(type3(a,b))return 3;
    if(type11(a,b))return 11;
    for(i=2;i<b;i++)
    {
        if(b%i==0)
        {
            x=i;y=b/i;
            if(x==y)continue;
            f1=type2(a,x)||type3(a,x)||type11(a,x);
            f2=type2(a,y)||type3(a,y)||type11(a,y);
            if(f1&&f2)return 6;
        }
    }
    return 7;
}
int main()
{
    int b,d;
    int i,j;
    int xx,yy;
    while(scanf("%d %d",&b,&d)!=EOF)
    {
    xx=type(b,d);
    if(xx==2)
    {
        for(i=1;i<20;i++)
        {
            if(ppo(b,i,d)==0)
            {
                yy=i;
                break;
            }
        }
        printf("2-type\n%d\n",yy);
    }
    else printf("%d-type\n",xx);
    }
}

#include<cstdio>
#include<cstring>

bool ok[110];
int prim[100],len;

void init()
{
    prim[0]=2;
    len=1;
    for(int i=3,j;i<=100;i++)
    {
        for(j=0;j<len&&prim[j]*prim[j]<=i;j++)
        {
            if(i%prim[j]==0)
                break;
        }
        if(j==len||prim[j]*prim[j]>i)
            prim[len++]=i;
    }
}

int sum(int n,int base)
{
    int ans=0;
    while(n)
    {
        ans+=n%base;
        n/=base;
    }
    return ans;
}

int last(int a,int b)
{
    int k=1;
    for(int i=1;i<1000;i++)
    {
        k=k*b%a;
        if(k==0)
            return i;
    }
}

bool istype2(int a,int base)
{
	for(int i=0;i<=a;i++)
		ok[i]=0;
	int k=base%a;
	ok[k]=1;
	for(int i=1;i<=a;i++)
	{
		k=k*k%a;
		if(k==0)
			return true;
		if(ok[k])
			break;
		ok[k]=1;
	}
	return false;
}

bool istype3(int a,int base)
{
	for(int k=1;k<=base;k++)
	{
		if(sum(k*a,base)%a!=0)
			return false;
	}
	return true;
}

bool istype11(int a,int base)
{
	return a==base+1;
}

int main()
{
	int a,b;
	scanf("%d%d",&b,&a);
	init();
	bool type2=0;
	bool type3=0;
	bool type11=0;
	type2|=istype2(a,b);
	type3|=istype3(a,b);
	type11|=istype11(a,b);
	int tot=type2+type3+type11;
	if(tot==1)
	{
		if(type2)
			printf("2-type\n%d\n",last(a,b));
		if(type3)
			printf("3-type\n");
		if(type11)
			printf("11-type\n");
	}
	else if(tot>=2)
        printf("6-type");
    else
    {
        bool type6=0;
        for(int i=0;i<len&&prim[i]<a&&!type6;i++)
        {
            if(a%prim[i]==0)
            {
                type2=istype2(prim[i],b);
                type6|=(type2&&(istype3(a/prim[i],b)||istype11(a/prim[i],b)));
                type3=istype3(prim[i],b);
                type6|=(type3&&(istype2(a/prim[i],b)||istype11(a/prim[i],b)));
                type11=istype11(prim[i],b);
                type6|=(type11&&(istype3(a/prim[i],b)||istype2(a/prim[i],b)));
            }
        }
        if(!type6)
        {
            for(int i=0;i<len&&prim[i]<=a&&!type6;i++)
            {
                for(int j=i+1;j<len&&prim[i]*prim[j]<a&&!type6;j++)
                {
                    if(a%(prim[i]*prim[j])==0)
                    type2=(istype2(prim[i],b)||istype2(prim[j],b)||istype2(a/prim[i]/prim[j],b));
                    type3=(istype3(prim[i],b)||istype3(prim[j],b)||istype3(a/prim[i]/prim[j],b));
                    type2=(istype11(prim[i],b)||istype11(prim[j],b)||istype11(a/prim[i]/prim[j],b));
                    type6|=((type11+type2+type3)>=2);
                }
            }
        }
        if(type6)
            printf("6-type\n");
        else
            printf("7-type\n");
    }
	return 0;
}

#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

vector<pair<int,int> > go(int b)
{
    vector<pair<int,int> >a;
    for(int i=2;i*i<=b;i++)
    {
        if(b%i==0)
        {
            int k = 0;
            while(b%i==0) {b/=i; k++;}
            a.push_back({i,k});
        }
    }
    if(b>1) a.push_back({b,1});
    return a;
}

//void go2(const vector<int> &a, int &d)
int go2(int b, int &d)
{
    vector<pair<int,int> > a = go(b);
    int res = 0;
    for(int i=0;i<a.size();i++)
    {
        int k = 0;
        cerr << a[i].first<<endl;
        while(d%a[i].first==0)
        {
            d/=a[i].first;
            k++;
        }
        int t = 0;
        if(k%a[i].second)  t=1;
        k/=a[i].second;
        k+=t;
        if(k>res) res = k;
    }
    cerr <<endl;
    return res;

}

bool go3(int b, int d)
{
    vector<pair<int,int> > a = go(b);
    int res = 0;
    for(int i=0;i<a.size();i++)
    {
        int k = 0;
        cerr << a[i].first<<endl;
        while(d%a[i].first==0)
        {
            d/=a[i].first;
            k++;
        }
        int t = 0;
        if(k%a[i].second)  t=1;
        k/=a[i].second;
        k+=t;
        if(k>res) res = k;
    }
    cerr <<endl;
    return d==1;
}

int main()
{
    int b,d;
    cin >> b >>d;
    if(go3(b-1,d)) {cout << "3-type"<<endl; return 0;}
    if(go3(b+1,d)) {cout << "11-type"<<endl; return 0;}

    int fl2 = go2(b,d);
    if(d==1){cout << "2-type"<<endl<<fl2<<endl; return 0;}
    go2(b-1,d);
    go2(b+1,d);
    if(d>1){cout <<"7-type"<<endl; return 0;}
    cout << "6-type"<<endl;
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>

using namespace std;

int K, P;

int p[100], nP;

int main() {
    scanf("%d%d", &K, &P);
    int t = 1;
    for (int i = 0; i < 100; i++) {
        if (t == 0) {
            printf("2-type\n%d\n", i);
            return 0;
        }
        t = t * K % P;
    }
    if (K % P == 1) {
        printf("3-type\n");
        return 0;
    }
    if (K % P == P - 1) {
        printf("11-type\n");
        return 0;
    }
    nP = 0;
    for (int i = 2; i <= P; i++) {
        while (P % i == 0) {
            p[nP++] = i;
            P /= i;
        }
    }
    for (int i = 0; i < nP; i++) {
        int t = 0;
        for (int j = 0; j < 100; j++) t = t * K % p[i];
        if (t == 0) continue;
        if (K % p[i] == 1 && K % p[i] == p[i] - 1) continue;
        printf("7-type\n");
        return 0;
    }
    printf("6-type\n");
    return 0;
}

#include<algorithm>
#include<assert.h>
#include<bitset>
#include<complex>
#include<ctype.h>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<limits.h>
#include<list>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<string>
#include<time.h>
#include<utility>
#include<vector>
//#include<windows.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;++i)
#define For(i,l,r) for(int i=l;i<=r;++i)
#define foreach(i,x) for(typeof((x).begin()) i=(x).begin();i!=(x).end();++i)
#define all(x) x.begin(),x.end()
#define SORT(x) sort(all(x))
#define CLEAR(x) memset(x,0,sizeof(x))
#define FILL(x,c) memset(x,c,sizeof(x))
#define SZ(x) ((int)(x.size()))
#define DREP(x) sort(all(x));x.erase(unique(x.begin(),x.end()),x.end())
#define INDEX(arr,index) (lower_bound(arr.begin(),arr.end(),index)-arr.begin())
#define Debug(x) cout<<#x<<"="<<x<<endl
#define debug(args...) {dbg,args; cerr<<endl;}
#define dline cerr<<endl
#define mp make_pair
#define pb push_back
#define FF first
#define SS second
#define tri(a,b,c) make_pair((a),make_pair((b),(c)))
#define XX first
#define YY second.first
#define ZZ second.second
#define s(n) scanf("%d",&n)
#define sl(n) scanf(%lld",&n)
#define sf(n) scanf("%lf",&n)
#define ss(n) scanf("%s",n)
#define maX(a,b) ((a)>(b)?(a):(b))
#define miN(a,b) ((a)<(b)?(a):(b))
#define abS(x) ((x)<0?-(x):(x))
const int inf=~0U>>1;
const long long linf=(long long)1e18;
const double eps=1e-6;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
typedef vector<int>::iterator eit;
typedef pair<int,int> pi;
typedef pair<int,pair<int,int> > tri;
typedef vector<int> vi;
typedef vector<int>::iterator vit;
typedef set<int> si;
typedef set<int>::iterator sit;
typedef map<int,int> mii;
typedef map<int,int>::iterator mit;
typedef istringstream ISS;
typedef ostringstream OSS;
template<class T> string tostr(T a){
	OSS out;out<<a;return out.str();
}
struct debugger{
	template<typename T> debugger& operator ,(const T &x)
	{
		cerr<<x<<endl;
		return *this;
	}
}dbg;
namespace fastIO{
	#define BUF_SIZE 100000
	#define OUT_SIZE 100000
	#define ll long long
	//fread->read
	bool IOerror=0;
	inline char nc(){
		static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
		if (p1==pend){
			p1=buf; pend=buf+fread(buf,1,BUF_SIZE,stdin);
			if (pend==p1){IOerror=1;return -1;}
			//{printf("IO error!\n");system("pause");for (;;);exit(0);}
		}
		return *p1++;
	}
	inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
	inline void read(int &x){
		bool sign=0; char ch=nc(); x=0;
		for (;blank(ch);ch=nc());
		if (IOerror)return;
		if (ch=='-')sign=1,ch=nc();
		for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
		if (sign)x=-x;
	}
	inline void read(ll &x){
		bool sign=0; char ch=nc(); x=0;
		for (;blank(ch);ch=nc());
		if (IOerror)return;
		if (ch=='-')sign=1,ch=nc();
		for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
		if (sign)x=-x;
	}
	inline void read(double &x){
		bool sign=0; char ch=nc(); x=0;
		for (;blank(ch);ch=nc());
		if (IOerror)return;
		if (ch=='-')sign=1,ch=nc();
		for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
		if (ch=='.'){
			double tmp=1; ch=nc();
			for (;ch>='0'&&ch<='9';ch=nc())tmp/=10.0,x+=tmp*(ch-'0');
		}
		if (sign)x=-x;
	}
	inline void read(char *s){
		char ch=nc();
		for (;blank(ch);ch=nc());
		if (IOerror)return;
		for (;!blank(ch)&&!IOerror;ch=nc())*s++=ch;
		*s=0;
	}
	inline void read(char &c){
		for (c=nc();blank(c);c=nc());
		if (IOerror){c=-1;return;}
	}
	//getchar->read
	inline void read1(int &x){
		char ch;int bo=0;x=0;
		for (ch=getchar();ch<'0'||ch>'9';ch=getchar())if (ch=='-')bo=1;
		for (;ch>='0'&&ch<='9';x=x*10+ch-'0',ch=getchar());
		if (bo)x=-x;
	}
	inline void read1(ll &x){
		char ch;int bo=0;x=0;
		for (ch=getchar();ch<'0'||ch>'9';ch=getchar())if (ch=='-')bo=1;
		for (;ch>='0'&&ch<='9';x=x*10+ch-'0',ch=getchar());
		if (bo)x=-x;
	}
	inline void read1(double &x){
		char ch;int bo=0;x=0;
		for (ch=getchar();ch<'0'||ch>'9';ch=getchar())if (ch=='-')bo=1;
		for (;ch>='0'&&ch<='9';x=x*10+ch-'0',ch=getchar());
		if (ch=='.'){
			double tmp=1;
			for (ch=getchar();ch>='0'&&ch<='9';tmp/=10.0,x+=tmp*(ch-'0'),ch=getchar());
		}
		if (bo)x=-x;
	}
	inline void read1(char *s){
		char ch=getchar();
		for (;blank(ch);ch=getchar());
		for (;!blank(ch);ch=getchar())*s++=ch;
		*s=0;
	}
	inline void read1(char &c){for (c=getchar();blank(c);c=getchar());}
	//scanf->read
	inline void read2(int &x){scanf("%d",&x);}
	inline void read2(ll &x){
		#ifdef _WIN32
			scanf("%I64d",&x);
		#else
		#ifdef __linux
			scanf("%lld",&x);
		#else
			puts("error:can't recognize the system!");
		#endif
		#endif
	}
	inline void read2(double &x){scanf("%lf",&x);}
	inline void read2(char *s){scanf("%s",s);}
	inline void read2(char &c){scanf(" %c",&c);}
	inline void readln2(char *s){gets(s);}
	//fwrite->write
	struct Ostream_fwrite{
		char *buf,*p1,*pend;
		Ostream_fwrite(){buf=new char[BUF_SIZE];p1=buf;pend=buf+BUF_SIZE;}
		void out(char ch){
			if (p1==pend){
				fwrite(buf,1,BUF_SIZE,stdout);p1=buf;
			}
			*p1++=ch;
		}
		void print(int x){
			static char s[15],*s1;s1=s;
			if (!x)*s1++='0';if (x<0)out('-'),x=-x;
			while(x)*s1++=x%10+'0',x/=10;
			while(s1--!=s)out(*s1);
		}
		void println(int x){
			static char s[15],*s1;s1=s;
			if (!x)*s1++='0';if (x<0)out('-'),x=-x;
			while(x)*s1++=x%10+'0',x/=10;
			while(s1--!=s)out(*s1); out('\n');
		}
		void print(ll x){
			static char s[25],*s1;s1=s;
			if (!x)*s1++='0';if (x<0)out('-'),x=-x;
			while(x)*s1++=x%10+'0',x/=10;
			while(s1--!=s)out(*s1);
		}
		void println(ll x){
			static char s[25],*s1;s1=s;
			if (!x)*s1++='0';if (x<0)out('-'),x=-x;
			while(x)*s1++=x%10+'0',x/=10;
			while(s1--!=s)out(*s1); out('\n');
		}
		void print(double x,int y){
			static ll mul[]={1,10,100,1000,10000,100000,1000000,10000000,100000000,
				1000000000,10000000000LL,100000000000LL,1000000000000LL,10000000000000LL,
				100000000000000LL,1000000000000000LL,10000000000000000LL,100000000000000000LL};
			if (x<-1e-7)out('-'),x=-x;x*=mul[y];
			ll x1=(ll)floor(x); if (x-floor(x)>=0.5)++x1; ll x2=x1/mul[y];
			print(x2);if (y>0){out('.');print(x1-x2*mul[y]);}
		}
		void println(double x,int y){print(x,y);out('\n');}
		void print(char *s){while (*s)out(*s++);}
		void println(char *s){while (*s)out(*s++);out('\n');}
		void flush(){if (p1!=buf){fwrite(buf,1,p1-buf,stdout);p1=buf;}}
		~Ostream_fwrite(){flush();}
	}Ostream;
	inline void print(int x){Ostream.print(x);}
	inline void println(int x){Ostream.println(x);}
	inline void print(char x){Ostream.out(x);}
	inline void println(char x){Ostream.out(x);Ostream.out('\n');}
	inline void print(ll x){Ostream.print(x);}
	inline void println(ll x){Ostream.println(x);}
	inline void print(double x,int y){Ostream.print(x,y);}
	inline void println(double x,int y){Ostream.println(x,y);}
	inline void print(char *s){Ostream.print(s);}
	inline void println(char *s){Ostream.println(s);}
	inline void println(){Ostream.out('\n');}
	inline void flush(){Ostream.flush();}
	//puts->write
	char Out[OUT_SIZE],*o=Out;
	inline void print1(int x){
		static char buf[15];
		char *p1=buf;if (!x)*p1++='0';if (x<0)*o++='-',x=-x;
		while(x)*p1++=x%10+'0',x/=10;
		while(p1--!=buf)*o++=*p1;
	}
	inline void println1(int x){print1(x);*o++='\n';}
	inline void print1(ll x){
		static char buf[25];
		char *p1=buf;if (!x)*p1++='0';if (x<0)*o++='-',x=-x;
		while(x)*p1++=x%10+'0',x/=10;
		while(p1--!=buf)*o++=*p1;
	}
	inline void println1(ll x){print1(x);*o++='\n';}
	inline void print1(char c){*o++=c;}
	inline void println1(char c){*o++=c;*o++='\n';}
	inline void print1(char *s){while (*s)*o++=*s++; }
	inline void println1(char *s){print(s);*o++='\n';}
	inline void println1(){*o++='\n';}
	inline void flush1(){if (o!=Out&&*(o-1)=='\n')*--o=0;puts(Out);}
	struct puts_write{
		~puts_write(){flush1();}
	};
	inline void print2(int x){printf("%d",x);}
	inline void println2(int x){printf("%d\n",x);}
	inline void print2(char x){printf("%c",x);}
	inline void println2(char x){printf("%c\n",x);}
	inline void print2(ll x){
		#ifdef _WIN32
			printf("%I64d",x);
		#else
		#ifdef __linux
			printf("%lld",x);
		#else
			puts("error:can't recognize the system!");
		#endif
		#endif
	}
	inline void println2(ll x){print2(x);printf("\n");}
	inline void println2(){printf("\n");}
	#undef ll
	#undef OUT_SIZE
	#undef BUF_SIZE
};
using namespace fastIO;
string name="", in=".in", out=".out";
const int N=105;
int can2(int b,int d){
	int x=1;
	for (int i=1;i<=d;++i){
		x=x*b%d;
		if (x==0)return i;
	}
	return 0;
}
bool can3(int b,int d){
	if (b%d==1)return 1;
	else return 0;
}
bool can11(int b,int d){
	if (b%d==d-1)return 1;
	else return 0;
}
int f[N];
bool dfs(int x,int y){
	if (y==0)return 0;
	for (int i=1;i<=y;++i)
		if (f[i]&&dfs(x/i,i-1))return 1;
	return 0;
}
bool can6(int b,int d){
	for (int i=1;i<=d;++i)f[i]=can2(b,i)||can3(b,i)||can11(b,i);
	//for (int i=1;i<=d;++i)printf("f%d %d\n",i,f[i]);
	//for (int i=1;i<=d;++i)
	//	for (int j=i+i;j<=d;j+=i)if (f[i]&&f[j/i]&&(i!=j/i))f[j]=1;
	//puts("-------");
	//for (int i=1;i<=d;++i)printf("f%d %d\n",i,f[i]);
	//return f[d];
	return dfs(d,d);
}
void RT(){
	//system("pause");for (;;);
	exit(0);
}
int main()
{
	//freopen((name+in).c_str(),"r",stdin);
	//freopen((name+out).c_str(),"w",stdout);
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
	//freopen("1.out","w",stdout);
#endif
	int b,d;scanf("%d%d",&b,&d);
	if (can2(b,d)){
		puts("2-type");
		printf("%d\n",can2(b,d));
		RT();
	}
	if (can3(b,d))puts("3-type"),RT();
	if (can11(b,d))puts("11-type"),RT();
	if (can6(b,d))puts("6-type"),RT();
	puts("7-type"),RT();
	//system("pause");for (;;);
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define sz(a) (int)a.size()

typedef long long ll;

const int N = (int)1e5 + 3;
const int K = 20;
const int inf = (int)1e9 + 7;

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, d;
    scanf("%d%d", &d, &n);
    if (d % n == 1) {
        printf("3-type");
        return 0;
    }
    if (d == n - 1) {
        printf("11-type");
        return 0;
    }
    vector<int> a;
    vector<int> w;
    for (int i = 2; i * i <= d; ++i) {
        if (d % i == 0) {
            int r = 0;
            a.push_back(i);
            for (; d % i == 0; d /= i) {
                ++r;
            }
            w.push_back(r);
        }
    }
    if (d > 1) {
        a.push_back(d);
        w.push_back(1);
    }
    int p = 0;
    for (int i = 0; i < sz(a); ++i) {
        int l = 0;
        for (; n % a[i] == 0; n /= a[i]) {
            ++l;
        }
        p = max(p, (l + w[i] - 1) / w[i]);
    }
    if (n == 1) {
        printf("2-type\n%d", p);
        return 0;
    }
    if (d % n == 1 || d == n - 1) {
        printf("6-type");
        return 0;
    }
    printf("7-type");
    return 0;
}

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cctype>
using namespace std;

int main() {
	int b, d;
	cin >> b >> d;
	bool type2 = false, type3 = false, type11 = false;
	if ((b - 1) % d == 0) {
		type3 = true;
	}
	if ((b + 1) % d == 0) {
		type11 = true;
	}
	int cnt = 0;
	type2 = true;
	for (int i = 2; i <= b; i++) {
		if (b % i == 0) {
			int div = i;
			int cb = 0;
			while (b % i == 0) {
				b /= div;
				cb++;
			}
			int cd = 0;
			while (d % i == 0) {
				d /= div;
				cd++;
			}
			cnt = max(cnt, (cd + cb - 1) / cb);
		}
	}
	if (d != 1) {
		type2 = false;
	}
	if (type2 && type3 || type2 && type11) {
		cout << "6-type" << endl;
	} else if (type3) {
		cout << "3-type" << endl;
	} else if (type11) {
		cout << "11-type" << endl;
	} else if (type2) {
		cout << "2-type" << endl << cnt << endl;
	} else {
		cout << "7-type" << endl;
	}
}

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
using namespace std;
typedef long long lld;
#define mp make_pair
#define X first
#define Y second
#define pb push_back
#define inf 0xfffffff
bool isprime(int x)
{
    for(int i=2;i*i<=x;i++)
        if(x%i == 0)
            return false;
    return true;
}
vector<int>p2;
vector<int>p3;
vector<int>p11;
vector<int>p6;
vector<int> solve(int x)
{
    vector<int>g;
    g.clear();
    for(int i=2;i*i<=x;i++)
        if(x%i == 0)
        {
            while(x%i == 0)
            {
                g.pb(i);
                x/=i;
            }
        }
    if(x != 1)
        g.pb(x);
    return g;
}
int ok(vector<int>g,int x)
{
    int t=-1;
    while(1)
    {
        t++;
        int mark=x;
        for(vector<int>::iterator ll=g.begin();ll != g.end();ll++)
            if(x%(*ll) == 0)
                x/=*ll;
        if(mark == x)
            break;
    }
    if(x == 1)
        return t;
    else
        return -1;
}
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    p2=solve(a);
    p11=solve(a+1);
    p3=solve(a-1);
    p6.clear();
    for(vector<int>::iterator ll=p2.begin();ll != p2.end();ll++)
        p6.pb(*ll);
    for(vector<int>::iterator ll=p11.begin();ll != p11.end();ll++)
        p6.pb(*ll);
    for(vector<int>::iterator ll=p3.begin();ll != p3.end();ll++)
        p6.pb(*ll);
    if(ok(p2,b) != -1)
    {
        printf("2-type\n");
        printf("%d\n",ok(p2,b));
    }
    else if(ok(p3,b) != -1)
        printf("3-type\n");
    else if(ok(p11,b) != -1)
        printf("11-type\n");
    else if(ok(p6,b) != -1)
        printf("6-type\n");
    else
        printf("7-type\n");
    return 0;
}

#include <iostream>
#include <cstring>

using namespace std;

int b,d,ans,f[1000];

int gcd(int a,int b)
{
	if (b==0) return a; else return gcd(b,a%b);
}

int lcm(int a,int b)
{
	return a*b/gcd(a,b);
}

int main()
{
	cin>>b>>d;
	if (d==b+1) ans=11; else
	{
		memset(f,127,sizeof(f));
		ans=7;
		f[b+1]=11;
		for (int i=2;i<=b-1;i++)
			if ((b-1)%i==0) f[i]=3;
		for (int i=1;i<=b;i++)
			if (b%i==0) f[i]=2;
		for (int i=1;i<=d;i++)
			for (int j=1;j<=i;j++)
				if ((i%j==0)&&(f[j]==2)&&(f[i/j]==2)) f[i]=2;
		for (int i=1;i<=d-1;i++)
			if ((i==1)||(f[i]==3))
				for (int j=1;j<=d-1;j++)
					if ((j==1)||(f[j]==11))
						if (((d%lcm(i,j))==0)&&(f[d/lcm(i,j)]==2)) ans=6;
		if ((ans==7)&&(f[d]<100)) ans=f[d];
	}
	cout<<ans<<"-type"<<endl;
	if (ans==2)
	{
		long long k=1;
		for (int i=1;i<=10;i++)
		{
			k=(long long)k*b;
			if (k%d==0)
			{
				cout<<i<<endl;
				return 0;
			}
		}
	}
	return 0;
}

#include<iostream>
#include<sstream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<cassert>
#define rep(i,n) for(int i=0;i<n;i++)
#define fr(i,c) for(__typeof (c.begin()) i=c.begin(); i!=c.end(); i++)
#define all(c) (c).begin(), (c).end()
#define pb push_back
using namespace std;

typedef vector<int> vi;
typedef long long ll;

map<int, int> fac(int n){
	map<int, int> res;
	for(int i = 2; i*i <= n; i++) if(n % i == 0){
		int c = 0;
		while(n % i == 0) n /= i, c++;
		res[i] = c;
	}
	if(n > 1) res[n] = 1;
	return res;
}
void run(){
	int d, b;
	cin >> b >> d;
	map<int, int> f = fac(d), g = fac(b);

	if(d % b == 1){
		cout << "3-type" << endl;
		return;
	}
	if(d % b == b-1){
		cout << "11-type" << endl;
		return;
	}

	int two = 0;
	bool three = 0, eleven = 0;
	fr(i, f){
		if(!g.count(i->first)){
			if(b % i->first == 1) three = 1;
			else if(b % i->first == i->first - 1) eleven = 1;
			else{
				cout << "7-type" << endl;
				return;
			}
		}
		else two = max(two, (g[i->first] + i->second - 1) / g[i->first]);
	}
	if((two != 0) + three + eleven > 1) cout << "6-type" << endl;
	else if(two){
		cout << "2-type" << endl;
		cout << two << endl;
	}
	else if(three) cout << "3-type" << endl;
	else if(eleven) cout << "11-type" << endl;
	else assert(0);
}
int main(){
#ifndef ONLINE_JUDGE
  rep(i,3)
#endif
    run();
  return 0;
}

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cctype>
using namespace std;

int main() {
	int b, d;
	cin >> b >> d;
	bool type2 = false, type3 = false, type11 = false;
	if ((b - 1) % d == 0) {
		type3 = true;
	}
	if ((b + 1) % d == 0) {
		type11 = true;
	}
	int cnt = 0;
	type2 = true;
	for (int i = 2; i <= b; i++) {
		if (b % i == 0) {
			int div = i;
			int cb = 0;
			while (b % i == 0) {
				b /= div;
				cb++;
			}
			int cd = 0;
			while (d % i == 0) {
				d /= div;
				cd++;
			}
			cnt = max(cnt, (cd + cb - 1) / cb);
		}
	}
	if (d != 1) {
		type2 = false;
	}
	if (type2 && type3) {
		cout << "6-type" << endl;
	} else if (type3) {
		cout << "3-type" << endl;
	} else if (type11) {
		cout << "11-type" << endl;
	} else if (type2) {
		cout << "2-type" << endl << cnt << endl;
	} else {
		cout << "7-type" << endl;
	}
}

//============================================================================
// Name        : dd.cpp
// Author      : dd
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <set>
#include <cstdio>
#include <map>
using namespace std;

int ans;

int dp[200];

int solve(int b, int d){
    if( dp[b]>=0 ) return dp[b];

    bool vst[220]={false};
    int t=1;
    vst[1]=true;
    set<int> st;
    st.insert(1);

    for(int i=1;;i++){
        t=t*b%d;
        if( t==0 ){
            ans=i;
            return 2;
        }
        st.insert(t);
        if( vst[t] ) break;
        vst[t]=true;
    }

    if( st.size()==1 ) return 3;

    if( d==b+1 ) return 11;

    for(int i=2;i<d;i++){
        if( d%i==0 ){
            if( solve(b, i)!=7 && solve(b, d/i)!=7 )
                return 6;
        }
    }
    return 7;
}

int main() {
    int b, d;
    while( cin>>b>>d ){
         memset(dp, -1, sizeof(dp));
        int ret=solve(b, d);
        printf("%d-type", ret);
        cout<<endl;
        if( ret==2 ) cout<<ans<<endl;
    }
}

#include<cstdio>
int B,D,T,i;
int Gcd(int a,int b)
{
	if(!b) return a;
	return Gcd(b,a%b);
}
int main()
{
	scanf("%d%d",&B,&D);
	T=D;
	for(i=2;i<=B;++i)
		if(B%i==0)
			for(;T%i==0;T/=i);
	if(T==1)
	{
		printf("2-type\n");
		return 0;
	}
	if((B-1)%D==0)
	{
		printf("3-type\n");
		return 0;
	}
	if(D==B+1)
	{
		printf("11-type\n");
		return 0;
	}
	T=D;
	for(;T%(B+1)==1;T/=(B+1));
	for(i=2;i<=B;++i)
		if((B-1)%i==0&&T%i==0)
			if(Gcd(i,D/T)==1)
				T/=i;
	for(i=2;i<=B;++i)
		if(B%i==0)
			for(;T%i==0;T/=i);
	if(T==1)
	{
		printf("6-type\n");
		return 0;
	}
	printf("7-type\n");
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define sz(a) (int)a.size()

typedef long long ll;

const int N = (int)1e5 + 3;
const int K = 20;
const int inf = (int)1e9 + 7;

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, d;
    scanf("%d%d", &d, &n);
    int dd = d;
    if (d % n == 1) {
        printf("3-type");
        return 0;
    }
    if (d % n == n - 1) {
        printf("11-type");
        return 0;
    }
    vector<int> a;
    vector<int> w;
    for (int i = 2; i * i <= d; ++i) {
        if (d % i == 0) {
            int r = 0;
            a.push_back(i);
            for (; d % i == 0; d /= i) {
                ++r;
            }
            w.push_back(r);
        }
    }
    if (d > 1) {
        a.push_back(d);
        w.push_back(1);
    }
    int p = 0;
    for (int i = 0; i < sz(a); ++i) {
        int l = 0;
        for (; n % a[i] == 0; n /= a[i]) {
            ++l;
        }
        p = max(p, (l + w[i] - 1) / w[i]);
    }
    if (n == 1) {
        printf("2-type\n%d", p);
        return 0;
    }
    for (; n > 1; ) {
        bool f = 1;
        for (int j = 2; j <= n; ++j) {
            if ((dd % j == 1 || dd % j == j - 1) && n % j == 0) {
                n /= j;
                f = 0;
                break;
            }
        }
        if (f) {
            printf("7-type");
            return 0;
        }
    }
    printf("6-type");
    return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int b, d;

int gcd(int a, int b)
{
	return b ? gcd(b, a % b) : a;
}

int _;
bool p2(int x)
{
	_ = 0;
	while (gcd(x, b) != 1)
		x /= gcd(x, b), ++_;
	return x == 1;
}

bool p3(int x)
{
	return b % x == 1;
}

bool p11(int x)
{
	return b % x == x - 1;
}

bool p6(int x)
{
	for (int i = 2; x > 1; ++i)
		if (x % i == 0)
		{
			if (!(p2(i) || p3(i) || p11(i)))
				return 0;
			while (x % i == 0)
				x /= i;
		}
	return 1;
}

int main()
{
	scanf("%d%d", &b, &d);
	if (p2(d))
		printf("2-type\n%d\n", _);
	else if (p3(d))
		printf("3-type\n");
	else if (p11(d))
		printf("11-type\n");
	else if (p6(d))
		printf("6-type\n");
	else
		printf("7-type\n");
	return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <cstdio>
#include <stdlib.h>
#include <stack>
#include <numeric>
#include <bitset>
#include <cctype>
typedef long long ll;
#define MAX 15
using namespace std;
#define INF 2147483647
#define inf 1<<30
#define MOD 1000000007
#define EPS 1e-20
#define G 9.8
#define PI acos(-1)
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
bool debug = false;
int n,m,k;
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};

int gc(int x, int y) {
    int z = y;
    while(x%y!=0)
    {
        z = x%y;
        x = y;
        y = z;
    }
    return z;
}
int main(){
    int d,b,g,c=0,dd;
    scanf("%d%d",&b,&d); dd=d;
    while((g=gc(b, dd)) > 1) {
        dd/=g; c++;
    }
    if (dd==1) {
        printf("2-type\n%d\n", c);
    } else if ((b-1)%d==0) {
        puts("3-type");
    } else  if ((b+1)%d==0) {
        puts("11-type");
    } else if ((b+1)*(b-1)/(b&1+1) % dd == 0) {
        puts("6-type");
    } else {
        puts("7-type");
    }

    return 0;
}

#include <cstdio>
int tmp,fail[1000];
int gcd(int a,int b)
{
  if(a < b){int t=a;a=b;b=t;}
  if(b == 0)
    return a;
  return gcd(b,a%b);
}
int twotype(int a,int b)
{
  int i,k,g,x = a;
  while(x > 1)
    {
      g = gcd(x,b);
      if(g == 1)
	return -1;
      x /= g;
    }
  for(i=1,k=b;k%a;i++,k*=b);
  return i;
}
int func(int a,int b)
{
  tmp = twotype(a,b);
  if(tmp != -1)
    return 2;
  if(b%a == 1)
    return 3;
  if( (b*b)%a == 1 && b%a == a-1)
    return 11;
  return 7;
}
int sixtype(int a,int b)
{
  int x = a,j;
  for(int i=2;i<a && x > 1;i++)
    {
      if(x%i == 0 && !fail[i])
	{
	  for(j=i;x%j==0;j*=i) fail[j] = 1;
	  if(func(j,b) != 7)
	    x /= j;
	}
    }
  if(x == 1)
    return 6;
  return 7;
}
int main()
{
  //freopen("b.in","r",stdin);
  //freopen("b.out","w",stdout);
  int d,b;
  scanf("%d%d",&b,&d);
  int ans = func(d,b);
  if(ans == 7)
    ans = sixtype(d,b);
  printf("%d-type\n",ans);
  if(ans == 2)
    printf("%d\n",tmp);
}

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
#include <utility>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define FOE(i,a,b) for (int i = (a); i <= (b); i++)
#define FR(i,e) for(__typeof(e.begin()) i = e.begin(); x != e.end(); i++)
#define SQR(x) ((x)*(x))
#define REP(i,n) FOR(i,0,n)
#define CLR(a,b) memset(a, b, sizeof(a))
#define INF (1<<29)
#define LL long long
#define PII pair<int,int>
#define PDI pair<double,int>
#define ISS istringstream
#define OSS ostringstream
#define gmin(a,b) { if ( b < a ) a = b; }
#define gmax(a,b) { if ( b > a ) a = b; }

int gcd( int a, int b ) { return b ? gcd( b, a % b ) : a; }

int type[111];

int main() {
  CLR( type, 0 );
  int b = 0, div;
  cin >> b >> div;
  for( int d = 2; d <= b; d++ )
    if ( b % d == 0 ) type[d] = 2;
  for( int d = 2; d <= 100; d++ ) {
    for( int i = 2; i * i <= d; i++ )
      if ( d % i == 0 )
        if ( type[i] == 2 && type[d / i] == 2 ) {
          type[d] = 2;
          break;
        }
    for( int d = 2; d < b; d++ )
      if ( (b - 1) % d == 0) {
        if ( type[d] == 0 ) type[d] = 3;
      }
    for( int d = 2; d <= b + 1; d++ ) {
      if ( (b + 1) % d == 0 && type[d] == 0 ) type[d] = 11;
    }
    for( int d = 2; d <= 100; d++ ) {
      if ( type[d] == 0 ) {
        for( int i = 2; i < d; i++ ) {
          if ( d % i == 0 && d % (i * i)) {
            if ( type[i] == 2 && type[d / i] == 3 ) type[d] = 6;
            if ( type[i] == 2 && type[d / i] == 11 ) type[d] = 22;
            if ( type[i] == 3 && type[d / i] == 11 ) type[d] = 33;
            if ( type[i] == 2 && type[d / i] == 33 ) type[d] = 66;
            if ( type[i] == 3 && type[d / i] == 22 ) type[d] = 66;
            if ( type[i] == 11 && type[d / i] == 66 ) type[d] = 66;
            if ( type[d] ) break;
          }
        }
      }
    }

    for( int i = 2; i <= 100; i++ )
      if ( !type[i] ) type[i] = 7;
      else if ( type[i] == 22 || type[i] == 33 || type[i] == 66 ) type[i] = 6;
  }
  printf( "%d-type\n", type[div] );
  if ( type[div] == 2 ) {
    int cnt = 0, r = gcd( div, b );
    while ( r > 1 ) {
      div /= r;
      cnt++;
      r = gcd( div, b );
    }
    printf( "%d\n", cnt );
  }
  return 0;
}

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cctype>
using namespace std;

int b, d;

int cnt;
bool is2(int nd) {
	cnt = 0;
	for (int i = 2; i <= b; i++) {
		if (b % i == 0) {
			int div = i;
			int cb = 0;
			while (b % i == 0) {
				b /= div;
				cb++;
			}
			int cd = 0;
			while (nd % i == 0) {
				nd /= div;
				cd++;
			}
			cnt = max(cnt, (cd + cb - 1) / cb);
		}
	}
	return nd == 1;
}

int main() {
	cin >> b >> d;
	if ((b - 1) % d == 0) {
		cout << "3-type" << endl;
	} else if ((b + 1) % d == 0) {
		cout << "11-type" << endl;
	} else {
		if (is2(d)) {
			cout << "2-type" << endl << cnt << endl;
			return 0;
		}
		for (int i = 1; i <= d; i++) {
			if (d % i) continue;
			if (is2(d / i) && (((b - 1) % d == 0) || ((b + 1) % d == 0))) {
				cout << "6-type" << endl;
				return 0;
			}
		}
		cout << "7-type" << endl;
	}
}

#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#pragma comment(linker, "/STACK:64000000")

template<class T> inline T sqr (T x) {return x * x;}

typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> pii;
typedef pair<int, pii> pip;
typedef pair<pii, int> ppi;
typedef pair<int64, int> pii64;
typedef pair<double, double> pdd;
typedef pair<double, int> pdi;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
#define next huynext
#define FAIL ++*(int*)0
#define eps  1e-9
#define inf  0x7f7f7f7f
#define MP make_pair
#define sz(C) (int)((C).size())
#define all(C) (C).begin(), (C).end()
#define TASK "codeforces"
#define N 256

bool check2 (int d, int b) {
    int pow = 1 % d;
    for (int i = 1; i <= 1000 * d; ++i) {
        pow = pow * b % d;
        if (pow == 0) return true;
    }
    return false;
}

bool check3 (int d, int b) {
    int pow = 1 % d;
    for (int i = 1; i <= 1000 * d; ++i) {
        pow = pow * b % d;
        if (pow != 1) return false;
    }
    return true;
}

bool check11 (int d, int b) {
    int pow1 = 1 % d;
    int pow2 = b % d;
    if (pow2 != b) return false;
    for (int i = 2; i <= 1000 * d; ++i) {
        int cur = pow2 * b % d;
        if (cur != pow1) return false;
        swap(pow1, pow2);
    }
    return true;
}

char can[128] = {0};
char dp[128];

char rec (int d) {
    if (can[d]) return true;
    char &res = dp[d];
    if (res != -1) return res;
    res = 0;
    for (int i = 1; i * i <= d; ++i) {
        if (d % i) continue;
        if (rec(i) && rec(d / i)) {
            res = true;
            break;
        }
    }
    return res;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int b, d;
    cin >> b >> d;
    if (check2(d, b)) {
        puts("2-type");
        int cnt = 0;
        int pow = 1 % d;
        for (; pow != 0; pow = pow * b % d)
            ++cnt;
        printf("%d\n", cnt);
        return 0;
    }
    if (check3(d, b)) {
        puts("3-type");
        return 0;
    }
    if (check11(d, b)) {
        puts("11-type");
        return 0;
    }
    can[1] = true;
    for (int i = 2; i * i <= d; ++i) {
        if (d % i) continue;
        can[i] = check2(i, b) || check3(i, b) || check11(i, b);
        can[d / i] = check2(d / i, b) || check3(d / i, b) || check11(d / i, b);
    }
    memset(dp, -1, sizeof dp);
    if (rec(d)) {
        puts("6-type");
        return 0;
    }
    puts("7-type");

    return 0;
}

#include <cstdio>
#include <algorithm>
using namespace std;

const int Maxn = 105;

int b, d;
bool two, three, eleven, seven;

bool Test3(int d)
{
	return b % d == 1;
}

bool Test11(int d)
{
	return b % d == d - 1;
}

int Get(int d)
{
	int res, cur = 1;
	for (res = 0; res < Maxn && cur; res++)
		cur = cur * b % d;
	return res;
}

int main()
{
	scanf("%d %d", &b, &d);
	int sav = d;
	for (int i = 2; i <= d; i++)
		if (d % i == 0) {
			int res = 1;
			while (d % i == 0) { res *= i; d /= i; }
			bool tk = false;
			if (Get(res) < Maxn) two = tk = true;
			if (Test3(res)) three = tk = true;
			if (Test11(res)) eleven = tk = true;
			if (!tk) seven = true;
		}
	if (seven) printf("7-type\n");
	else if (two + three + eleven > 1) printf("6-type\n");
	else if (two) printf("2-type\n%d\n", Get(sav));
	else if (three) printf("3-type\n");
	else if (eleven) printf("11-type\n");
	return 0;
}

#include <stdio.h>
#include <string.h>
#include <math.h>
int isprime(int n)
{
	double a=sqrt(n+1.0);
	for(int i=2;i<a;++i)
		if(n%i==0)return false;
	return n!=1;
}
int gcd(int a,int b)
{
	return b?gcd(b,a%b):a;
}
int main()
{
	int b,d;
	scanf("%d%d",&b,&d);
	for(int i=1,t=1;t<(1<<25);++i)
	{
		t*=b;
		if(t%d==0)
		{
			printf("2-type\n%d\n",i);
			return 0;
		}
	}
	if(b%d==1)
	{
		printf("3-type\n");
		return 0;
	}
	for(int i=1,t=1;t<(1<<25);t*=b)
	{
		if((t%d==1&&t*b%d==(d-1))||(t%d==(d-1)&&t*b%d==1))
		{
			printf("11-type\n");
			return 0;
		}
	}
	if(isprime(d)||gcd(b,d)==1)
		printf("7-type\n");
	else
		printf("6-type\n");
	return 0;
}

#include <cstdio>

int cnt[111], ans, b, d, pr[111];

int main(){
	scanf("%d%d", &b, &d);
	int k = b;
	for (int i = 2; k > 1; i++){
		if (k % i) continue;
		while (k % i == 0) cnt[i]++, k /= i;
	}
	bool flag = true; k = d;
	for (int i = 2; k > 1; i++){
		if (k % i) continue;
		if (cnt[i] == 0) flag = false;
		while (k % i == 0) pr[i]++, k /= i;
		int p = (pr[i] - 1) / p + 1;
		if (p > ans) ans = p;
	}
	if (flag) printf("2-type\n%d\n", ans);
	else{
		if (b % d == 1) printf("3-type\n");
		else if ((b + 1) % d == 0) printf("11-type\n");
		else{
			flag = true;
			for (int i = 2; i <= d; i++){
				if (pr[i] == 0 || cnt[i] || b % i == 1 || (b + 1) % i == 0) continue;
				flag = false;
				break;
			}
			if (flag) printf("6-type\n"); else printf("7-type\n");
		}
	}
}

#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
#define maxn 110
int ss[maxn],u[maxn],nss;
int ss_factor[maxn],nss_f;
char str[5][10]={"2-type", "3-type", "11-type", "6-type","7-type"};
int ans[5];
void predeal()
{
    nss=0;
    ss[++nss]=2;
    memset(u,0,sizeof(u));
    for (int i=3;i<maxn;i+=2)
        if (u[i]==0)
        {
            ss[++nss]=i;
            for (int j=i+i;j<maxn;j+=i) u[j]=1;
        }
}
void deal(int b,int d)
{
    int i,cnt=0,y,max=0,t,td,tb;
    memset(ans,0,sizeof(ans));
    for (i=1;i<=nss;i++)
    {
        int x=ss[i];
        if (d%x==0)
        {
           // printf("x:%d\n",x);
            if (b%x==0)
            {
                cnt+=ans[0]^1;
                ans[0]=1;
                td=tb=0;
                for (t=d;t%x==0;t/=x) td++;//d中x因子数
                for (t=b;t%b==0;t/=x) tb++;//b中x因子数
                y=td/tb;
                if (td%tb>0) y++;
                if (y>max) max=y;
            }
            else if ((b-1)%x==0)
            {
                cnt+=ans[1]^1;
                ans[1]=1;
            }
            else if ((b+1)%x==0)
            {
                cnt+=ans[2]^1;
                ans[2]=1;
            }
            else
            {
                cnt+=ans[4]^1;
                ans[4]=1;
            }
        }
    }
    if (ans[4])
    {
        printf("%s\n",str[4]);
        return ;
    }
    if (cnt>1)
    {
        printf("%s\n",str[3]);
        return ;
    }
    if (ans[0])
    {
        printf("%s\n",str[0]);
        printf("%d\n",max);
        return ;
    }
    if ((b-1)%d==0)
    {
        printf("%s\n",str[1]);
        return ;
    }
    if ((b+1)%d==0)
    {
        printf("%s\n",str[2]);
        return ;
    }
    printf("%s\n",str[4]);
}
int main()
{
    int b,d;
    predeal();
    while (scanf("%d%d",&b,&d)==2)
    {
        deal(b,d);
    }
    return 0;
}

// Codeforces Round #116 (Div. 2, ACM-ICPC Rules) B Divisibility Rules

#include <cstdio>

using namespace std;

int main() {
	int b, d;
	scanf("%d%d", &b, &d);

	if (b % d == 1) {
		printf("3-type\n");
		return 0;
	}

	if (b % d == d - 1) {
		printf("11-type\n");
		return 0;
	}

	int ans = -1, cnt = 0;
	for (int i = 2; i <= d; i ++)
		if (d % i == 0) {
			int t = 0;
			int m = 1;
			while (d % i == 0) {
				t ++;
				d /= i;
				m *= i;
			}
			if (b % i == 0) {
				int tt = 1;
				int bb = b;
				while (bb % m != 0) {
					bb *= b;
					tt ++;
				}
				if (tt > cnt) cnt = tt;
				if (ans == -1) {
					ans = 2;
				} else if (ans != 2) {
					ans = 6;
				}
			} else if (b % m == 1) {
				if (ans == -1) {
					ans = 3;
				} else if (ans != 3) {
					ans = 6;
				}
			} else if (b % m == m - 1) {
				if (ans == -1) {
					ans = 11;
				} else if (ans != 11) {
					ans = 6;
				}
			}
			if (ans == 6) break;
		}

	if (ans == -1) ans = 7;
	printf("%d-type\n", ans);
	if (ans == 2) printf("%d\n", cnt);

	return 0;
}

#include <iostream>
#include <cstring>

using namespace std;

int b,d,ans,f[1000];

int gcd(int a,int b)
{
	if (b==0) return a; else return gcd(b,a%b);
}

int lcm(int a,int b)
{
	return a*b/gcd(a,b);
}

int main()
{
	cin>>b>>d;
	if (d==b+1) ans=11; else
	{
		memset(f,127,sizeof(f));
		ans=7;
		f[b+1]=11;
		for (int i=2;i<=b-1;i++)
			if ((b-1)%i==0) f[i]=3;
		for (int i=1;i<=b;i++)
			if (b%i==0) f[i]=2;
		for (int i=1;i<=d;i++)
			for (int j=1;j<=i;j++)
				if ((i%j==0)&&(f[j]==2)&&(f[i/j]==2)) f[i]=2;
		for (int i=1;i<=d-1;i++)
			if (f[i]==3)
				for (int j=1;j<=d-1;j++)
					if (f[j]==11)
						if (((d%lcm(i,j))==0)&&(f[d/lcm(i,j)]==2)) ans=6;
		if ((ans==7)&&(f[d]<100)) ans=f[d];
	}
	cout<<ans<<"-type"<<endl;
	if (ans==2)
	{
		long long k=1;
		for (int i=1;i<=10;i++)
		{
			k=(long long)k*b;
			if (k%d==0)
			{
				cout<<i<<endl;
				return 0;
			}
		}
	}
	return 0;
}

#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

vector<int> go(int b)
{
    vector<int>a;
    for(int i=2;i*i<=b;i++)
    {
        if(b%i==0)
        {
            while(b%i==0) b/=i;
            a.push_back(i);
        }
    }
    if(b>1) a.push_back(b);
    return a;
}

//void go2(const vector<int> &a, int &d)
int go2(vector<int> a, int &d)
{
    int res = 0;
    for(int i=0;i<a.size();i++)
    {
        int k = 0;
        cerr << a[i]<<endl;
        while(d%a[i]==0)
        {
            d/=a[i];
            k++;
        }
        if(k>res) res = k;
    }
    return res;
    cerr <<endl<<endl;
}

int main()
{
    int b,d;
    cin >> b >>d;
    int fl2 = go2(go(b),d);
    int fl3 = go2(go(b-1),d);
    int fl11 = go2(go(b+1),d);
    if(d>1){cout <<"7-type"<<endl; return 0;}
    if(fl3 + fl11 ==0){cout << "2-type"<<endl<<fl2<<endl; return 0;}
    if(fl2 + fl11 ==0){cout << "3-type"<<endl; return 0;}
    if(fl2 + fl3 ==0){cout << "11-type"<<endl; return 0;}
    cout << "6-type"<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int b;
struct num{
	int a[10];
	void dr(){
		memset(a,0,sizeof(a));
		int k;
		scanf("%d",&k);
		while(k) a[++a[0]]=k%b,k/=b;
	}

}d,bb;

num turnum(int s){
	num ss;
	ss.a[0]=0;
	while(s) ss.a[++ss.a[0]]=s%b,s/=b;
	return ss;
}

int turint(num s){
	int k=0,l=1;
	for(int i=1;i<=s.a[0];i++){
		k+=s.a[i]*l;
		l*=b;
	}
	return k;
}

int mod(num x,num y){
	int xt,yt;
	xt=turint(x),yt=turint(y);
	int mm=yt%xt;
	return mm;
}

num nod(num x,num y){
	int xt,yt;
	xt=turint(x),yt=turint(y);
	int mm=yt%xt;
	return turnum(mm);
}

int type2(num u){
	int uu=turint(u);
	int cnt=0;
	for(int i=b;i>1;i--){
		if(b%i==0){
			while(uu%i==0) cnt++,uu/=i;
		}
	}
	if(uu==1) return cnt;
	else return 0;
}

bool type3(num u){
	num t=turnum(b-1);
	int ss=mod(u,t);
	if(ss==0) return true;
	return false;
}

bool type11(num u){
	int uu=turint(u);
	if((b+1)%uu==0) return true;
	return false;
}

bool type6(num u){
	bool flag=(type2(u)&type3(u))|(type2(u)&type11(u));
	return flag;
}

int main(){
	scanf("%d",&b);
	bb=turnum(b);
	int dd;
	scanf("%d",&dd);
	d=turnum(dd);
	if(type6(d)) printf("6-type");
	else if(type2(d)){
		int k=type2(d);
		printf("2-type\n%d",k);
	}
	else if(type3(d)) printf("3-type");
	else if(type11(d)) printf("11-type");
	else printf("7-type");
}

#include <cstdio>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

int gcd (int x, int y) { return y ? gcd(y, x % y) : x; }

int gtype (int base, int divi, int &num)
{
	if (divi == 1) { num = 0; return 2; }
	set<int> st;
	for (int i = 1, cr = 1; ; ++i)
	{
		cr = cr * base % divi;
		if (!cr) { num = i; return 2; }
		if (st.find(cr) != st.end()) break;
		st.insert(cr);
	}
	if (st.size() == 1) return 3;
	else if (st.size() == 2 && (*st.begin() + *++st.begin()) % divi == 0) return 11;
	for (int i = 2; i < divi; ++i)
		if (divi % i == 0 && gcd(i, divi / i) == 1)
			if (gtype(base, i, num) != 7 && gtype(base, divi / i, num) != 7)
				return 6;
	return 7;
}

int main ()
{
	int x, y, num, t;
	scanf("%d%d", &x, &y);
	printf("%d-type\n", t = gtype(x, y, num));
	if (t == 2) printf("%d\n", num);
	return 0;
}

#include<cstdio>
#include<cstring>

bool ok[110];

int sum(int n,int base)
{
    int ans=0;
    while(n)
    {
        ans+=n%base;
        n/=base;
    }
    return ans;
}

bool istype2(int a,int base)
{
	for(int i=00;i<=a;i++)
		ok[i]=0;
	int k=base%a;
	ok[k]=1;
	for(int i=1;i<=a;i++)
	{
		k=k*k%a;
		if(k==0)
			return true;
		if(ok[k])
			break;
		ok[k]=1;
	}
	return false;
}

bool istype3(int a,int base)
{
	for(int k=1;k<=base;k++)
	{
		if(sum(k*a,base)%a!=0)
			return false;
	}
	return true;
}

bool istype11(int a,int base)
{
	return a==base+1;
}

int main()
{
	int a,b;
	scanf("%d%d",&b,&a);
	bool type2=0;
	bool type3=0;
	bool type11=0;
	for(int i=2;i<=a;i++)
	{
	    if(a%i==0)
	    {
	        type2|=istype2(i,b);
	        type3|=istype3(i,b);
	        type11|=istype11(i,b);
	    }
	}
	int tot=type2+type3+type11;
	if(tot==0)
		printf("7-type\n");
	else if(tot>=2)
		printf("6-type\n");
	else
	{
		if(type2)
			printf("2-type\n");
		if(type3)
			printf("3-type\n");
		if(type11)
			printf("11-type\n");
	}
	return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <map>
using namespace std;

int main()
{
	int b, d;
	cin >> b >> d;
	if(d == b + 1)
	{
		cout << "11-type\n";
		return 0;
	}
	int i;
/*	for(i = b; i >= 2; i--)
	{
		if(b % i == 0)
		{
		}
	}*/
			int t = b;
			int k = 1;
			while(t < 10000000 && t % d != 0)
			{
				t *= b;
				k++;
			}
			if(t % d == 0)
			{
				cout << "2-type\n" << k << endl;
				return 0;
			}

	if(b % d == 1)
	{
		cout << "3-type\n";
		return 0;
	}
	bool ok = true;
	int s = 0;
	for(i = 2; i <= d; i++)
	{
		while(d % i == 0)
		{
			if(!(i == b + 1 || b % i == 0 || b % i == 1))
			{
				ok = false;
			}
			if(b % i == 1) s++;
			if(s > 1)
			{
				ok = false;
			}
//			cout << i << endl;
			d /= i;
		}
	}
	if(ok)
	{
		cout << "6-type\n";
		return 0;
	}
	cout << "7-type\n";
	return 0;
}

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int b,d;
int a[100],n=0,t[100],t2=0;
int ty[20];
int gcd(const int x,const int y)
{
	return y==0?x:gcd(y,x%y);
}
int main()
{
	scanf("%d%d",&b,&d);
	memset(ty,0,sizeof(ty));
	for(int i=2;i<=d;++i)
	if ( d%i==0 )
	{
		a[++n]=1;t[n]=0;
		while ( d%i==0 ) a[n]*=i,d/=i;
	}
	for(int i=1;i<=n;++i)
	{
		bool kk=0;
		if ( b%a[i]==a[i]-1 )
		{
			++ty[11];
			kk=1;
		}
		if ( b%a[i]==1 )
		{
			++ty[3]=1;
			kk=1;
		}
		if ( gcd(a[i],b)>1 )
		{
			int p=0;
			while ( a[i]>1 ) a[i]/=gcd(a[i],b),++p;
			if ( p>t2 ) t2=p;
			++ty[2];
			kk=1;
		}
		if ( !kk ) ty[7]=1;
	}
	if ( ty[7]>0 )
	{
		puts("7-type");
	}
	else if ( ty[2]==n ) puts("2-type"),cout<<t2<<endl;
	else if ( ty[3]==n ) puts("3-type");
	else if ( ty[11]==n ) puts("11-type");
	else	{
		int p=0;
		p=(ty[2]>0)+(ty[3]>0)+(ty[11]>0);
		if ( p>1 )	puts("6-type");
		else if ( ty[2]>0 )	puts("2-type"),	cout<<t2<<endl;
		else if ( ty[3]>0 )	puts("3-type");
		else puts("11-type");
	}
	return 0;
}

#include <stdio.h>
bool ok(int b,int d)
{
    if (b%d==0) return true;
    if ((b+1)%d==0) return true;
    int now=1;
    for (int i=0;i<d+10;i++)
    {
        now=(now*b)%d;
        if (now==0) return true;
    }
    return false;
}
int main()
{
    int b,d;
    while (scanf("%d%d",&b,&d)==2)
    {
        if (b%d==1) puts("3-type");
        else if ((b+1)%d==0) puts("11-type");
        else
        {
            bool find=false;
            int now=1,cnt=0;
            for (int i=0;i<d+10;i++)
            {
                now=(now*b)%d;
                if (now==0)
                {
                    find=true;
                    cnt=i+1;
                    break;
                }
            }
            if (find)
            {
                puts("2-type");
                printf("%d\n",cnt);
            }
            else
            {
                bool bad=false;
                int td=d;
                for (int i=2;i<=d;i++)
                {
                    if (td%i==0)
                        if (!ok(b,i)) bad=true;
                        else
                        {
                            while (td%i==0) td/=i;
                        }
                }
                if (bad) puts("7-type");
                else puts("6-type");
            }
        }
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
void factor(int x,vector<pair<int,int> > &s){
	for(int i=2;i*i<=x;i++)
	if(x%i==0){
		s.push_back(make_pair(i,0));
		int now=s.size()-1;
		while(x%i==0)
			x/=i,s[now].second++;
	}
	if(x>1)
		s.push_back(make_pair(x,0));
}
int power(int a,int b){
	int ret=1;
	while(b){
		if(b&1)
			ret*=a;
		a*=a;
		b>>=1;
	}
	return ret;
}
int eular(int d){
	int ret=d;
	for(int i=2;i*i<=d;i++)
	if(d%i==0){
		ret=ret/i*(i-1);
		while(d%i==0)
			d/=i;
	}
	if(d)
		ret--;
	return ret;
}
int for2;
bool check2(int b,int d){
	int lim=eular(d);
	int scp=1;
	for(int i=0;i<lim;i++){
        if(scp%d==0){
			for2=i;
			return true;
        }
        scp=scp*b%d;
	}
	return false;
}
int check(int b,int d,bool ch7){
	vector<pair<int,int> > bf,df;
	factor(b,bf);
    factor(d,df);
	if((b-1)%d==0)
		return 3;
    else if((b+1)%d==0)
		return 11;
	else if(check2(b,d))
		return 2;
	else if(ch7){
		for(int i=0;i<df.size();i++){
			pair<int,int> pa=df[i];
			if(check(b,power(pa.first,pa.second),false)==6)
				return 7;
		}
	}
	return 6;
}
int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif // ONLINE_JUDGE
	int b,d;
	scanf("%d%d",&b,&d);
	int ans=check(b,d,true);
    printf("%d-type\n",ans);
    if(ans==2)
		printf("%d\n",for2);
	return 0;
}

#include <iostream>
#include <vector>
using namespace std;
int dp[101];
int pow(int b, int j){
	if(j==0)
		return 1;
	return b*pow(b,j-1);
}
int main(){
	int b,d;
	cin >> b >> d;
	for(int i = 2; i <= 100; ++i){
		dp[i]=7;
		for(int j = 1; j < 10; ++j){
			if(pow(b,j)%i==0)
				dp[i]=2;
		}
		if(dp[i]!=7) continue;
		if(b%i==1 || (b%i)==(i-1)){
			dp[i]=3;
			continue;
		}
		if(b%d==d-1 && ((d-1)*b)%d==1){
			dp[i]=11;
			continue;
		}
		vector<int> divs;
		int m = i;
		for(int j = 2; j <= 100; ++j){
			int cur = 1;
			while(m%j==0){
				cur*=j;
				m/=j;
			}
			if(cur>1)
				divs.push_back(cur);
		}
		bool ok = true;
		for(int j = 0; j < divs.size(); ++j)
			if(dp[divs[j]]==7){
				ok=false;
			}
		if(ok)
			dp[i]=6;
		else
			dp[i]=7;
	}
	cout << dp[d] << "-type\n";
	if(dp[d]==2)
		for(int i = 0; i < 10; ++i)
			if(pow(b,i)%d==0){
				cout << i << '\n';
				return 0;
			}
}

#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
int power(int fac, int d) {
    int ans = 0;
    while(d > 1) {
        d /= fac;
        ans++;
    }
    return ans;
}
bool perfect_power(int fac, int d) {
    bool ans = true;
    while(d > 1 and ans) {
        ans &= d % fac == 0;
        d /= fac;
    }
    return ans;
}
int type2(int b, int d) {
    set<int> b_factors;
    for(int i = 2; i <= b; i++) {
        if(b % i == 0) {
            b_factors.insert(i);
        }
    }
    int ans = 0;
    for(int fac : b_factors) {
        if(perfect_power(fac, d)) {
            ans = fac;
        }
    }
    return ans;
}
bool type3(int b, int d) {
    return b % d == 1;
}
bool type11(int b, int d) {
    return d == b + 1;
}
bool type6(int b, int d) {
    bool ans = true;
    bool has_proper_divisor = false;
    for(int i = 2; i < d; i++) {
        if(d % i == 0) {
            ans &= (type2(b, i) or type3(b, i) or type11(b, i)) and type6(b, d / i);
            has_proper_divisor = true;
        }
    }
    return ans and has_proper_divisor;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int b, d;
    cin >> b >> d;
    vector<int> types;
    int type2_fac;
    if(type2_fac = type2(b, d)) {
        types.push_back(2);
    }
    if(type3(b, d)) {
        types.push_back(3);
    }
    if(type11(b, d)) {
        types.push_back(11);
    }
    if(type6(b, d)) {
        types.push_back(6);
    }
    if(types.empty()) {
        cout << "7-type" << endl;
    } else {
        cout << types[0] << "-type" << endl;
        if(types[0] == 2) {
            cout << power(type2_fac, d) << endl;
        }
    }
    return 0;
}

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define P // system("pause")
using namespace std ;
typedef long long LL ;

LL b, d ;
int dp[150] ;

int Dfs(LL x)
{
	int i ;
	LL tmp ;
	if(dp[x]) return dp[x] ;
	for(i = 1, tmp = b; i <= 7; i ++, tmp *= b)
		if(tmp%x == 0) return dp[x] = 1 ;
	if(b%x == 1) return dp[x] = 1 ;
	if(b%x == x-1) return dp[x] = 1 ;
	for(i = 2; i < x; i ++)
		if(x%i==0 && Dfs(i) && Dfs(x/i)) return dp[x] = 1 ;
	return dp[x] = -1 ;
}

int main()
{
	int i, j ;
	LL tmp ;
	scanf("%I64d %I64d", &b, &d) ;
	for(i = 1, tmp = b; i <= 7; i ++, tmp *= b)
		if(tmp%d == 0)
		{
			printf("2-type\n%d\n", i) ;
			P ;
			exit(0) ;
		}
	if(b%d == 1)
	{
		printf("3-type\n") ;
		P ;
		exit(0) ;
	}
	if(b%d == d-1)
	{
		printf("11-type\n") ;
		P ;
		exit(0) ;
	}
	if(Dfs(d) > 0)
	{
		printf("6-type\n") ;
		P ;
		exit(0) ;
	}
	else
	{
		printf("7-type\n") ;
		P ;
		exit(0) ;
	}

}

#pragma comment(linker, "/STACK:256000000")

#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <ctime>
#include <math.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <algorithm>

using namespace std;

template<class T>
double sqrt(T x)
{
	return sqrt((double) x);
}

template<class T>
T sqr (T x)
{
	return x*x;
}

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define X first
#define Y second
#define pb push_back
#define mp make_pair
//#define foreach(e,x) for(__typeof(x.begin()) e=x.begin();e!=x.end();++e)

const double PI = acos(-1.0);
const int INF = 1000000000;
const int MOD = 1000000007;

//#define ONLINE_JUDGE

bool up(char c)
{
	if ( c >= 'A' && c <= 'Z' ) return 1;
	return 0;
}

int b,d,last;
vector<int> r;

vector<int> getr(int b, int d, int& last)
{
	vector<int> r;
	r.resize(1);
	r[0] = 1;
	for(int x = 0 ; ; x++)
	{
		int t = (r[r.size()-1] * b) % d;

		for (int y = 0 ; y < r.size() ; y++)
			if ( r[y] == t )
			{
				last = t;
				goto end1;

			}

		r.pb(t);

	}
	end1:;

	return r;
}

bool is2(int num,int& a)
{
	int last = 0;
	vector<int> r =getr(b,num,last);
	if ( last == 0 )
	{
		a = r.size()-1;
		return 1;
	}

	return 0;
}

bool is3(int num)
{
	int last = 0;
	vector<int> r =getr(b,num,last);
	if ( last == 1 && r.size() == 1 ) return 1;
	return 0;
}

bool is11(int num)
{
	int last = 0;
	vector<int> r =getr(b,num,last);

	if ( r.size() == 2 && last==1 && r[1] == num-1 ) return 1;
	return 0;
}

bool is6()
{
	map<int,int> dt;
	int td = d;
	int uo;
	for (int x = 2 ; x * x <= d;  x++)
	{
		while(d%x==0)
		{
			dt[x]++;
			d /= x;
		}
	}

	if ( d != 1 ) dt[d]++;

	d = td;

	if ( dt.size() == 0 || dt.size() == 1 ) return 0;

	for (map<int,int>::iterator it = dt.begin() ; it != dt.end() ; it++)
	{
		if ( it->Y != 1  || (!is2(it->X,td) && !is3(it->X) && !is11(it->X))) return 0;
	}

	return 1;
}

int main()
{
	double TIME_START = clock();
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
#endif

	while(cin >> b >> d)
	{

	r.resize(1);
	r[0] = 1;
	for(int x = 0 ; ; x++)
	{
		int t = (r[r.size()-1] * b) % d;

		for (int y = 0 ; y < r.size() ; y++)
			if ( r[y] == t )
			{
				last = t;
				goto end;

			}

		r.pb(t);

	}

end:;

	eprintf("TEST %d %d\n",b,d);

	int tpp=0;
	if ( is2(d,tpp) ) printf("2-type\n%d",tpp);
	else
		if ( is3(d) ) printf("3-type");
		else if ( is11(d) ) printf("11-type");
		else
			if ( is6() ) printf("6-type");
		else
		{
			if ( r.size() != d ) *((int*)0);
			printf("7-type");
		}

		eprintf("\n");
	for (int x = 0 ; x < r.size() ; x++) eprintf("%d ", r[x]);
		eprintf("\n\n\n");
		//printf("\n");

	}

	return 0;

	if ( last == 0 )
	{
		int dd = 0;

		printf("2-type\n%d",r.size()-1);
	} else
	{
		if ( last == 1 && r.size() == 1 ) printf("3-type");
		else
		{
			int o=0,i=0;
			for (int x = 0 ; x < r.size() ; x++)
			{
				if ( r[x] == d-1 ) o++;
				else i++;
			}

			int ans = 100500;
			if ( i + o == r.size() ) ans = 11;

			for (int x = 2 ; x * x <= d ; x++)
			{
				if ( d % x == 0 )
				{
					ans = min(ans,6);
					break;
				}
			}

			if ( ans == 100500 ) ans = 7;
			printf("%d-type",ans);
		}
	}

	eprintf("\n\n%.15lf\n\n",(double)(clock() - TIME_START)/CLOCKS_PER_SEC);
	return 0;
}

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
using namespace std;
typedef long long lld;
#define mp make_pair
#define X first
#define Y second
#define pb push_back
#define inf 0xfffffff
bool isprime(int x)
{
    for(int i=2;i*i<=x;i++)
        if(x%i == 0)
            return false;
    return true;
}
vector<int>p2;
vector<int>p3;
vector<int>p11;
vector<int>p6;
vector<int> solve(int x)
{
    vector<int>g;
    g.clear();
    for(int i=2;i*i<=x;i++)
        if(x%i == 0)
        {
            while(x%i == 0)
            {
                g.pb(i);
                x/=i;
            }
        }
    if(x != 0)
        g.pb(x);
    return g;
}
int ok(vector<int>g,int x)
{
    int t=-1;
    while(1)
    {
        t++;
        int mark=x;
        for(vector<int>::iterator ll=g.begin();ll != g.end();ll++)
            if(x%(*ll) == 0)
                x/=*ll;
        if(mark == x)
            break;
    }
    if(x == 1)
        return t;
    else
        return -1;
}
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    p2=solve(a);
    p11=solve(a+1);
    p3=solve(a-1);
    p6.clear();
    for(vector<int>::iterator ll=p2.begin();ll != p2.end();ll++)
        p6.pb(*ll);
    for(vector<int>::iterator ll=p11.begin();ll != p11.end();ll++)
        p6.pb(*ll);
    for(vector<int>::iterator ll=p3.begin();ll != p3.end();ll++)
        p6.pb(*ll);
    if(ok(p2,b) != -1)
    {
        printf("2-type\n");
        printf("%d\n",ok(p2,b));
    }
    else if(ok(p11,b) != -1)
        printf("11-type\n");
    else if(ok(p3,b) != -1)
        printf("3-type\n");
    else if(ok(p6,b) != -1)
        printf("6-type\n");
    else
        printf("7-type\n");
    return 0;
}

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
using namespace std;
typedef long long lld;
#define mp make_pair
#define X first
#define Y second
#define pb push_back
#define inf 0xfffffff
bool isprime(int x)
{
    for(int i=2;i*i<=x;i++)
        if(x%i == 0)
            return false;
    return true;
}
vector<int>p2;
vector<int>p3;
vector<int>p11;
vector<int>p6;
vector<int> solve(int x)
{
    vector<int>g;
    g.clear();
    for(int i=2;i*i<=x;i++)
        if(x%i == 0)
        {
            g.pb(i);
            while(x%i == 0)
                x/=i;
        }
    if(x != 0)
        g.pb(x);
    return g;
}
int ok(vector<int>g,int x)
{
    int t=-1;
    while(1)
    {
        t++;
        int mark=x;
        for(vector<int>::iterator ll=g.begin();ll != g.end();ll++)
            if(x%(*ll) == 0)
                x/=*ll;
        if(mark == x)
            break;
    }
    if(x == 1)
        return t;
    else
        return -1;
}
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    p2=solve(a);
    p11=solve(a+1);
    p3=solve(a-1);
    p6.clear();
    for(vector<int>::iterator ll=p2.begin();ll != p2.end();ll++)
        p6.pb(*ll);
    for(vector<int>::iterator ll=p11.begin();ll != p11.end();ll++)
        p6.pb(*ll);
    for(vector<int>::iterator ll=p3.begin();ll != p3.end();ll++)
        p6.pb(*ll);
    if(ok(p2,b) != -1)
    {
        printf("2-type\n");
        printf("%d\n",ok(p2,b));
    }
    else if(ok(p11,b) != -1)
        printf("11-type\n");
    else if(ok(p3,b) != -1)
        printf("3-type\n");
    else if(ok(p6,b) != -1)
        printf("6-type\n");
    else
        printf("7-type\n");
    return 0;
}