#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5 + 7, oo = 1e18, aoo = -1e18;
map<string, string> _map;
long long t, n;
string s, tmp;
void solve() {
  {
    tmp = "";
    for (long long j = n - 2; j <= n - 1; ++j) tmp += s[j];
    if (_map[tmp] != "") {
      cout << _map[tmp] << '\n';
      return;
    }
    tmp = "";
    for (long long j = n - 4; j <= n - 1; ++j) tmp += s[j];
    if (_map[tmp] != "") {
      cout << _map[tmp] << '\n';
      return;
    }
    tmp = "";
    for (long long j = n - 5; j <= n - 1; ++j) tmp += s[j];
    if (_map[tmp] != "") {
      cout << _map[tmp] << '\n';
      return;
    }
  }
}
int main() {
  _map["po"] = "FILIPINO";
  _map["desu"] = "JAPANESE";
  _map["masu"] = "JAPANESE";
  _map["mnida"] = "KOREAN";
  cin >> t;
  while (t--) {
    cin >> s;
    n = s.size();
    solve();
  }
}
