#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
const int INF = 1000 * 1000 * 1000;
const long long LINF = 1000000000000000000LL;
const double eps = 1e-9;
void prepare() {}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
bool good11(int b, int d) { return (b % d == d - 1); }
bool used[150];
bool can(int b, int d) {
  memset((used), false, sizeof(used));
  int k = 1;
  int x = b;
  x %= d;
  while (x != 0) {
    if (used[x]) break;
    used[x] = true;
    x *= b;
    x %= d;
    k++;
  }
  if (x == 0) {
    return true;
  } else {
    if (b % d == 1) {
      return true;
    } else {
      if (good11(b, d)) {
        return true;
      } else {
        return false;
      }
    }
  }
}
bool solve() {
  int b, d;
  cin >> b >> d;
  int k = 1;
  int x = b;
  x %= d;
  while (x != 0) {
    if (used[x]) break;
    used[x] = true;
    x *= b;
    x %= d;
    k++;
  }
  if (x == 0) {
    printf("2-type\n");
    printf("%d\n", k);
  } else {
    if (b % d == 1) {
      printf("3-type\n");
    } else {
      if (good11(b, d)) {
        printf("11-type\n");
      } else {
        bool ok = true;
        for (int i = 2; i * i <= d; i++) {
          if (d % i == 0) {
            int cur = 1;
            while (d % i == 0) {
              d /= i;
              cur *= i;
            }
            if (!can(b, cur)) {
              printf("7-type\n");
              return false;
            }
          }
        }
        if (d == 1 || can(b, d))
          printf("6-type\n");
        else
          printf("7-type\n");
      }
    }
  }
  return false;
}
int main() {
  prepare();
  while (solve())
    ;
  return 0;
}
