#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) { return x ? gcd(y % x, x) : y; }
int b, d;
int p[100], q[100], r[100], up[100], n = 0;
const int INF = 1999;
int chk2() {
  int b2 = 0;
  for (int j = (0); j < (int)(n); j++) {
    if (b % p[j] == 0) {
      int t2 = q[j] / up[j] + (q[j] % up[j] > 0);
      b2 = max(b2, t2);
    } else {
      return INF;
    }
  }
  return b2;
}
int chk3() {
  for (int j = (0); j < (int)(n); j++) {
    if (b % r[j] != 1) return 0;
  }
  return 1;
}
int chk11() {
  for (int j = (0); j < (int)(n); j++) {
    if (b % r[j] != r[j] - 1) return 0;
  }
  return 1;
}
int chk6() {
  for (int j = (0); j < (int)(n); j++) {
    if (b % p[j] == 0) continue;
    if (b % r[j] == 1) continue;
    if (b % r[j] == r[j] - 1) continue;
    return 0;
  }
  return 1;
}
int main() {
  while (cin >> b >> d) {
    n = 0;
    for (int i = 2; i * i <= d; i++) {
      if (d % i == 0) {
        p[n] = i;
        q[n] = 0;
        r[n] = 1;
        while (d % i == 0) {
          q[n]++;
          r[n] *= i;
          d /= i;
        }
        int x = b;
        up[n] = 0;
        while (x % i == 0) {
          up[n]++;
          x /= i;
        }
        n++;
      }
    }
    if (d > 1) {
      p[n] = r[n] = d;
      q[n] = 1;
      int x = b;
      up[n] = 0;
      while (x % d == 0) {
        up[n]++;
        x /= d;
      }
      n++;
    }
    int b2 = chk2();
    if (b2 != INF) {
      cout << "2-type" << endl << b2 << endl;
    } else if (chk3()) {
      cout << "3-type" << endl;
    } else if (chk11()) {
      cout << "11-type" << endl;
    } else if (chk6()) {
      cout << "6-type" << endl;
    } else {
      cout << "7-type" << endl;
    }
  }
  return 0;
}
