#include <bits/stdc++.h>
using namespace std;
int cnt[1010], B, D, ans = 1;
int main() {
  cin >> B >> D;
  int 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 % D == 1)
    cout << "3-type" << endl;
  else if (B % D == D - 1)
    cout << "11-type" << endl;
  else {
    for (int i = 2; i * i <= D; i++) {
      while (D % i == 0) {
        D /= i;
        cnt[i]++;
      }
    }
    if (D > 1) cnt[D]++;
    bool flag = true;
    for (int i = 2; i < 1010; i++)
      if (cnt[i]) {
        int tmp = 1;
        if (B % i == 0) continue;
        while (cnt[i]-- > 0) tmp *= i;
        if (B % tmp != 1 && B % tmp != tmp - 1) flag = false;
      }
    if (flag)
      cout << "6-type" << endl;
    else
      cout << "7-type" << endl;
  }
  return 0;
}
