#include <bits/stdc++.h>
int b, d;
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
bool type2(int b, int d) {
  int ans = 0;
  while (gcd(b, d) != 1) d /= gcd(b, d), ans++;
  if (d != 1)
    return 0;
  else {
    printf("2-type\n%d\n", ans);
    return 1;
  }
}
bool type3(int b, int d) {
  if ((b - 1) % d)
    return 0;
  else {
    puts("3-type");
    return 1;
  }
}
bool type11(int b, int d) {
  if ((b + 1) % d)
    return 0;
  else {
    puts("11-type");
    return 1;
  }
}
bool type6(int b, int d) {
  d /= gcd(b + 1, d) * gcd(b - 1, d) / gcd(gcd(b + 1, d), gcd(b - 1, d));
  while (gcd(b, d) != 1) d /= gcd(b, d);
  if (d != 1)
    return 0;
  else {
    puts("6-type");
    return 1;
  }
}
int main() {
  scanf("%d%d", &b, &d);
  if (type2(b, d)) return 0;
  if (type3(b, d)) return 0;
  if (type11(b, d)) return 0;
  if (type6(b, d)) return 0;
  puts("7-type");
}
