#include <bits/stdc++.h>
using namespace std;
const double EPS = 1E-9;
const int INF = 1000000000;
const long long INF64 = (long long)1E18;
const double PI = 3.1415926535897932384626433832795;
long long gcd(long long a, long long b) {
  if (a < b) return gcd(b, a);
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long st(long long b, long long d) {
  long long a, a1 = b, i;
  for (i = 1, a = b; a <= d && d % a == 0; ++i) a1 = a, a *= b;
  return a1;
}
long long type(long long b, long long d, long long& res) {
  long long g = gcd(b, d), i, a;
  if (g > 1) {
    for (i = 1, a = g; a < 100500000000; ++i, a *= g)
      if (a % d == 0) {
        res = i;
        return 2;
      }
  }
  if (b % d == 1) return 3;
  if ((b + 1) % d == 0) return 11;
  return 0;
}
int main() {
  long long i, n, j, a, b, d;
  cin >> b >> d;
  long long res, tp = type(b, d, res);
  if (tp > 0) {
    cout << tp << "-type" << endl;
    if (tp == 2) cout << res;
    return 0;
  }
  for (i = 2; i <= d; ++i)
    if (d % i == 0)
      if (type(b, st(i, d), res) > 0) {
        d /= st(i, d);
      } else {
      }
  if (d == 1) {
    cout << "6-type";
    return 0;
  }
  cout << "7-type";
  return 0;
}
