#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100;
int power;
bool t2(int b, int d) {
  int r = 1;
  for (int i = int(1); i < int(MAXN); ++i) {
    r = r * b % d;
    if (r == 0) {
      power = i;
      return true;
    }
  }
  return false;
}
bool t3(int b, int d) { return b % d == 1; }
bool t11(int b, int d) { return b % d == d - 1; }
bool t6(int b, int d) {
  for (int i = int(2); i < int(MAXN); ++i)
    if (d % i == 0) {
      int p = 1;
      while (d % i == 0) {
        d /= i;
        p *= i;
      }
      if (!t2(b, p) && !t3(b, p) && !t11(b, p)) return false;
    }
  return true;
}
int main() {
  int b, d;
  cin >> b >> d;
  if (t2(b, d)) {
    cout << "2-type" << endl;
    cout << power << endl;
    return 0;
  }
  if (t3(b, d)) {
    cout << "3-type" << endl;
    return 0;
  }
  if (t11(b, d)) {
    cout << "11-type" << endl;
    return 0;
  }
  if (t6(b, d)) {
    cout << "6-type" << endl;
    return 0;
  }
  cout << "7-type" << endl;
}
