#include <bits/stdc++.h>
using namespace std;
long long prime[30] = {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};
long long b, d, flag = 0;
long long Ksm(long long x, long long p) {
  if (p == 0)
    return 1;
  else if (p == 1)
    return x;
  else {
    long long tmp = Ksm(x, p >> 1);
    if (p & 1)
      return tmp * tmp * x;
    else
      return tmp * tmp;
  }
}
bool fcheck(long long x, long long m) {
  for (long long i = 1; i <= 6; i++)
    if (Ksm(x, i) % m == 0) return true;
  if ((x - 1) % m == 0) return true;
  if ((x + 1) % m == 0) return true;
  return false;
}
long long check(long long x) {
  for (long long i = 1; i <= 6; i++)
    if (Ksm(x, i) % d == 0) {
      flag = i;
      return 2;
    }
  if ((x - 1) % d == 0) return 3;
  if ((x + 1) % d == 0) return 11;
  for (long long i = 1; i <= 25; i++)
    if (d % prime[i] == 0) {
      long long top = 1;
      while (d % prime[i] == 0) top *= prime[i], d /= prime[i];
      if (!fcheck(x, top)) return 7;
    }
  return 6;
}
int main() {
  scanf("%I64d %I64d", &b, &d);
  printf("%I64d-type\n", check(b));
  if (flag) printf("%I64d\n", flag);
  return 0;
}
