#include <bits/stdc++.h>
using namespace std;
int b, d, n;
bool type2(int d) {
  int a = b;
  for (n = 1; n < 100; n++) {
    if (a % d == 0) return 1;
    a = (a * b) % d;
  }
  return 0;
}
bool type3(int d) { return b % d == 1; }
bool type11(int d) { return b % d == d - 1; }
int gcd(int a, int b) {
  if (!b) return a;
  return gcd(b, a % b);
}
bool type6(int d) {
  if (type2(d) || type3(d) || type11(d)) return 1;
  for (int i = 2; i * i <= d; i++)
    if (d % i == 0 && gcd(i, d / i) == 1) {
      if (type6(i) && type6(d / i)) return 1;
    }
  return 0;
}
int main() {
  scanf("%d%d", &b, &d);
  if (type2(d))
    printf("2-type\n%d\n", n);
  else if (type3(d))
    printf("3-type\n");
  else if (type11(d))
    printf("11-type\n");
  else if (type6(d))
    printf("6-type\n");
  else
    printf("7-type\n");
  return 0;
}
