#include <bits/stdc++.h>
using namespace std;
long long b, d;
int check2(int d) {
  int cnt = 0;
  long long curr = 1;
  for (int i = 0; i < 200; i++) {
    if (curr != 0) cnt++;
    curr = (curr * b) % d;
  }
  if (curr != 0) return -1;
  return cnt;
}
bool check3(int d) {
  if (b % d == 1) return true;
  return false;
}
bool check11(int d) {
  if (b % d == d - 1) return true;
  return false;
}
int check6(int d) {
  int dCopy = d;
  int cnt = 0;
  int divisor = 2;
  while (dCopy != 1) {
    if (dCopy % divisor == 0) {
      bool ok = false;
      if (check2(divisor) != -1) ok = true;
      if (check3(divisor) == true) ok = true;
      if (check11(divisor) == true) ok = true;
      if (ok == false) return -1;
      cnt++;
      while (dCopy % divisor == 0) dCopy /= divisor;
    } else {
      divisor++;
    }
  }
  return cnt;
}
int main() {
  cin >> b >> d;
  if (check2(d) != -1) {
    cout << "2-type" << '\n';
    cout << check2(d) << '\n';
    return 0;
  }
  if (check3(d) == true) {
    cout << "3-type" << '\n';
    return 0;
  }
  if (check11(d) == true) {
    cout << "11-type" << '\n';
    return 0;
  }
  if (check6(d) > 1) {
    cout << "6-type" << '\n';
    return 0;
  }
  cout << "7-type" << '\n';
}
