#include <bits/stdc++.h>
using namespace std;
int b, num;
inline bool type2(int b, int num) {
  int h = sqrt(num + 0.5);
  for (int i = 2; i <= h; i++) {
    if (num % i) continue;
    if (b % i) return 0;
    while (num % i == 0) num /= i;
  }
  return b % num == 0;
}
inline bool type3(int b, int num) { return b % num == 1; }
inline bool type11(int b, int num) {
  return b * b % num == 1 && b % num == num - 1;
}
inline bool type6(int b, int num) {
  int h = sqrt(num + 0.5);
  for (int i = 2; i <= h; i++) {
    if (num % i) continue;
    int c = 1;
    while (num % i == 0) num /= i, c *= i;
    if (type2(b, c) || type3(b, c) || type11(b, c))
      ;
    else
      return 0;
  }
  return type2(b, num) || type3(b, num) || type11(b, num);
}
int main() {
  scanf("%d %d", &b, &num);
  if (type2(b, num)) {
    puts("2-type");
    int B = b;
    for (int i = 1;; i++) {
      if (B % num == 0) {
        printf("%d\n", i);
        return 0;
      }
      B *= b;
    }
  } else if (type3(b, num))
    puts("3-type");
  else if (type11(b, num))
    puts("11-type");
  else if (type6(b, num))
    puts("6-type");
  else
    puts("7-type");
}
