#include <bits/stdc++.h>
using namespace std;
template <class T>
using lim = numeric_limits<T>;
void factorize(int x, unordered_map<int, int> &fact) {
  for (int i = 2; i * i <= x; i++) {
    while (x % i == 0) {
      fact[i]++;
      x /= i;
    }
  }
  if (x > 1) fact[x]++;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int b, d;
  cin >> b >> d;
  if ((b - 1) % d == 0)
    cout << "3-type\n";
  else if ((b + 1) % d == 0)
    cout << "11-type\n";
  else if (b % d == 0)
    cout << "2-type\n1\n";
  else {
    unordered_map<int, int> bfact;
    unordered_map<int, int> dfact;
    factorize(b, bfact);
    factorize(d, dfact);
    bool twotype = true;
    vector<int> checksix;
    for (auto it : dfact) {
      if (bfact.find(it.first) == bfact.end()) {
        checksix.push_back(pow(it.first, it.second));
        twotype = false;
      }
    }
    bool sixtype = true;
    for (int num : checksix)
      sixtype &= ((b - 1) % num == 0 or (b + 1) % num == 0);
    if (twotype) {
      int ans = 0;
      for (auto it : bfact) ans = max(ans, abs(it.second - dfact[it.first]));
      ans++;
      cout << "2-type\n" << ans << "\n";
    } else if (sixtype)
      cout << "6-type\n";
    else
      cout << "7-type\n";
  }
}
