#include <bits/stdc++.h>
int main() {
  int n, i, j = 0, x, k;
  scanf("%d", &n);
  int ln[n];
  char str[n][1001], str2[n][1001];
  for (i = 0; i < n; i++) {
    scanf("%s", str[i]);
    ln[j++] = strlen(str[i]);
  }
  for (i = 0; i < n; i++) {
    if (ln[i] < 5) {
      for (j = 0; j < (5 - ln[i]); j++) {
        str2[i][j] = 'x';
      }
      for (k = 0;; j++, k++) {
        str2[i][j] = str[i][k];
        if (str2[i][j] == '\0') break;
      }
      continue;
    }
    x = (ln[i] - 5);
    for (j = 0; j < 6; j++) {
      str2[i][j] = str[i][x++];
      if (str2[i][j] == '\0') break;
    }
  }
  for (i = 0; i < n; i++) {
    if (strcmp(str2[i], "mnida") == 0)
      printf("KOREAN\n");
    else {
      for (j = 0;; j++) {
        str2[i][j] = str2[i][j + 1];
        if (str2[i][j] == '\0') break;
      }
    }
    if (strcmp(str2[i], "desu") == 0 || strcmp(str2[i], "masu") == 0)
      printf("JAPANESE\n");
    else {
      for (j = 0;; j++) {
        str2[i][j] = str2[i][j + 2];
        if (str2[i][j] == '\0') break;
      }
    }
    if (strcmp(str2[i], "po") == 0) printf("FILIPINO\n");
  }
  return 0;
}
