#include <bits/stdc++.h>
const int N = 100010;
const int inf = 0x3f3f3f3f;
using namespace std;
int ans = -1;
bool type2(int b, int d) {
  int ret = b % d;
  for (int i = 0; i < 100; i++) {
    if (ret == 0) {
      ans = i + 1;
      return 1;
    }
    ret = ret * b % d;
  }
  return 0;
}
bool type3(int b, int d) { return b % d == 1; }
bool type11(int b, int d) { return b % d == d - 1; }
bool type6(int b, int d) {
  int cnt[N] = {0}, t = 0;
  for (int i = 2; i * i < d; i++) {
    if (d % i) continue;
    while (d % i == 0) cnt[i]++, d /= i;
  }
  cnt[d]++;
  for (int i = 2; i < N; i++) {
    if (cnt[i] == 0) continue;
    int tmp = 1;
    while (cnt[i]) tmp *= i, cnt[i]--;
    if (!(type2(b, tmp) || type3(b, tmp) || type11(b, tmp))) return 0;
  }
  return 1;
}
int main() {
  int b, d;
  scanf("%d%d", &b, &d);
  if (type2(b, d))
    printf("2-type\n%d\n", ans);
  else if (type3(b, d))
    printf("3-type\n");
  else if (type11(b, d))
    printf("11-type\n");
  else if (type6(b, d))
    printf("6-type\n");
  else
    printf("7-type\n");
  return 0;
}
