We just discovered a new data structure in our research group: a suffix three!

It's very useful for natural language processing. Given three languages and three suffixes, a suffix three can determine which language a sentence is written in.

It's super simple, 100% accurate, and doesn't involve advanced machine learning algorithms.

Let us tell you how it works.

  If a sentence ends with "po" the language is Filipino.  If a sentence ends with "desu" or "masu" the language is Japanese.  If a sentence ends with "mnida" the language is Korean. 

Given this, we need you to implement a suffix three that can differentiate Filipino, Japanese, and Korean.

Oh, did I say three suffixes? I meant four.


-----Input-----

The first line of input contains a single integer $t$ ($1 \leq t \leq 30$) denoting the number of test cases. The next lines contain descriptions of the test cases. 

Each test case consists of a single line containing a single string denoting the sentence. Spaces are represented as underscores (the symbol "_") for ease of reading. The sentence has at least $1$ and at most $1000$ characters, and consists only of lowercase English letters and underscores. The sentence has no leading or trailing underscores and no two consecutive underscores. It is guaranteed that the sentence ends with one of the four suffixes mentioned above.


-----Output-----

For each test case, print a single line containing either "FILIPINO", "JAPANESE", or "KOREAN" (all in uppercase, without quotes), depending on the detected language.


-----Example-----
Input
8
kamusta_po
genki_desu
ohayou_gozaimasu
annyeong_hashimnida
hajime_no_ippo
bensamu_no_sentou_houhou_ga_okama_kenpo
ang_halaman_doon_ay_sarisari_singkamasu
si_roy_mustang_ay_namamasu

Output
FILIPINO
JAPANESE
JAPANESE
KOREAN
FILIPINO
FILIPINO
JAPANESE
JAPANESE



-----Note-----

The first sentence ends with "po", so it is written in Filipino.

The second and third sentences end with "desu" and "masu", so they are written in Japanese.

The fourth sentence ends with "mnida", so it is written in Korean.

Difficulty: interview

Starter code:

Solutions:
q=int(input())
for i in range(q):
    t=input()
    r=t[-1]
    if r=="o":
        print("FILIPINO")
    elif r=="u":
        print("JAPANESE")
    else:
        print("KOREAN")

for i in ' '*int(input()):
    s=input()
    if s[-2:]=='po':print('FILIPINO')
    elif s[-2:]=='su':print('JAPANESE')
    else:print('KOREAN')

t = int(input())
for i in range(t):
    s = input()
    if s.endswith("po"):
        print("FILIPINO")
    elif s.endswith("desu") or s.endswith("masu"):
        print("JAPANESE")
    else:
        print("KOREAN")
        


t = int(input())
while t:
    s = input()
    if s[-2] == 'p' and s[-1] == 'o':
        print("FILIPINO")
    else:
        if s[-4:] == "desu" or s[-4:] == "masu":
            print("JAPANESE")
        else:
            print("KOREAN")
    t -= 1

n = int(input())
for _ in range(n):
    s = input()
    if len(s) >= 2 and s[-2:] == 'po':
        print ("FILIPINO")
    elif len(s) >= 4 and s[-4:] == 'desu':
        print ("JAPANESE")
    elif len(s) >= 4 and s[-4:] == 'masu':
        print ("JAPANESE")
    else:
        print ("KOREAN")

for _ in range(int(input())):
    s = input()
    if s.endswith("po"):
        print("FILIPINO")
    elif s.endswith("desu") or s.endswith("masu"):
        print("JAPANESE")
    elif s.endswith("mnida"):
        print("KOREAN")




t = int(input())
for _ in range(t):
    s = input()
    if s[-2:] == 'po':
        print("FILIPINO")
    elif s[-5:] == 'mnida':
        print("KOREAN")
    else:
        print("JAPANESE")


def main():
    N = int(input())
    for i in range(N):
        a = input().strip()
        if a.endswith("po"):
            print("FILIPINO")
        elif a.endswith("mnida"):
            print("KOREAN")
        else:
            print("JAPANESE")

main()


import sys
r_input = sys.stdin.readline

t = int(r_input())

for _ in range(t):
    s = r_input().rstrip()
    if s.endswith('po'):
        print('FILIPINO')
    elif s.endswith('desu') or s.endswith('masu'):
        print('JAPANESE')
    elif s.endswith('mnida'):
        print('KOREAN')

t = int(input())
for a in range(t):
    s = input()
    if s[-2:] == "po":
        print("FILIPINO")
    elif s[-4:] == "desu" or s[-4:] == "masu":
        print("JAPANESE")
    elif s[-5:] == "mnida":
        print("KOREAN")

n = int(input())
for _ in range(n):
    s = input()
    if s[-1] == "o":
        print("FILIPINO")
    elif s[-1] == "u":
        print("JAPANESE")
    else:
        print("KOREAN")

#!/usr/bin/env python3
# coding: utf-8
# Last Modified: 15/Dec/19 10:37:31 AM


import sys


def main():
    for tc in range(int(input())):
        s = list(input())
        s.reverse()
        if s[0] == "o":
            print("FILIPINO")
        elif s[0] == "u":
            print("JAPANESE")
        else:
            print("KOREAN")


get_array = lambda: list(map(int, sys.stdin.readline().split()))


get_ints = lambda: list(map(int, sys.stdin.readline().split()))


input = lambda: sys.stdin.readline().strip()


def __starting_point():
    main()

__starting_point()

from copy import copy


def arr_float_inp():
    return [float(s) for s in input().split()]


def arr_int_inp():
    return [int(s) for s in input().split()]


def int_inp():
    return int(input())


def float_inp():
    return float(input())


def comp(a):
    return a[0]


def __starting_point():
    for _ in range(int_inp()):
        str = input()
        if str.endswith('po'):
            print('FILIPINO')
        elif str.endswith('desu') or str.endswith('masu'):
            print('JAPANESE')
        elif str.endswith('mnida'):
            print('KOREAN')

__starting_point()

arr = ["FILIPINO", "JAPANESE", "KOREAN"]
 
N = int(input())
 
for _ in range(N):
	line = input()
	if line[-2:] == "po":
		print(arr[0])
	if line[-4:] == "desu" or line[-4:] == "masu":
		print(arr[1])
	if line[-5:] == "mnida":
		print(arr[2])


t=int(input())
for i in range(t):
	s=input()
	if s[-1]=="o":
		print("FILIPINO")
	elif s[-1]=="u":
		print("JAPANESE")
	else:
		print("KOREAN")

n = input()
for i in range(int(n)):
    s = input()
    if(s[-2:]=="po"):
        print("FILIPINO")
    elif(s[-4:]=="desu" or s[-4:]=="masu"):
        print("JAPANESE")
    else:
        print("KOREAN")


t = int(input())

for t_i in range(t):
    s = input()
    if s[-2:] == "po":
        print("FILIPINO")
    elif s[-4:] in ["desu", "masu"]:
        print("JAPANESE")
    else:
        print("KOREAN")


for _ in range(int(input())):
    s = input()
    if s[-2:]=="po":
        print("FILIPINO")
    elif s[-4:]=="desu" or s[-4:]=="masu":
        print("JAPANESE")
    elif s[-5:]=="mnida":
        print("KOREAN")


n = int(input())
for i in range(n):
    s = input()
    if s[-1] == 'o':
        print("FILIPINO")
    elif s[-1] == 'u':
        print("JAPANESE")
    else:
        print("KOREAN")

n = int(input())
while n:
    x = input()
    if x[-2:] == 'po':
        print('FILIPINO')
    elif x[-4:] == 'masu' or x[-4:] == 'desu':
        print('JAPANESE')
    else:
        print('KOREAN')
    n -= 1

def main():
    N = int(input())
    for _ in range(N):
        S = str(input())
        if S.endswith("po"):
            print("FILIPINO")
        elif S.endswith("desu") or S.endswith("masu"):
            print("JAPANESE")
        else:
            print("KOREAN")

def __starting_point():
    main()

__starting_point()

for i in range(int(input())):
  s = input()
  l = len(s)-1
  if s[l] == 'o':
    print('FILIPINO')
  elif s[l] == 'u':
    print('JAPANESE')
  else:
    print('KOREAN')

import sys
input = sys.stdin.readline

def getInt(): return int(input())
def getVars(): return list(map(int, input().split()))
def getList(): return list(map(int, input().split()))
def getStr(): return input().strip()

## -------------------------------

n = getInt()
for i in range(n):
    s = getStr()
    if s[-2:] == 'po': print('FILIPINO')
    if s[-2:] == 'su': print('JAPANESE')
    if s[-5:] == 'mnida': print('KOREAN')




n = int(input())
for _ in range(n):
    s = input()
    if s.endswith("po"):
        print("FILIPINO")
    elif s.endswith("mnida"):
        print("KOREAN")
    else:
        print("JAPANESE")


# n, x, a, b = map(int, input().split())

t = int(input())
for i in range(t):
    s = input()
    suff = s[-2:]
    if suff == 'po':
        print('FILIPINO')
    if suff == 'su':
        print('JAPANESE')
    if suff == 'da':
        print('KOREAN')



from collections import Counter,deque,defaultdict,OrderedDict,namedtuple
from bisect import bisect_left,bisect_right,insort
from math import sqrt,ceil,floor,factorial,gcd
from heapq import heapify,heappush,heappop,heappushpop,heapreplace,merge,nlargest,nsmallest
from itertools import permutations,combinations

mod=10**9+7
inf = float('inf')
negin = float('-inf')
a_dict={'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8,'i':9,'j':10,'k':11,'l':12,'m':13,'n':14,'o':15,'p':16,'q':17,'r':18,'s':19,'t':20,'u':21,'v':22,'w':23,'x':24,'y':25,'z':26}
AZ=dict(list(zip('ABCDEFGHIJKLMNOPQRSTUVWXYZ', list(range(1,27)))))
def b_search(a,x):
    i = bisect_left(a, x) 
    if i != len(a) and a[i] == x: 
        return(i) 
    else: 
        return(-1)

def opt_sieve(n):
    prime=[]
    is_prime = [True for i in range(n)] 
    spf=[0 for i in range(n)]
    is_prime[0]=is_prime[1]=False
    for i in range(2,n):
        if is_prime[i]:
            spf[i]=i
            prime.append(i)
        j=0
        while j<len(prime) and i*prime[j]<n and prime[j]<=spf[i]:
            is_prime[i*prime[j]]=False
            spf[i*prime[j]]=prime[j]
            j+=1
    return is_prime
    
is_prime=opt_sieve(1000001)
    
from sys import stdin    
t=int(stdin.readline())
while t:
    s=input()
    if s[len(s)-2:]=='po':
        print('FILIPINO')
    elif s[len(s)-4:]=='desu' or s[len(s)-4:]=='masu':
        print('JAPANESE')
    elif s[len(s)-5:]=='mnida':
        print('KOREAN')
    

    t-=1

    
    


t = int(input())
for _ in range(0,t):
    s = input()
    if s[len(s)-2:len(s)] == "po":
        print("FILIPINO")
    elif s[len(s)-4:len(s)] == "desu" or s[len(s)-4:len(s)] == "masu":
        print("JAPANESE")
    else:
        print("KOREAN")

import math

def main():
    t = int(input())
    for i in range(t):
        sen = str(input())
        if sen.endswith('po'):
            print('FILIPINO')
        elif sen.endswith('desu') or sen.endswith('masu'):
            print('JAPANESE')
        else:
            print('KOREAN')

def __starting_point():
    main()

__starting_point()

import sys

input = lambda: sys.stdin.readline()[:-1]
print = lambda s: sys.stdout.write(f"{s}\n")

for _ in range(int(input())):
    sentence = input()
    if sentence.endswith("po"):
        print("FILIPINO")
    elif sentence.endswith("mnida"):
        print("KOREAN")
    else:
        print("JAPANESE")

sys.stdout.flush()


import sys

r = lambda: sys.stdin.readline().rstrip()

def __starting_point():
    T = int(r())
    for _ in range(T):
        s = r()
        if s.endswith('po'): print('FILIPINO')
        elif s.endswith('desu') or s.endswith('masu'): print('JAPANESE')
        elif s.endswith('mnida'): print('KOREAN')

__starting_point()

for _ in range(int(input())):
    s=input()
    if s[-2:]=='po':
        print("FILIPINO")
    elif s[-4:]=='masu' or s[-4:]=='desu':
        print("JAPANESE")
    else:
        print("KOREAN")

n = int(input())

for i in range(0, n):
    st = list(input())
    if "".join(st[-2:]) == "po":
        print("FILIPINO")
    elif "".join(st[-4:]) == "masu" or "".join(st[-4:]) == "desu":
        print("JAPANESE")
    elif "".join(st[-5:]) == "mnida":
        print("KOREAN")


t=int(input())
for i in range(t):
    a=input()
    if a[-2:]=='po':
        print("FILIPINO")
    elif a[-4:]=='desu' or a[-4:]=='masu':
        print("JAPANESE")
    elif a[-5:]=='mnida':
        print("KOREAN")

t = int(input())
for i in range(t):
    s = input()
    delta = s[-2:]
    # print(delta)
    if delta=="po":
        print("FILIPINO")
    elif delta=="su":
        print("JAPANESE")
    else:
        print("KOREAN")
        


t = int(input())


def main():
    n = input()
    if n[-1] == "o":
        print("FILIPINO")
    elif n[-1] == "u":
        print("JAPANESE")
    elif n[-1] == "a":
        print("KOREAN")


def __starting_point():
    for i in range(t):
        main()
__starting_point()

for _ in range(int(input())):
    s = input().strip()
    if s.endswith('po'):
        print('FILIPINO')
    elif s.endswith('desu') or s.endswith('masu'):
        print('JAPANESE')
    elif s.endswith('mnida'):
        print('KOREAN')
    else:
        raise Exception

t = int(input())
for  i in range(t):
    s = input()
    if s[-2:] == "po":
        print("FILIPINO")
    elif s[-4:] == "masu" or s[-4:] == "desu":
        print("JAPANESE")
    elif s[-5:] == "mnida":
        print("KOREAN"  )


for _ in range(int(input())):
	s = input()
	if s[-2:] == "po":
		print("FILIPINO")
	elif s[-4:]=="desu" or s[-4:]=="masu":
		print("JAPANESE")
	else:
		print("KOREAN")



n=int(input())
for x in range(n):
    s=input()
    l=len(s)
    if(len(s)>=2 and s[l-2:l]=="po"):
        print("FILIPINO")
    if(len(s)>=4 and s[l-4:l]=="desu"):
        print("JAPANESE")
    if(len(s)>=4 and s[l-4:l]=="masu"):
        print("JAPANESE")
    if(len(s)>=5 and s[l-5:l]=="mnida"):
        print("KOREAN")


t=int(input())
while(t):
 t-=1
 a=input()
 if(a[-2::]=='po'):
  print("FILIPINO")
 elif(a[-4::]=='desu' or a[-4::]=='masu'):
  print("JAPANESE")
 else:
  print("KOREAN")