#include <bits/stdc++.h>
using namespace std;
int n, m, f, g, prime[1000], cnt, flag, last = -1;
void get_prime() {
  prime[++cnt] = 2;
  for (int i = 3; i <= 1000; i += 2) {
    for (int j = 2; j <= sqrt(i); j++)
      if (i % j == 0) break;
    prime[++cnt] = i;
  }
}
int t1(int a, int b) {
  f = 1;
  for (int i = 1; i <= 1000; i++) {
    g = f * a % b;
    if (g == 0) return i;
    f = g;
  }
  return 0;
}
int t2(int a, int b) {
  if (a % b == 1) return 1;
  return 0;
}
int t3(int a, int b) {
  if (a % b == b - 1) return 1;
  return 0;
}
int main() {
  scanf("%d %d", &n, &m);
  if (f = t1(n, m))
    printf("2-type\n%d\n", f);
  else if (t2(n, m))
    printf("3-type\n");
  else if (t3(n, m))
    printf("11-type\n");
  else {
    get_prime();
    for (int i = 1; i <= cnt; i++) {
      if (m % prime[i] == 0) {
        if (!t1(n, prime[i]) && !t2(n, prime[i]) && !t3(n, prime[i])) {
          printf("7-type\n");
          return 0;
        }
        if (i != last) flag++, last = i;
        m /= prime[i], i--;
      }
    }
    if (flag >= 2)
      printf("6-type\n");
    else
      printf("7-type\n");
  }
  return 0;
}
