#include <bits/stdc++.h>
using namespace std;
const int MAXN = -1;
map<int, int> fact(int n) {
  map<int, int> F;
  for (int p = 2; p * p <= n; p++) {
    while (n % p == 0) F[p]++, n /= p;
  }
  if (n > 1) F[n]++;
  return F;
}
int ans2 = -1;
map<int, int> B, N;
bool check2(int n) {
  N = fact(n);
  ans2 = 0;
  for (pair<int, int> t : N) {
    if (!B.count(t.first)) return false;
    ans2 = max(ans2, (t.second + B[t.first] - 1) / B[t.first]);
  }
  return true;
}
int b;
bool check3(int n) { return (b - 1) % n == 0; }
bool check11(int n) { return (b + 1) % n == 0; }
vector<int> V;
bool check6(int n) {
  V.clear();
  N = fact(n);
  for (pair<int, int> t : N) {
    int val = 1;
    for (int _ = (0); _ < (int)(t.second); _++) val *= t.first;
    V.push_back(val);
  }
  for (int v : V) {
    bool wk = false;
    if (check2(v)) wk = true;
    if (check3(v)) wk = true;
    if (check11(v)) wk = true;
    if (!wk) return false;
  }
  return true;
}
int n;
int main() {
  while (scanf("%d %d", &b, &n) >= 1) {
    B = fact(b);
    if (check2(n)) {
      printf("2-type\n%d\n", ans2);
      continue;
    }
    if (check3(n)) {
      printf("3-type\n");
      continue;
    }
    if (check11(n)) {
      printf("11-type\n");
      continue;
    }
    if (check6(n)) {
      printf("6-type\n");
      continue;
    }
    printf("7-type\n");
  }
  return 0;
}
