#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int j = 0; j <= t; j++) {
    string s;
    getline(cin, s);
    int l = s.length();
    string s1 = "";
    for (int i = l - 5; i < l; i++) {
      s1 += s[i];
    }
    string s11 = "mnida";
    string s2 = "";
    for (int i = l - 4; i < l; i++) {
      s2 += s[i];
    }
    string s21 = "desu";
    string s22 = "masu";
    string s3 = "";
    for (int i = l - 2; i < l; i++) {
      s3 += s[i];
    }
    string s31 = "po";
    if ((s1.compare(s11)) == 0) {
      cout << "KOREAN" << endl;
    } else if (((s2.compare(s21)) == 0) || ((s2.compare(s22)) == 0)) {
      cout << "JAPANESE" << endl;
    } else if ((s3.compare(s31)) == 0) {
      cout << "FILIPINO" << endl;
    }
  }
}
