#include <bits/stdc++.h>
using namespace std;
using namespace std;
int inquire(int x, int y) {
  cout << "? " << x << " " << y << endl;
  int a;
  cin >> a;
  return a;
}
const long long int INF = 1e18;
const long long int MAX = 1e6 + 1;
const long long int LOG_MAX = 20;
const double pi = 3.141592653;
long long int cases;
string s;
vector<string> cur = {"po", "desu", "masu", "mnida"};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> cases;
  while (cases--) {
    cin >> s;
    string emptys = "";
    bool ok = false;
    string ans;
    for (int i = (int)s.length() - 1; i >= 0; i--) {
      emptys = s[i] + emptys;
      for (int i = 0; i < 4; i++) {
        if (emptys == cur[0]) {
          ans = "FILIPINO";
          break;
        } else if (emptys == cur[1] || emptys == cur[2]) {
          ans = "JAPANESE";
          break;
        } else if (emptys == cur[3]) {
          ans = "KOREAN";
          break;
        }
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
