#include <bits/stdc++.h>
using namespace std;
bool ch2(int b, int d, int &mv) {
  for (int i = 2; d > 1; ++i)
    if (d % i == 0) {
      if (b % i) return 0;
      int c1 = 0, c2 = 0;
      while (d % i == 0) d /= i, ++c1;
      while (b % i == 0) b /= i, ++c2;
      mv = max(mv, (c1 + c2 - 1) / c2);
    }
  return 1;
}
bool ch3(int b, int d) { return b % d == 1; }
bool ch11(int b, int d) { return b % d == d - 1; }
int pr[9];
bool ch6(int b, int d) {
  int N = 0, rem = 1;
  for (int i = 2; d > 1; ++i)
    if (d % i == 0) {
      if (b % i) {
        pr[N] = 1;
        while (d % i == 0) d /= i, pr[N] *= i, rem *= i;
        ++N;
      } else {
        while (d % i == 0) d /= i;
      }
    }
  if (ch3(b, rem) || ch11(b, rem)) return 1;
  for (int i = 0; i < N; ++i) {
    if (ch3(b, pr[i]) && ch11(b, rem / pr[i])) return 1;
    if (ch3(b, rem / pr[i]) && ch11(b, pr[i])) return 1;
  }
  return 0;
}
int main() {
  int b, d;
  while (scanf("%d%d", &b, &d) != EOF) {
    int mv = -1;
    if (ch2(b, d, mv)) {
      printf("2-type\n%d\n", mv);
    } else if (ch3(b, d))
      puts("3-type");
    else if (ch11(b, d))
      puts("11-type");
    else if (ch6(b, d))
      puts("6-type");
    else
      puts("7-type");
  }
  return 0;
}
