#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    int n = s.size();
    string p;
    for (int i = n - 1; i >= 0; i--) {
      p.push_back(s[i]);
      if ((int)p.size() == 2) {
        reverse(p.begin(), p.end());
        if (p == "po") {
          cout << "FILIPINO" << endl;
          break;
        }
        reverse(p.begin(), p.end());
      }
      if ((int)p.size() == 4) {
        reverse(p.begin(), p.end());
        if (p == "desu" || p == "masu") {
          cout << "JAPANESE" << endl;
          break;
        }
        reverse(p.begin(), p.end());
      }
      if ((int)p.size() == 5) {
        reverse(p.begin(), p.end());
        if (p == "mnida") {
          cout << "KOREAN" << endl;
          break;
        }
      }
    }
  }
  return 0;
}
