#include <bits/stdc++.h>
using namespace std;
int prime[29] = {0,  2,  3,  5,  7,  11, 13, 17, 19, 23, 29, 31, 37,
                 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
int b, d;
int i, j, k, l, q;
bool ist2[105];
int min2[105];
int pp[105];
int gcd(int x, int y) {
  int r;
  while (y) {
    r = x % y;
    x = y;
    y = r;
  }
  return x;
}
int main() {
  cin >> b >> d;
  l = 0;
  for (i = 1; i <= 25; i++)
    if (b % prime[i] == 0) pp[++l] = prime[i];
  ist2[1] = true;
  min2[1] = 0;
  for (i = 1; i <= l; i++) {
    for (k = 1; k * pp[i] <= 100; k++)
      if (ist2[k]) ist2[k * pp[i]] = true;
  }
  if (ist2[d]) {
    j = 0;
    k = 1;
    while (k) {
      j++;
      k = (k * b) % d;
    }
    printf("2-type\n%d", j);
  } else if (b % d == 1)
    printf("3-type");
  else if ((b + 1) % d == 0)
    printf("11-type");
  else {
    for (i = 1; i <= d; i++)
      if (ist2[i] && d % i == 0) {
        for (j = 1; j <= d; j++)
          if ((b - 1) % j == 0 && d % (i * j) == 0 && gcd(i, j) == 1) {
            if (gcd(i, d / (i * j)) == 1 && gcd(j, d / (i * j)) == 1)
              if ((b + 1) % (d / (i * j)) == 0) {
                printf("6-type");
                return 0;
              }
          }
      }
    printf("7-type");
  }
  return 0;
}
