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: EASY

Solutions:
import sys
t = int(input())
for i in range(t):
	a = sys.stdin.readline().strip()
	if a[-2:] == 'po':
		print('FILIPINO')
	elif a[-4:] in ['desu', 'masu']:
		print('JAPANESE')
	else:
		print('KOREAN')


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


t = int(input())
l = []
for i in range(t):
	a = str(input())
	l.append(a)
for i in range(t):
	d = l[i][-2]
	d += l[i][-1]
	if d == 'su':
		print('JAPANESE')
	if d == 'po':
		print('FILIPINO')
	if d == 'da':
		print('KOREAN')


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


import sys
import math
from collections import defaultdict, Counter, deque
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for i in range(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')
	else:
		print('KOREAN')


for t in range(int(input())):
	s = input()
	if s[-1] == 'o':
		print('FILIPINO')
	if s[-1] == 'u':
		print('JAPANESE')
	if s[-1] == 'a':
		print('KOREAN')


N = int(input())
lang = ['FILIPINO', 'JAPANESE', 'KOREAN']
for i in range(N):
	s = input()
	if s.endswith('po'):
		print(lang[0])
		continue
	elif s.endswith('mnida'):
		print(lang[2])
		continue
	print(lang[1])


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


n = int(input())
for i in range(n):
	s = input()
	s = s[::-1]
	if s[:2] == 'op':
		print('FILIPINO')
	elif s[:4] == 'usam' or s[:4] == 'used':
		print('JAPANESE')
	else:
		print('KOREAN')


t = eval(input())
while t != 0:
	t -= 1
	s = input()
	if s.endswith('po'):
		print('FILIPINO')
	elif s.endswith('mnida'):
		print('KOREAN')
	else:
		print('JAPANESE')


for i in range(int(input())):
	print({'o': 'FILIPINO', 'a': 'KOREAN', 'u': 'JAPANESE'}[input()[-1]])


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


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


from sys import exit as sys_return
queries = int(input())
while queries != 0:
	queries -= 1
	sentence = str(input())
	if sentence[::-1][0] == 'u':
		print('JAPANESE')
	elif sentence[::-1][0] == 'a':
		print('KOREAN')
	else:
		print('FILIPINO')


x = int(input())
a = []
for i in range(0, x):
	a.append(input())
for i in range(0, x):
	if a[i][-2:] == 'po':
		print('FILIPINO')
	elif a[i][-4:] == 'desu':
		print('JAPANESE')
	elif a[i][-4:] == 'masu':
		print('JAPANESE')
	elif a[i][-5:] == 'mnida':
		print('KOREAN')


def check(x):
	f = x[len(x) - 2:]
	j = x[len(x) - 4:]
	k = x[len(x) - 5:]
	if f == 'po':
		return 'FILIPINO'
	elif j == 'desu' or j == 'masu':
		return 'JAPANESE'
	elif k == 'mnida':
		return 'KOREAN'
n = int(input())
while n > 0:
	x = input()
	print(check(x))
	n -= 1


t = int(input())
while t:
	t = t - 1
	s = input()
	if s[-1] == 'o':
		print('FILIPINO')
	elif s[-1] == 'u':
		print('JAPANESE')
	else:
		print('KOREAN')


t = int(input())
for _ in range(t):
	st = input()
	lis = st.split('_')
	word = lis[-1]
	n = len(word)
	if word[n - 2:] == 'po':
		print('FILIPINO')
	elif word[n - 4:] == 'desu':
		print('JAPANESE')
	elif word[n - 4:] == 'masu':
		print('JAPANESE')
	elif word[n - 5:] == 'mnida':
		print('KOREAN')


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


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


n = int(input())
for i in range(n):
	s = input()
	if s.endswith('po'):
		print('FILIPINO')
		continue
	if s.endswith('desu') or s.endswith('masu'):
		print('JAPANESE')
		continue
	if s.endswith('mnida'):
		print('KOREAN')
		continue


import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline

def ii():
	return int(input())

def mi():
	return map(int, input().rstrip().split())

def lmi():
	return list(map(int, input().rstrip().split()))

def fi():
	return float(input())

def mfi():
	return map(float, input().rstrip().split())

def lmfi():
	return list(map(float, input().rstrip().split()))

def li():
	return list(input().rstrip())

def exit(*arg):
	print(*arg)
	sys.exit()

def main():
	n = ii()
	for i in range(n):
		s = input().rstrip()
		if len(s) >= 2 and s[-2:] == 'po':
			print('FILIPINO')
		if len(s) >= 4 and (s[-4:] == 'desu' or s[-4:] == 'masu'):
			print('JAPANESE')
		if len(s) >= 5 and s[-5:] == 'mnida':
			print('KOREAN')
	return
main()


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')


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


t = int(input())
for i in range(t):
	y = input()
	j = len(y)
	k = y[-5:j]
	if 'po' in k:
		print('FILIPINO')
	elif 'desu' in k:
		print('JAPANESE')
	elif 'masu' in k:
		print('JAPANESE')
	elif 'mnida' in k:
		print('KOREAN')


t = int(input())
for _ in range(t):
	string = str(input())
	if string[-1] == 'o':
		print('FILIPINO')
	elif string[-1] == 'u':
		print('JAPANESE')
	else:
		print('KOREAN')


q = int(input())
d = {'po': 'FILIPINO', 'desu': 'JAPANESE', 'masu': 'JAPANESE', 'mnida': 'KOREAN'}
lst = list(d.keys())
for i in range(q):
	inp = input()
	for k in lst:
		if inp[-1] == k[-1]:
			print(d[k])
			break


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


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


def spliter(a):
	word = []
	for i in a:
		word.append(i)
	return word
x = int(input())
new = []
for i in range(x):
	m = input()
	new.append(m)
for i in range(x):
	if new[i].endswith('po'):
		print('FILIPINO')
	if new[i].endswith('desu') or new[i].endswith('masu'):
		print('JAPANESE')
	if new[i].endswith('mnida'):
		print('KOREAN')


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


t = int(input())
ls = []
for i in range(t):
	s = input()
	ls.append(s)
for j in ls:
	if j.endswith('po'):
		print('FILIPINO')
	elif j.endswith('desu'):
		print('JAPANESE')
	elif j.endswith('masu'):
		print('JAPANESE')
	elif j.endswith('mnida'):
		print('KOREAN')


n = int(input())
suf = ['po', 'desu', 'masu', 'mnida']
lang = {'po': 'FILIPINO', 'desu': 'JAPANESE', 'masu': 'JAPANESE', 'mnida': 'KOREAN'}
for _ in range(n):
	s = input()
	for i in suf:
		if s.endswith(i):
			print(lang[i])
			break


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')


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


n = int(input())
while n > 0:
	t = input()
	b = t[-1]
	if b == 'u' or b == 'U':
		print('JAPANESE')
	elif b == 'o' or b == 'O':
		print('FILIPINO')
	elif b == 'a' or b == 'A':
		print('KOREAN')
	n = n - 1


def main():

	def solve():
		ss = input()
		if ss[-1] == 'o':
			print('FILIPINO')
		elif ss[-1] == 'u':
			print('JAPANESE')
		else:
			print('KOREAN')
	q = int(input())
	for _ in range(q):
		solve()
main()


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')


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


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


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


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


t = int(input())
while t > 0:
	s = input()
	n = len(s)
	if n >= 2 and s[n - 2] == 'p' and (s[n - 1] == 'o'):
		print('FILIPINO')
	elif n >= 4 and s[n - 4] == 'd' and (s[n - 3] == 'e') and (s[n - 2] == 's') and (s[n - 1] == 'u'):
		print('JAPANESE')
	elif n >= 4 and s[n - 4] == 'm' and (s[n - 3] == 'a') and (s[n - 2] == 's') and (s[n - 1] == 'u'):
		print('JAPANESE')
	elif n >= 5 and s[n - 5] == 'm' and (s[n - 4] == 'n') and (s[n - 3] == 'i') and (s[n - 2] == 'd') and (s[n - 1] == 'a'):
		print('KOREAN')
	t -= 1


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


def str_inp(n):
	return [input() for x in range(n)]

def check(s):
	(l, out) = (len(s), '')
	if l >= 4 and s[-4:] == 'desu' or s[-4:] == 'masu':
		out = 'JAPANESE'
	elif l >= 5 and s[-5:] == 'mnida':
		out = 'KOREAN'
	else:
		out = 'FILIPINO'
	return out
from sys import *
n = int(input())
arr = str_inp(n)
print('\n'.join(list(map(check, arr))))


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


N = int(input())
for _ in range(N):
	string = input()
	if string[-1] == 'o':
		print('FILIPINO')
	elif string[-1] == 'u':
		print('JAPANESE')
	elif string[-1] == 'a':
		print('KOREAN')


d = int(input())
if d <= 30 and d >= 1:
	for loop in range(d):
		z = input()
		l = len(z)
		if l <= 1000 and l >= 1:
			if z[l - 2] + z[l - 1] == 'po':
				print('FILIPINO')
			elif z[l - 5] + z[l - 4] + z[l - 3] + z[l - 2] + z[l - 1] == 'mnida':
				print('KOREAN')
			elif z[l - 4] + z[l - 3] + z[l - 2] + z[l - 1] == 'masu':
				print('JAPANESE')
			elif z[l - 4] + z[l - 3] + z[l - 2] + z[l - 1] == 'desu':
				print('JAPANESE')


d = ['FILIPINO', 'JAPANESE', 'KOREAN']
for _ in range(int(input())):
	s = input()
	s = s[::-1]
	k = 2
	if s[:2] == 'op':
		k = 0
	elif s[:4] in ['used', 'usam']:
		k = 1
	print(d[k])


testcase = int(input())
while testcase > 0:
	x = input()
	if x[-2:] == 'po':
		print('FILIPINO')
	elif x[-4:] == 'desu' or x[-4:] == 'masu':
		print('JAPANESE')
	elif x[-5:] == 'mnida':
		print('KOREAN')
	testcase -= 1


a = input()
l = []
a = int(a)
for x in range(a):
	k = input()
	l.append(k)
for x in l:
	if x[-1] == 'o':
		print('FILIPINO')
	elif x[-1] == 'a':
		print('KOREAN')
	elif x[-1] == 'u':
		print('JAPANESE')


for _ in range(int(input())):
	n = input()
	a = n[len(n) - 2:]
	b = n[len(n) - 4:]
	c = n[len(n) - 5:]
	if a == 'po':
		print('FILIPINO')
	elif b == 'desu' or b == 'masu':
		print('JAPANESE')
	elif c == 'mnida':
		print('KOREAN')


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


n = int(input())
for i in range(n):
	s = input()
	x = len(s)
	if s[x - 2:x] == 'po':
		print('FILIPINO')
		continue
	elif s[x - 2:x] == 'su':
		if s[x - 4:x - 2] == 'de' or s[x - 4:x - 2] == 'ma':
			print('JAPANESE')
			continue
	elif s[x - 5:x] == 'mnida':
		print('KOREAN')


t = int(input())
for i in range(0, t):
	name = input()
	le = len(name)
	if name[le - 1] == 'u':
		print('JAPANESE')
	if name[le - 1] == 'o':
		print('FILIPINO')
	if name[le - 1] == 'a':
		print('KOREAN')


def solver():
	word = input()
	if word[-2:] == 'po':
		return 'FILIPINO'
	elif word[-4:] == 'desu' or word[-4:] == 'masu':
		return 'JAPANESE'
	else:
		return 'KOREAN'
n = int(input())
for i in range(n):
	print(solver())


n = int(input())
while n != 0:
	s = input()
	if len(s) == 2:
		print('FILIPINO')
	elif len(s) == 3:
		sx = s[-2:]
		if 'po' == sx:
			print('FILIPINO')
	elif len(s) == 4:
		if 'po' in s:
			print('FILIPINO')
		elif 'desu' == s or 'masu' == s:
			print('JAPANESE')
	elif len(s) == 5:
		if s == 'mnida':
			print('KOREAN')
		elif 'po' in s[-2:]:
			print('FILIPINO')
		elif ('desu' or 'masu' in s) and s != 'mnida':
			print('JAPANESE')
	elif len(s) > 5:
		sx = s[-5:]
		if 'po' in sx:
			print('FILIPINO')
		elif ('desu' or 'masu' in sx) and sx != 'mnida':
			print('JAPANESE')
		elif 'mnida' == sx:
			print('KOREAN')
	n -= 1


t = int(input())
for i in range(t):
	s = input()
	for i in range(len(s)):
		s1 = 'po'
		s2 = 'desu'
		s3 = 'masu'
		s4 = 'mnida'
		if s1 in s[len(s) - 2:len(s)]:
			print('FILIPINO')
			break
		elif s2 in s[len(s) - 4:len(s)] or s3 in s[len(s) - 4:len(s)]:
			print('JAPANESE')
			break
		elif s4 in s[len(s) - 5:len(s)]:
			print('KOREAN')
			break
		else:
			pass


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


n = int(input())
a = [input() for i in range(n)]
for i in a:
	if i[-1:-3:-1] == 'op':
		print('FILIPINO')
	elif i[-1:-5:-1] == 'used' or i[-1:-5:-1] == 'usam':
		print('JAPANESE')
	elif i[-1:-6:-1] == 'adinm':
		print('KOREAN')


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


for _ in range(int(input())):
	string = input()
	if string[len(string) - 1] == 'o':
		print('FILIPINO')
	elif string[len(string) - 1] == 'a':
		print('KOREAN')
	else:
		print('JAPANESE')


import sys
from collections import defaultdict, deque
from math import sqrt

def input():
	return sys.stdin.readline()[:-1]
t = int(input())
for _ in range(t):
	s = input()[-5:]
	if 'po' in s:
		print('FILIPINO')
	elif 'mnida' in s:
		print('KOREAN')
	else:
		print('JAPANESE')


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


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


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


n = int(input())
d = []
for i in range(n):
	b = input()
	a = b[-2:]
	if 'po' == a:
		d.append('FILIPINO')
	elif 'su' == a:
		d.append('JAPANESE')
	else:
		d.append('KOREAN')
for i in range(len(d)):
	print(d[i])


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


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


for t in range(int(input())):
	s = list(input().split('_'))
	ln = len(s)
	x = s[len(s) - 1]
	ln = len(x)
	if ln < 4:
		print('FILIPINO')
	elif ln == 4:
		y = x[ln - 4:ln]
		if y[2:4] == 'po':
			print('FILIPINO')
		else:
			print('JAPANESE')
	elif ln == 5 and x == 'mnida':
		print('KOREAN')
	else:
		y = x[ln - 5:ln]
		if y == 'mnida':
			print('KOREAN')
		elif y[3:5] == 'po':
			print('FILIPINO')
		else:
			print('JAPANESE')


n = int(input())
i = 0
while i < n:
	s = input()
	if s[len(s) - 2] == 's':
		print('JAPANESE')
	elif s[len(s) - 2] == 'p':
		print('FILIPINO')
	else:
		print('KOREAN')
	i += 1


def languages(s):
	if s[-2:] == 'po':
		return 'FILIPINO'
	if s[-4:] == 'desu' or s[-4:] == 'masu':
		return 'JAPANESE'
	else:
		return 'KOREAN'
t = int(input())
for i in range(t):
	s = input()
	print(languages(s))


tc = int(input())
for _ in range(tc):
	string = input()
	Lang = {'op': 'FILIPINO', 'used': 'JAPANESE', 'usam': 'JAPANESE', 'adinm': 'KOREAN'}
	suffix = ''
	cnt = 0
	n = len(string)
	while cnt < 5:
		suffix += string[n - cnt - 1]
		cnt += 1
		if suffix in Lang:
			print(Lang[suffix])
			break


n = int(input())
for case in range(n):
	word = input()
	if word[-2:] == 'po':
		print('FILIPINO')
	elif word[-2:] == 'su':
		print('JAPANESE')
	else:
		print('KOREAN')


(l, solution) = ([], [])
n = int(input())
lines = ''

def solve(i):
	if i.endswith('po'):
		return 'FILIPINO'
	elif i.endswith('desu') or i.endswith('masu'):
		return 'JAPANESE'
	elif i.endswith('mnida'):
		return 'KOREAN'
	else:
		return ' '
for i in range(n):
	lines = input()
	result = solve(lines)
	solution.append(result)
for i in solution:
	print(i)


for i in range(int(input())):
	s = input()
	res = 'FILIPINO'
	if s.endswith('desu') or s.endswith('masu'):
		res = 'JAPANESE'
	elif s.endswith('mnida'):
		res = 'KOREAN'
	print(res)


num = int(input())
strings = []
for i in range(0, num):
	strings.append(input())
for string in strings:
	reversed_string = string[::-1]
	if reversed_string.startswith('op'):
		print('FILIPINO')
	elif reversed_string.startswith('used') or reversed_string.startswith('usam'):
		print('JAPANESE')
	else:
		print('KOREAN')


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


n = int(input())
for i in range(n):
	s = input()
	L1 = s[len(s) - 2:]
	L2 = s[len(s) - 4:]
	L3 = s[len(s) - 5:]
	if L1 == 'po':
		print('FILIPINO')
	elif L2 == 'desu' or L2 == 'masu':
		print('JAPANESE')
	elif L3 == 'mnida':
		print('KOREAN')


for i in [0] * int(input()):
	a = input()
	a = a[::-1]
	a = a[:5]
	if 'used' in a or 'usam' in a:
		print('JAPANESE')
	elif 'op' in a:
		print('FILIPINO')
	elif 'adinm' in a:
		print('KOREAN')


def solve(arr):
	ans = []
	for x in arr:
		if x.endswith('po'):
			ans.append('FILIPINO')
		elif x.endswith('desu') or x.endswith('masu'):
			ans.append('JAPANESE')
		elif x.endswith('mnida'):
			ans.append('KOREAN')
	return '\n'.join(ans)
arr = []
for i in range(int(input())):
	arr.append(input())
print(solve(arr))


t = int(input())
for i in range(0, t):
	s = input()
	x = s[-1]
	if x == 'u':
		print('JAPANESE')
	elif x == 'o':
		print('FILIPINO')
	elif x == 'a':
		print('KOREAN')


import sys
from sys import stdin, stdout
import bisect
import math
import heapq

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
import math

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def main():
	t = inin()
	for _ in range(t):
		a = sin()
		n = len(a)
		b = a[n - 5:]
		c = a[n - 4:]
		d = a[n - 2:]
		if b == 'mnida':
			print('KOREAN')
		elif c == 'masu' or c == 'desu':
			print('JAPANESE')
		else:
			print('FILIPINO')
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


for _ in range(int(input())):
	line = input()
	word = line[-5:] if len(line) > 5 else line
	if 'mnida' in word:
		print('KOREAN')
	elif 'po' in word:
		print('FILIPINO')
	else:
		print('JAPANESE')


n = int(input())
for x in range(n):
	v = input()
	L = []
	for bogstaver in v:
		L.append(bogstaver)
	if L[-1] == 'o':
		print('FILIPINO')
	elif L[-1] == 'u':
		print('JAPANESE')
	else:
		print('KOREAN')


t = int(input())
for i in range(t):
	sen = input()
	last_4 = sen[-4:]
	last_2 = sen[-2:]
	if last_4 == 'desu' or last_4 == 'masu':
		print('JAPANESE')
	elif last_2 == 'po':
		print('FILIPINO')
	else:
		print('KOREAN')


t = int(input())
for k in range(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')
	else:
		print('KOREAN')


t = int(input())
for i in range(t):
	string = input()
	if string[-1] == 'o':
		print('FILIPINO')
	elif string[-1] == 'u':
		print('JAPANESE')
	elif string[-1] == 'a':
		print('KOREAN')


t = int(input())
while t > 0:
	s = input()
	n = []
	for i in s:
		n.append(i)
	n.reverse()
	if ''.join(n[0:2][::-1]) == 'po':
		print('FILIPINO')
	elif ''.join(n[0:4][::-1]) == 'desu' or ''.join(n[0:4][::-1]) == 'masu':
		print('JAPANESE')
	else:
		print('KOREAN')
	t -= 1


t = int(input())
l1 = []
for i in range(t):
	l1.append(input())
for i in l1:
	if i[-2:] == 'po':
		print('FILIPINO')
	elif i[-4:] == 'desu' or i[-4:] == 'masu':
		print('JAPANESE')
	else:
		print('KOREAN')


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


import sys
d = {'po': 'FILIPINO', 'mnida': 'KOREAN', 'desu': 'JAPANESE', 'masu': 'JAPANESE'}
for _ in range(int(sys.stdin.readline())):
	s = sys.stdin.readline().strip()
	st = s[-2:]
	if st in d:
		print(d[st])
		continue
	st = s[-4:]
	if st in d:
		print(d[st])
		continue
	st = s[-5:]
	print(d[st])


import sys, queue, copy
sys.setrecursionlimit(10 ** 8)

def inpl():
	return list(map(int, sys.stdin.readline().split()))

def inpl_str():
	return list(sys.stdin.readline().split())
INF = float('inf')
q = int(input())
for _ in range(q):
	s = input()
	if s[len(s) - 1] == 'o':
		print('FILIPINO')
		continue
	elif s[len(s) - 1] == 'u':
		print('JAPANESE')
		continue
	elif s[len(s) - 1] == 'a':
		print('KOREAN')
		continue


dic = {'po': 'FILIPINO', 'desu': 'JAPANESE', 'masu': 'JAPANESE', 'mnida': 'KOREAN'}
n = int(input())
for i in range(n):
	pal = input()
	for k in dic.keys():
		if pal.endswith(k):
			print(dic[k])


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


x = int(input())
a = list()
for i in range(x):
	a.append(input())
for j in a:
	if j.endswith('po'):
		print('FILIPINO')
	elif j.endswith('desu') or j.endswith('masu'):
		print('JAPANESE')
	else:
		print('KOREAN')


t = int(input())
while t > 0:
	t -= 1
	s = input()
	p = s[len(s) - 1]
	if p == 'u':
		print('JAPANESE')
	elif p == 'o':
		print('FILIPINO')
	else:
		print('KOREAN')


l = int(input())
for i in range(l):
	a = list(input())
	n = len(a)
	if a[n - 2] + a[n - 1] == 'po':
		print('FILIPINO')
	elif a[n - 5] + a[n - 4] + a[n - 3] + a[n - 2] + a[n - 1] == 'mnida':
		print('KOREAN')
	else:
		print('JAPANESE')


import sys
input = sys.stdin.readline

def getInt():
	return int(input())

def getVars():
	return 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 i in range(n):
	x = input()
	if (x[-2] == 'p') & (x[-1] == 'o'):
		print('FILIPINO')
	elif (x[-1] == 'u') & (x[-2] == 's'):
		if (x[-3] == 'e') & (x[-4] == 'd') | (x[-3] == 'a') & (x[-4] == 'm'):
			print('JAPANESE')
	else:
		print('KOREAN')


d = {'o': 'FILIPINO', 'u': 'JAPANESE', 'a': 'KOREAN'}
n = int(input())
for _ in range(n):
	print(d[input()[-1]])


n = int(input())
ans = []
for i in range(n):
	s = input()
	if s[len(s) - 1] == 'o':
		ans.append('FILIPINO')
	elif s[len(s) - 1] == 'u':
		ans.append('JAPANESE')
	elif s[len(s) - 1] == 'a':
		ans.append('KOREAN')
for i in range(len(ans)):
	print(ans[i])


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


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


n = int(input())
for _ in range(0, n):
	st = input()
	if st[-2:] == 'po':
		print('FILIPINO')
	elif st[-5:] == 'mnida':
		print('KOREAN')
	else:
		print('JAPANESE')


import re
for _ in range(int(input())):
	s = input()
	if re.findall('mnida$', s):
		print('KOREAN')
	elif re.findall('po$', s):
		print('FILIPINO')
	else:
		print('JAPANESE')


n = int(input())
for _ in range(n):
	s = input()
	x = len(s)
	if s[x - 1] == 'o' and s[x - 2] == 'p':
		print('FILIPINO')
	elif s[x - 1] == 'a' and s[x - 2] == 'd' and (s[x - 3] == 'i') and (s[x - 4] == 'n') and (s[x - 5] == 'm'):
		print('KOREAN')
	elif s[x - 1] == 'u' and s[x - 2] == 's' and (s[x - 3] == 'e') and (s[x - 4] == 'd') or (s[x - 1] == 'u' and s[x - 2] == 's' and (s[x - 3] == 'a') and (s[x - 4] == 'm')):
		print('JAPANESE')


n = int(input())
for i in range(n):
	cur = input().rstrip()
	if cur[-2:] == 'po':
		print('FILIPINO')
	elif cur[-5:] == 'mnida':
		print('KOREAN')
	else:
		print('JAPANESE')


t = int(input())
while t:
	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 -= 1


def lang(s):
	if s[-2:] == 'po':
		return 'FILIPINO'
	elif s[-4:] == 'desu':
		return 'JAPANESE'
	elif s[-4:] == 'masu':
		return 'JAPANESE'
	elif s[-5:] == 'mnida':
		return 'KOREAN'
t = int(input())
for i in range(t):
	s = input().rstrip()
	print(lang(s))


for _ in range(int(input())):
	s = input()
	s = s[::-1]
	if 'op' in s and s[0] == 'o':
		print('FILIPINO')
	elif ('used' in s or 'usam' in s) and s[0] == 'u':
		print('JAPANESE')
	else:
		print('KOREAN')


import sys

def main():
	inp = sys.stdin.read().strip().split('\n')[1:]
	d = {'po': 'FILIPINO', 'desu': 'JAPANESE', 'masu': 'JAPANESE', 'mnida': 'KOREAN'}
	out = []
	for s in inp:
		for k in d:
			if s.endswith(k):
				out.append(d[k])
				break
	return out
print(*main(), sep='\n')


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


def tod(word):
	return [char for char in word]
x = int(input())
r = 0
a = list()
while r < x:
	b = input()
	c = tod(b)
	if c[-2:] == ['p', 'o']:
		a.append('FILIPINO')
	if c[-4:] == ['d', 'e', 's', 'u'] or c[-4:] == ['m', 'a', 's', 'u']:
		a.append('JAPANESE')
	if c[-5:] == ['m', 'n', 'i', 'd', 'a']:
		a.append('KOREAN')
	r = r + 1
r = 0
while r < x:
	print(a[r])
	r = r + 1


t = int(input())
if 1 <= t <= 30:
	for i in range(t):
		a = input()
		f = len(a)
		b = 'po'
		c = 'desu'
		d = 'masu'
		e = 'mnida'
		if f == 2:
			if b in a:
				print('FILIPINO')
		if f > 2:
			k = [a[f - 5], a[f - 4], a[f - 3], a[f - 2], a[f - 1]]
			h = ''.join(map(str, k))
			if c in h:
				print('JAPANESE')
			elif d in h:
				print('JAPANESE')
			elif e in h:
				print('KOREAN')
			elif b in h:
				print('FILIPINO')
			k.clear()


n = int(input())
a = ''
for i in range(n):
	a += input()
	a += ' '
a = a.split()
for i in a:
	if i[-2:] == 'po':
		print('FILIPINO')
	elif i[-2:] == 'su':
		print('JAPANESE')
	elif i[-2:] == 'da':
		print('KOREAN')


inp = int(input())
i = 0
while i < inp:
	word = input()
	if word[len(word) - 1] == 'o':
		print('FILIPINO')
	elif word[len(word) - 1] == 'u':
		print('JAPANESE')
	else:
		print('KOREAN')
	i = i + 1


n = int(input())
arr = [str(input()) for _ in range(n)]
brr = list(map(lambda x: 'FILIPINO' if x[-1] == 'o' else 'JAPANESE' if x[-1] == 'u' else 'KOREAN', arr))
print('\n'.join(brr))


t = int(input())
myList = []
result = []
i = 0
while i < t:
	myList.append(str(input()))
	i += 1
for line in myList:
	if line[-1] == 'o':
		result.append('FILIPINO')
	elif line[-1] == 'u':
		result.append('JAPANESE')
	else:
		result.append('KOREAN')
for r in result:
	print(r)


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


num = int(input())
l = []
for i in range(1, num + 1):
	str = input()
	a = str.lower()
	a = str[-2:-1:1] + str[-1]
	if a == 'po':
		l.append('FILIPINO')
	elif str[-4:-1:1] + str[-1] == 'desu' or str[-4:-1:1] + str[-1] == 'masu':
		l.append('JAPANESE')
	elif str[-5:-1:1] + str[-1] == 'mnida':
		l.append('KOREAN')
for i in l:
	print(i)


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


for _ in range(int(input())):
	s = input()
	s = s[::-1]
	if 'op' == s[:2]:
		print('FILIPINO')
	elif 'usam' == s[:4]:
		print('JAPANESE')
	elif 'used' == s[:4]:
		print('JAPANESE')
	elif 'adinm' == s[:5]:
		print('KOREAN')


n = int(input())
lines = []
for i in range(n):
	line = input()
	if line:
		lines.append(line)
	else:
		break
for i in lines:
	if i[-1] == 'o':
		print('FILIPINO')
	elif i[-1] == 'u':
		print('JAPANESE')
	else:
		print('KOREAN')


t = int(input())
for i in range(t):
	s = input().strip().split(' ')
	x = s[-1]
	t = len(x)
	s1 = 'po'
	s2 = 'desu'
	s3 = 'masu'
	s4 = 'mnida'
	if t >= 5:
		temp = x[len(x) - 5:len(x)]
		if temp == 'mnida':
			print('KOREAN')
		temp = x[len(x) - 2:len(x)]
		if temp == 'po':
			print('FILIPINO')
		temp = x[len(x) - 4:len(x)]
		if temp == 'masu' or temp == 'desu':
			print('JAPANESE')
	elif t >= 4:
		temp = x[len(x) - 2:len(x)]
		if temp == 'po':
			print('FILIPINO')
		temp = x[len(x) - 4:len(x)]
		if temp == 'masu' or temp == 'desu':
			print('JAPANESE')
	elif t >= 2:
		temp = x[len(x) - 2:len(x)]
		if temp == 'po':
			print('FILIPINO')


t = int(input())
for i in range(t):
	str = input()
	if 'op' in str[-1:-3:-1]:
		print('FILIPINO')
	elif 'used' in str[-1:-5:-1] or 'usam' in str[-1:-5:-1]:
		print('JAPANESE')
	elif 'adinm' in str[-1:-6:-1]:
		print('KOREAN')


n = int(input())
for i in range(n):
	n = list(input())
	a = n[-1]
	b = n[-2]
	if a == 'o' and b == 'p':
		print('FILIPINO')
	elif a == 'u' and b == 's':
		print('JAPANESE')
	else:
		print('KOREAN')


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


from bisect import bisect_left, bisect_right

def main():
	st = input()
	if 'po' in st and st[-2:] == 'po':
		print('FILIPINO')
	elif 'desu' in st and st[-4:] == 'desu':
		print('JAPANESE')
	elif 'masu' in st and st[-4:] == 'masu':
		print('JAPANESE')
	else:
		print('KOREAN')
import sys
out = []
get_int = lambda : int(input())
get_list = lambda : list(map(int, input().split()))
[main() for _ in range(int(input()))]


t = int(input())
while t:
	s = input()
	if s[-2:] == 'po':
		print('FILIPINO')
	elif s[-5:] == 'mnida':
		print('KOREAN')
	else:
		print('JAPANESE')
	t -= 1


t = int(input())
for _ in range(t):
	n = input()
	n = n[::-1]
	if n[:2] == 'op':
		print('FILIPINO')
	elif n[:4] == 'used' or n[:4] == 'usam':
		print('JAPANESE')
	elif n[:5] == 'adinm':
		print('KOREAN')


g = ['FILIPINO', 'JAPANESE', 'KOREAN']
cases = int(input())
for _ in range(cases):
	n = input()
	if n.endswith('po'):
		print(g[0])
	elif n.endswith('desu') or n.endswith('masu'):
		print(g[1])
	else:
		print(g[2])


n = int(input())
l = []
for i in range(0, n):
	s = input()
	l.append(s)
for i in range(0, n):
	if l[i][-1] == 'u':
		print('JAPANESE')
	elif l[i][-1] == 'o':
		print('FILIPINO')
	elif l[i][-1] == 'a':
		print('KOREAN')


n = int(input())
lst = []
for i in range(n):
	n1 = input()
	if n1.endswith('desu') or n1.endswith('masu'):
		lst.append('JAPANESE')
	elif n1.endswith('po'):
		lst.append('FILIPINO')
	elif n1.endswith('mnida'):
		lst.append('KOREAN')
for j in lst:
	print(j)


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


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


n = int(input())
l1 = []
while n > 0:
	s = input()
	res = s[-2:]
	res1 = s[-4:]
	res2 = s[-5:]
	if res == 'po':
		l1.append('FILIPINO')
	if res1 == 'desu' or res1 == 'masu':
		l1.append('JAPANESE')
	if res2 == 'mnida':
		l1.append('KOREAN')
	n = n - 1
for i in range(len(l1)):
	print(l1[i])


import sys
import os
import time
__ONPC = os.getenv('SAKOSTONPC') is not None
if __ONPC:
	__now = time.time()
	sys.stdout = open('output.txt', 'w')
	sys.stdin = open('input.txt', 'r')
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')
if __ONPC:
	print('Elapsed time:', time.time() - __now, file=sys.stderr)


masukan = int(input())
tampung = []
for i in range(masukan):
	tampung += input().split()
for i in range(len(tampung)):
	if tampung[i][-1] == 'o':
		print('FILIPINO')
	elif tampung[i][-1] == 'u':
		print('JAPANESE')
	elif tampung[i][-1] == 'a':
		print('KOREAN')


def func(st):
	if st[-2:] == 'po':
		return 'FILIPINO'
	elif st[-4:] == 'desu' or st[-4:] == 'masu':
		return 'JAPANESE'
	else:
		return 'KOREAN'
t = int(input())
while t > 0:
	st = input()
	print(func(st))
	t -= 1


from math import *
from copy import *
from string import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
from collections import defaultdict

def solve(s):
	n = len(s)
	s = s[::-1]
	if s[:2] == 'op':
		return 'FILIPINO'
	elif s[:4] == 'used':
		return 'JAPANESE'
	elif s[:4] == 'usam':
		return 'JAPANESE'
	elif s[:5] == 'adinm':
		return 'KOREAN'
T = int(input())
for _ in range(T):
	s = input()
	print(solve(s))


for _ in range(int(input())):
	a = input()
	smth = a[-2:]
	if smth == 'po':
		print('FILIPINO')
	elif smth == 'su':
		print('JAPANESE')
	else:
		print('KOREAN')


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()


a = []
n = int(input())
for _ in range(n):
	b = input()
	a.append(b)
for i in range(n):
	if a[i][-1] == 'o':
		print('FILIPINO')
	elif a[i][-1] == 'u':
		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')
for i in range(t):
	main()


n = int(input())
for i in range(n):
	x = list(input())
	l = len(x)
	if x[l - 1] == 'o':
		print('FILIPINO')
	if x[l - 1] == 'u':
		print('JAPANESE')
	if x[l - 1] == 'a':
		print('KOREAN')


def f(s, p):
	(p1, p2) = (len(s) - 1, 0)
	while p2 < len(p) and p1 >= 0:
		if s[p1] == p[p2]:
			p1 -= 1
			p2 += 1
		else:
			return False
	return True
for _ in range(int(input())):
	s = str(input())
	if f(s, 'op') == True:
		print('FILIPINO')
	elif f(s, 'used') == True or f(s, 'usam') == True:
		print('JAPANESE')
	elif f(s, 'adinm') == True:
		print('KOREAN')


def solve(s):
	if len(s) >= 2 and s[-2:] == 'po':
		return 'FILIPINO'
	if len(s) >= 4 and s[-4:] == 'masu' or s[-4:] == 'desu':
		return 'JAPANESE'
	if len(s) >= 5 and s[-5:] == 'mnida':
		return 'KOREAN'
for i in range(int(input())):
	print(solve(input()))


def check(s):
	x = s[-1]
	if x == 'o':
		return 'FILIPINO'
	elif x == 'u':
		return 'JAPANESE'
	return 'KOREAN'
t = int(input())
for i in range(t):
	print(check(input()))


s = int(input())
names = []
for i in range(s):
	nam = input()
	names.append(nam)
language = []
for i in names:
	a = i[::-1]
	if a[0:2] == 'us':
		print('JAPANESE')
	elif a[0:2] == 'op':
		print('FILIPINO')
	elif a[0:2] == 'ad':
		print('KOREAN')


N = int(input())
arr = []
result = []
for i in range(N):
	arr.append(input())
arr = [i.split('_')[-1] for i in arr]
for i in arr:
	if i[-2:] == 'po':
		result.append('FILIPINO')
	elif i[-4:] == 'masu' or i[-4:] == 'desu':
		result.append('JAPANESE')
	else:
		result.append('KOREAN')
for i in result:
	print(i)


n = int(input())
li = []
for i in range(n):
	li.append(input())
for i in range(len(li)):
	if li[i][-2:] == 'po':
		print('FILIPINO')
	elif li[i][-4:] == 'desu':
		print('JAPANESE')
	elif li[i][-4:] == 'masu':
		print('JAPANESE')
	else:
		print('KOREAN')


t = int(input())
for c in range(t):
	kp = input()
	if len(kp) >= 2 and kp[-2:] == 'po':
		print('FILIPINO')
	elif len(kp) >= 4 and (kp[-4:] == 'desu' or kp[-4:] == 'masu'):
		print('JAPANESE')
	elif len(kp) >= 5 and kp[-5:] == 'mnida':
		print('KOREAN')


s = int(input())
l = list()
for i in range(s):
	w = input()
	l.append(w)
for w in l:
	if w.endswith('po'):
		print('FILIPINO')
	elif w.endswith('desu') or w.endswith('masu'):
		print('JAPANESE')
	elif w.endswith('mnida'):
		print('KOREAN')


for i in range(int(input())):
	s = input().split('_')
	if s[len(s) - 1][len(s[len(s) - 1]) - 2] == 'p':
		print('FILIPINO')
	elif s[len(s) - 1][len(s[len(s) - 1]) - 2] == 'd':
		print('KOREAN')
	else:
		print('JAPANESE')


t = int(input())
for i in range(t):
	text = input()
	if text.endswith('po'):
		print('FILIPINO')
	elif text.endswith('desu') or text.endswith('masu'):
		print('JAPANESE')
	elif text.endswith('mnida'):
		print('KOREAN')


t = int(input())
for _ in range(t):
	s = input()
	a = s.rfind('po')
	b = s.rfind('desu')
	c = s.rfind('masu')
	d = s.rfind('mnida')
	if s.count('po') != 0 and a + 2 == len(s):
		print('FILIPINO')
	elif s.count('desu') != 0 and b + 4 == len(s):
		print('JAPANESE')
	elif s.count('masu') != 0 and c + 4 == len(s):
		print('JAPANESE')
	elif s.count('mnida') != 0 and d + 5 == len(s):
		print('KOREAN')


t = int(input())
for i in range(t):
	s = input()
	s = s[::-1]
	if s.startswith('op'):
		res = 'FILIPINO'
	elif s.startswith('used') or s.startswith('usam'):
		res = 'JAPANESE'
	else:
		res = 'KOREAN'
	print(res)


LANG = {'su': 'JAPANESE', 'da': 'KOREAN', 'po': 'FILIPINO'}
for _ in range(int(input())):
	print(LANG[str(input())[-2:]])


for _ in range(int(input())):
	s = input()
	if len(s) >= 5:
		a = s[-5:]
		if a == 'mnida':
			print('KOREAN')
		else:
			f = False
			a = a[-4:]
			if a == 'desu' or a == 'masu':
				print('JAPANESE')
				f = True
			if f == False:
				print('FILIPINO')
	elif len(s) == 4:
		f = False
		a = s[-4:]
		if a == 'desu' or a == 'masu':
			print('JAPANESE')
			f = True
		if f == False:
			print('FILIPINO')
	else:
		print('FILIPINO')


n = int(input())
for _ in range(n):
	string = input()
	first = string[-2:]
	second = string[-4:]
	third = string[-4:]
	four = string[-5:]
	if first == 'po':
		lang = 'FILIPINO'
	elif second == 'desu' or third == 'masu':
		lang = 'JAPANESE'
	elif four == 'mnida':
		lang = 'KOREAN'
	print(lang)


import re
n = int(input())
for i in range(n):
	st = input()
	if re.findall('po$', st):
		print('FILIPINO')
	elif re.findall('desu$', st) or re.findall('masu$', st):
		print('JAPANESE')
	else:
		print('KOREAN')


n = int(input())
for i in range(n):
	c = input()
	if c[len(c) - 2:len(c)] == 'po':
		print('FILIPINO')
	if c[len(c) - 4:len(c)] == 'desu' or c[len(c) - 4:len(c)] == 'masu':
		print('JAPANESE')
	if c[len(c) - 5:len(c)] == 'mnida':
		print('KOREAN')


n = int(input())
for i in range(n):
	h = str(input())
	h = list(h)
	k = len(h)
	if h[k - 1] == 'a':
		print('KOREAN')
	elif h[k - 1] == 'u':
		print('JAPANESE')
	elif h[k - 1] == 'o':
		print('FILIPINO')


num = int(input())
l = []
for i in range(0, num):
	l.append(input())
for i in range(0, len(l)):
	temp = list(l[i])
	if temp[len(l[i]) - 1] == 'o':
		print('FILIPINO')
	elif temp[len(l[i]) - 1] == 'u':
		print('JAPANESE')
	else:
		print('KOREAN')


from sys import stdin, stdout
data = stdin.readlines()
for line in data[1:]:
	line = line[:-1]
	if line.endswith('po'):
		stdout.write('FILIPINO\n')
	elif line.endswith('mnida'):
		stdout.write('KOREAN\n')
	else:
		stdout.write('JAPANESE\n')


def suffix():
	numero_frasi = int(input())
	for i in range(numero_frasi):
		i = input()
		if i.endswith('po'):
			print('FILIPINO')
		elif i.endswith('su'):
			print('JAPANESE')
		elif i.endswith('mnida'):
			print('KOREAN')
suffix()


T = int(input())
for t in range(T):
	string = input()
	if string[-1:-3:-1][::-1] == 'po':
		print('FILIPINO')
	elif string[-1:-5:-1][::-1] == 'desu' or string[-1:-5:-1][::-1] == 'masu':
		print('JAPANESE')
	else:
		print('KOREAN')


nos = int(input())
for i in range(nos):
	aa = input()
	mm = aa[-5:]
	if mm == 'mnida':
		print('KOREAN')
	elif mm[-4:] == 'masu' or mm[-4:] == 'desu':
		print('JAPANESE')
	else:
		print('FILIPINO')


t = int(input())
l = []
for i in range(t):
	s = input()
	s1 = s[::-1]
	if 'op' in s1[:2]:
		l.append('FILIPINO')
	elif 'used' in s1[:4] or 'usam' in s1[:4]:
		l.append('JAPANESE')
	elif 'adinm' in s1[:5]:
		l.append('KOREAN')
for i in l:
	print(i)


def main():
	in_str = input()
	if in_str[-1] == 'o':
		print('FILIPINO')
	if in_str[-1] == 'u':
		print('JAPANESE')
	if in_str[-1] == 'a':
		print('KOREAN')
count = int(input())
for i in range(count):
	main()


n = int(input())
answ = []
for i in range(n):
	str = input()
	if str[-2:] == 'po':
		answ.append('FILIPINO')
	elif str[-4:] == 'desu' or str[-4:] == 'masu':
		answ.append('JAPANESE')
	elif str[-5:] == 'mnida':
		answ.append('KOREAN')
print('\n'.join(answ))


for _ in range(int(input())):
	n = input()
	t = n.split('_')
	s = t[-1]
	if s[-1:-3:-1] == 'op':
		print('FILIPINO')
	elif s[-1:-5:-1] == 'used' or s[-1:-5:-1] == 'usam':
		print('JAPANESE')
	elif s[-1:-6:-1] == 'adinm':
		print('KOREAN')


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


t = int(input())
for i in range(t):
	n = input()
	n = list(n)
	n.reverse()
	if n[0] == 'o':
		print('FILIPINO')
	elif n[0] == 'u':
		print('JAPANESE')
	elif n[0] == 'a':
		print('KOREAN')


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()


t = int(input())
for i in range(t):
	word = input()
	if word.endswith('po'):
		print('FILIPINO')
	elif word.endswith('mnida'):
		print('KOREAN')
	else:
		print('JAPANESE')


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


import sys

def my_strip(string):
	return string[:-1]
t = int(sys.stdin.readline())
test_cases = list(map(my_strip, sys.stdin.readlines()))

def suffix_three(t, test_cases):
	for i in range(t):
		if test_cases[i][-2:] == 'po':
			print('FILIPINO')
		elif test_cases[i][-4:] == 'desu' or test_cases[i][-4:] == 'masu':
			print('JAPANESE')
		else:
			print('KOREAN')
suffix_three(t, test_cases)


n = int(input())
for i in range(1, n + 1):
	s = list(input())
	c = len(s) - 1
	if s[-2] + s[-1] == 'po':
		print('FILIPINO')
	elif s[-4] + s[-3] + s[-2] + s[-1] == 'desu' or s[-4] + s[-3] + s[-2] + s[-1] == 'masu':
		print('JAPANESE')
	elif s[-5] + s[-4] + s[-3] + s[-2] + s[-1] == 'mnida':
		print('KOREAN')


t = int(input())
a = []
for i in range(0, t):
	s = input()
	if s[-2:] == 'po':
		a.append('FILIPINO')
	elif s[-5:] == 'mnida':
		a.append('KOREAN')
	else:
		a.append('JAPANESE')
b = '\n'
print(b.join(a))


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])


n = int(input())
i = 0
while i < n:
	string = input()
	if string[-2:] == 'po':
		print('FILIPINO')
	elif string[-4:] == 'desu' or string[-4:] == 'masu':
		print('JAPANESE')
	elif string[-5:] == 'mnida':
		print('KOREAN')
	i += 1


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()


from math import *
from collections import *
import sys
sys.setrecursionlimit(10 ** 9)
mod = 10 ** 9 + 7
t = int(input())
for y in range(t):
	s = input()
	l = len(s)
	if s[l - 2:l] == 'po':
		print('FILIPINO')
	elif s[l - 4:l] == 'desu' or s[l - 4:l] == 'masu':
		print('JAPANESE')
	else:
		print('KOREAN')


t = int(input())
for i in range(t):
	s = str(input())
	s = '1111' + s
	if s[-2] + s[-1] == 'po':
		print('FILIPINO')
	elif s[len(s) - 5:len(s)] == 'mnida':
		print('KOREAN')
	else:
		print('JAPANESE')


import math
n = int(input())
for i in range(n):
	st = input()
	if st.endswith('po'):
		print('FILIPINO')
	elif st.endswith('mnida'):
		print('KOREAN')
	else:
		print('JAPANESE')


import sys
data = [ent.split()[0] for ent in sys.stdin.readlines()]
for i in range(len(data) - 1):
	if data[i + 1][-len('po'):] == 'po':
		sys.stdout.write('FILIPINO\n')
	elif data[i + 1][-len('masu'):] == 'masu' or data[i + 1][-len('desu'):] == 'desu':
		sys.stdout.write('JAPANESE\n')
	elif data[i + 1][-len('mnida'):] == 'mnida':
		sys.stdout.write('KOREAN\n')


for _ in range(int(input())):
	s = input()
	f = 1
	j = 1
	k = 1
	s1 = s[len(s) - 2:len(s)]
	if s1 == 'po':
		f = 1
		j = 0
		k = 0
	s1 = s[len(s) - 4:len(s)]
	if s1 == 'desu' or s1 == 'masu':
		f = 0
		j = 1
		k = 0
	s1 = s[len(s) - 5:len(s)]
	if s1 == 'mnida':
		f = 0
		j = 0
		k = 1
	if f == 1:
		print('FILIPINO')
	elif j == 1:
		print('JAPANESE')
	else:
		print('KOREAN')


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


t = int(input())
for i in range(t):
	case = input().split('_')
	if case[-1][-1] == 'o':
		print('FILIPINO')
	elif case[-1][-1] == 'u':
		print('JAPANESE')
	elif case[-1][-1] == 'a':
		print('KOREAN')


n = int(input())
while n > 0:
	k = input()
	if k[len(k) - 2:] == 'po':
		print('FILIPINO')
	elif k[len(k) - 4:] == 'desu' or k[len(k) - 4:] == 'masu':
		print('JAPANESE')
	elif k[len(k) - 5:] == 'mnida':
		print('KOREAN')
	n -= 1


def suffix(ss):
	if ss.endswith('po'):
		return 'FILIPINO'
	elif ss.endswith('desu') or ss.endswith('masu'):
		return 'JAPANESE'
	return 'KOREAN'
tc = int(input())
for i in range(tc):
	ss = input()
	print(suffix(ss))


t = int(input())

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


BS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def to_base(s, b):
	res = ''
	while s:
		res += BS[s % b]
		s //= b
	return res[::-1] or '0'
alpha = 'abcdefghijklmnopqrstuvwxyz'
t = int(input())
for i in range(t):
	s = input().split('_')[-1]
	if s[-2:] == 'po':
		print('FILIPINO')
	elif s[-4:] in ['desu', 'masu']:
		print('JAPANESE')
	else:
		print('KOREAN')


for t in range(int(input())):
	s = input()
	n = len(s)
	if n <= 5:
		a = s.count('po')
		b = s.count('masu')
		bb = s.count('desu')
		c = s.count('mnida')
		if a > 0:
			print('FILIPINO')
		elif b > 0 or bb > 0:
			print('JAPANESE')
		elif c > 0:
			print('KOREAN')
		else:
			pass
	else:
		ss = s[n - 5:n]
		a = ss.count('po')
		b = ss.count('masu')
		bb = ss.count('desu')
		c = ss.count('mnida')
		if a > 0:
			print('FILIPINO')
		elif b > 0 or bb > 0:
			print('JAPANESE')
		elif c > 0:
			print('KOREAN')
		else:
			pass


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


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 : map(int, sys.stdin.readline().split())
input = lambda : sys.stdin.readline().strip()
main()


n = int(input())
a = []
for i in range(n):
	s = input()
	for j in range(len(s)):
		if s[len(s) - 1] == 'o':
			a += ['FILIPINO']
			break
		elif s[len(s) - 1] == 'u':
			a += ['JAPANESE']
			break
		elif s[len(s) - 1] == 'a':
			a += ['KOREAN']
			break
for i in a:
	print(i)


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


test = int(input())
for a_ in range(test):
	word = list(input())
	if word[-2] == 'p':
		print('FILIPINO')
	elif word[-2] == 's':
		print('JAPANESE')
	else:
		print('KOREAN')


from sys import stdin

def w(s):
	if s[len(s) - 2:] == 'po':
		return 'FILIPINO'
	if s[len(s) - 4:] in ('masu', 'desu'):
		return 'JAPANESE'
	if s[len(s) - 5:] in 'mnida':
		return 'KOREAN'
n = int(input())
for i in range(n):
	s = str(input())
	print(w(s))


def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
t = ii()
while t:
	t -= 1
	s = si()
	n = len(s)
	if s[n - 1] == 'u':
		print('JAPANESE')
	elif s[n - 1] == 'o':
		print('FILIPINO')
	else:
		print('KOREAN')


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


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


tests = int(input())
jpns = ['desu', 'masu']
fill = ['po']
kor = ['mnida']
for _ in range(tests):
	word = input()
	print('FILIPINO' if word[-2:] in fill else 'JAPANESE' if word[-4:] in jpns else 'KOREAN' if word[-5:] in kor else '')


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


def suffix_three(string):
	if string[len(string) - 2:] == 'po':
		return 'FILIPINO'
	elif string[len(string) - 4:] in ['desu', 'masu']:
		return 'JAPANESE'
	else:
		return 'KOREAN'
for _ in range(int(input())):
	print(suffix_three(input()))


n = int(input())
l = []
for i in range(n):
	a = input('')
	l.append(a)
for i in l:
	a = ''
	b = ''
	a = i[-2:]
	b = i[-4:]
	if a == 'po':
		print('FILIPINO')
	elif b == 'desu' or b == 'masu':
		print('JAPANESE')
	else:
		print('KOREAN')


tc = int(input())

def lan(o):
	if o[-2:] == 'po':
		print('FILIPINO')
	elif o[-4:] == 'desu' or o[-4:] == 'masu':
		print('JAPANESE')
	else:
		print('KOREAN')
for i in range(tc):
	o = input()
	lan(o)


n = int(input(''))
l = []
for i in range(0, n):
	a = input('')
	s = a[len(a) - 2:]
	if s == 'po':
		l.append('FILIPINO')
	else:
		s = a[len(a) - 4:]
		if s == 'desu' or s == 'masu':
			l.append('JAPANESE')
		else:
			l.append('KOREAN')
for i in l:
	print(i)


def split(word):
	return [char for char in word]
t = int(input())
q = []
for i in range(t):
	string = input()
	string = split(string)
	if string[-1] == 'o':
		q.append('FILIPINO')
	elif string[-1] == 'u':
		q.append('JAPANESE')
	else:
		q.append('KOREAN')
for i in q:
	print(i)


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


t = int(input())
L = []
for i in range(t):
	L.append(input())
for i in L:
	print('FILIPINO' if i[-1] == 'o' else 'JAPANESE' if i[-1] == 'u' else 'KOREAN')


import sys

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


n = int(input())
k = [2, 4, 5]
e = []
for i in range(n):
	a = str(input())
	b = a.split('_')
	for _ in k:
		if b[len(b) - 1][len(b[len(b) - 1]) - _:len(b[len(b) - 1])] == 'po':
			e.append('FILIPINO')
			break
		if b[len(b) - 1][len(b[len(b) - 1]) - _:len(b[len(b) - 1])] == 'desu' or b[len(b) - 1][len(b[len(b) - 1]) - _:len(b[len(b) - 1])] == 'masu':
			e.append('JAPANESE')
			break
		if b[len(b) - 1][len(b[len(b) - 1]) - _:len(b[len(b) - 1])] == 'mnida':
			e.append('KOREAN')
			break
for i in range(len(e)):
	print(e[i])


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


def solve(string):
	lista = string.split('_')
	lista = lista[-1]
	lista = 'LLLLL' + ''.join(lista)
	if lista[len(lista) - 2:] == 'po':
		print('FILIPINO')
	elif lista[len(lista) - 4:] in ['desu', 'masu']:
		print('JAPANESE')
	else:
		print('KOREAN')
n = int(input())
[solve(input()) for _ in range(n)]


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


n = input()
for i in range(0, int(n)):
	s = input()
	if s.endswith('po'):
		print('FILIPINO')
	elif s.endswith('mnida'):
		print('KOREAN')
	else:
		print('JAPANESE')


t = int(input())
for i in range(t):
	suffix = input().split('_')[-1]
	if suffix[-2:] == 'po':
		print('FILIPINO')
	elif suffix[-5:] == 'mnida':
		print('KOREAN')
	else:
		print('JAPANESE')


n = eval(input())
for i in range(n):
	st = input().split('_')
	if st[-1][-2:] == 'po':
		print('FILIPINO')
	elif st[-1][-4:] == 'desu' or st[-1][-4:] == 'masu':
		print('JAPANESE')
	elif st[-1][-5:] == 'mnida':
		print('KOREAN')


import sys
file = sys.stdin
n = int(file.readline())
for i in range(n):
	s = file.readline()
	s = s.strip('\n')
	if s[-2:] == 'po':
		print('FILIPINO')
	elif s[-4:] == 'desu' or s[-4:] == 'masu':
		print('JAPANESE')
	elif s[-5:] == 'mnida':
		print('KOREAN')


for _ in range(int(input().strip())):
	s = input().strip()
	if ''.join(s[-2:]) == 'po':
		print('FILIPINO')
	if ''.join(s[-4:]) in ['desu', 'masu']:
		print('JAPANESE')
	if ''.join(s[-5:]) == 'mnida':
		print('KOREAN')


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


t = int(input())
for i in range(t):
	s = list(input().split('_'))[-1]
	if s[-2:] == 'po':
		print('FILIPINO')
	elif s[-4:] in ('masu', 'desu'):
		print('JAPANESE')
	else:
		print('KOREAN')


i = int(input())
for k in range(i):
	line = input()
	if line[-2:] == 'po':
		print('FILIPINO')
	elif line[-5:] == 'mnida':
		print('KOREAN')
	else:
		print('JAPANESE')


n = int(input())
for _ in range(n):
	str_ = input()
	check = str_.split()[-1]
	if check[-2:] == 'po':
		print('FILIPINO')
		continue
	if check[-4:] == 'desu' or check[-4:] == 'masu':
		print('JAPANESE')
		continue
	if check[-5:] == 'mnida':
		print('KOREAN')


a = int(input())
for i in range(a):
	s = input()
	s1 = s[len(s) - 2:]
	s2 = s[len(s) - 4:]
	s3 = s[len(s) - 5:]
	if s1 == 'po':
		print('FILIPINO')
	if s2 == 'desu' or s2 == 'masu':
		print('JAPANESE')
	if s3 == 'mnida':
		print('KOREAN')


import sys
input = sys.stdin.readline
N = int(input())
Ss = [input().rstrip() for _ in range(N)]
for S in Ss:
	L = len(S)
	if L >= 5:
		if S[-5:] == 'mnida':
			print('KOREAN')
		elif S[-4:] == 'desu' or S[-4:] == 'masu':
			print('JAPANESE')
		elif S[-2:] == 'po':
			print('FILIPINO')
	elif L >= 4:
		if S[-4:] == 'desu' or S[-4:] == 'masu':
			print('JAPANESE')
		elif S[-2:] == 'po':
			print('FILIPINO')
	elif L >= 2:
		if S[-2:] == 'po':
			print('FILIPINO')


x = int(input())
for i in range(0, x):
	inputtext = input()
	if inputtext[len(inputtext) - 2:len(inputtext)] == 'po':
		print('FILIPINO')
	elif inputtext[len(inputtext) - 4:len(inputtext)] == 'desu' or inputtext[len(inputtext) - 4:len(inputtext)] == 'masu':
		print('JAPANESE')
	else:
		print('KOREAN')


import sys
n = int(input())
fili = 'FILIPINO'
jap = 'JAPANESE'
kor = 'KOREAN'
x = 0
for line in sys.stdin:
	while x < n:
		temp = str(line.rstrip())
		if temp[-1] == 'o':
			print(fili)
			break
		elif temp[-1] == 'u':
			print(jap)
			break
		else:
			print(kor)
			break
		x = x + 1


n = int(input())
for i in range(n):
	a = list(input().split('_'))
	if 'po' == a[-1][-2:]:
		print('FILIPINO')
	if 'desu' == a[-1][-4:] or 'masu' == a[-1][-4:]:
		print('JAPANESE')
	if 'mnida' in a[-1][-5:]:
		print('KOREAN')


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


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


n = int(input())
i = 1
while i <= n:
	word = input()
	length = len(word)
	if word[length - 2:length] == 'po':
		print('FILIPINO')
	elif word[length - 4:length] == 'desu' or word[length - 4:length] == 'masu':
		print('JAPANESE')
	elif word[length - 5:length] == 'mnida':
		print('KOREAN')
	i = i + 1


query = int(input())
for i in range(query):
	string = input()
	string = string[-5:]
	if 'po' in string:
		print('FILIPINO')
	elif 'desu' in string or 'masu' in string:
		print('JAPANESE')
	elif 'mnida' in string:
		print('KOREAN')


n = int(input())
ans = []
for i in range(n):
	text = list(input())
	symbol = ''.join(text[-2:])
	if symbol == 'po':
		ans.append('FILIPINO')
	if symbol == 'su':
		ans.append('JAPANESE')
	if symbol == 'da':
		ans.append('KOREAN')
[print(j) for j in ans]


def language(S):
	if S[-2:] == 'po':
		return 'FILIPINO'
	elif S[-4:] in ('desu', 'masu'):
		return 'JAPANESE'
	else:
		return 'KOREAN'
t = int(input())
for i in range(t):
	S = input()
	print(language(S))


no_of_words = int(input(''))
words = []
for no_of_words in range(0, no_of_words):
	words.append(input(''))
for word in words:
	if word[-2:] == 'po':
		print('FILIPINO')
	elif word[-4:] == 'desu' or word[-4:] == 'masu':
		print('JAPANESE')
	elif word[-5:] == 'mnida':
		print('KOREAN')


n = int(input())
while n > 0:
	s = input()
	if s[-2:] == 'po':
		print('FILIPINO')
	if s[-4:] == 'desu' or s[-4:] == 'masu':
		print('JAPANESE')
	if s[-5:] == 'mnida':
		print('KOREAN')
	n = n - 1


import re
t = int(input())
while t > 0:
	a = input()
	x = re.search('po$', a)
	y = re.search('desu$', a)
	z = re.search('mnida$', a)
	w = re.search('masu$', a)
	if x:
		print('FILIPINO')
	elif y or w:
		print('JAPANESE')
	elif z:
		print('KOREAN')
	t = t - 1


c = int(input())
i = 0
while i < c:
	a = input()
	b = len(a)
	a2 = a[b - 2:b]
	if a2 == 'po':
		print('FILIPINO')
	a3 = a[b - 4:b]
	if a3 == 'desu':
		print('JAPANESE')
	if a3 == 'masu':
		print('JAPANESE')
	a4 = a[b - 5:b]
	if a4 == 'mnida':
		print('KOREAN')
	i = i + 1


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


t = int(input())
for i in range(0, t):
	str = input()
	n = len(str)
	if str[n - 1] == 'a':
		print('KOREAN')
	elif str[n - 1] == 'o':
		print('FILIPINO')
	else:
		print('JAPANESE')


t = int(input())
res = []
for i in range(t):
	s = input()
	l = list(s)
	l = l[::-1]
	if l[0] == 'o' and l[1] == 'p':
		res.append('FILIPINO')
	elif (l[0] == 'u' and l[1] == 's') and (l[2] == 'e' and l[3] == 'd' or (l[2] == 'a' and l[3] == 'm')):
		res.append('JAPANESE')
	else:
		res.append('KOREAN')
for i in res:
	print(i)


t = int(input())
lis = []
for i in range(t):
	n = []
	a = input()
	if a[-5:].find('po') != -1:
		print('FILIPINO')
	elif a[-5:].find('desu') != -1 or a[-5:].find('masu') != -1:
		print('JAPANESE')
	elif a[-5:].find('mnida') != -1:
		print('KOREAN')


a = int(input())
mass = []
for i in range(a):
	s = input()
	if s[-1] == 'o':
		mass.append('FILIPINO')
	if s[-1] == 'u':
		mass.append('JAPANESE')
	if s[-1] == 'a':
		mass.append('KOREAN')
for i in mass:
	print(i)


T = int(input())
for t in range(T):
	given = input()
	if given[-1] == 'o':
		print('FILIPINO')
		continue
	elif given[-1] == 'u':
		print('JAPANESE')
		continue
	else:
		print('KOREAN')


for i in range(int(input())):
	x = str(input())
	if ''.join(list(x)[-2:]) == 'po':
		print('FILIPINO')
	if ''.join(list(x)[-4:]) == 'desu':
		print('JAPANESE')
	if ''.join(list(x)[-4:]) == 'masu':
		print('JAPANESE')
	if ''.join(list(x)[-5:]) == 'mnida':
		print('KOREAN')


n = int(input())
while n:
	n = n - 1
	s = input()
	if s.endswith('o'):
		print('FILIPINO')
	elif s.endswith('u'):
		print('JAPANESE')
	else:
		print('KOREAN')


n = input()
index = 0
while index < int(n):
	str = input()
	if str[-1] == 'o':
		print('FILIPINO')
	elif str[-1] == 'u':
		print('JAPANESE')
	else:
		print('KOREAN')
	index += 1


import copy
import sys
try:
	for _ in range(int(input())):
		a = input()
		if a[-1] == 'o':
			print('FILIPINO')
		elif a[-1] == 'u':
			print('JAPANESE')
		else:
			print('KOREAN')
except EOFError as e:
	pass


t = int(input())
for _ in range(t):
	l = list(map(str, input().split('_')))
	flag = -1
	if len(l[-1]) >= 2:
		if l[-1][len(l[-1]) - 2:] == 'po':
			print('FILIPINO')
			flag = 1
	if len(l[-1]) >= 4 and flag != 1:
		if l[-1][len(l[-1]) - 4:] == 'desu' or l[-1][len(l[-1]) - 4:] == 'masu':
			print('JAPANESE')
			flag = 1
	if len(l[-1]) >= 5 and flag != 1:
		if l[-1][len(l[-1]) - 5:] == 'mnida':
			print('KOREAN')
			flag = 1


import sys
t = int(input())
for tot in range(t):
	a = input()
	if a[len(a) - 2:] == 'po':
		print('FILIPINO')
	elif a[len(a) - 4:] == 'desu' or a[len(a) - 4:] == 'masu':
		print('JAPANESE')
	else:
		print('KOREAN')


nbr = int(input())
list = []
for i in range(nbr):
	list.append(input())
for i in range(nbr):
	if list[i][len(list[i]) - 1] == 'o':
		print('FILIPINO')
	elif list[i][len(list[i]) - 1] == 'a':
		print('KOREAN')
	else:
		print('JAPANESE')


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


t = int(input())
for ii in range(t):
	s = input().strip()
	if len(s) <= 2:
		check1 = s[-2] + s[-1]
		if check1 == 'po':
			print('FILIPINO')
			continue
	else:
		check1 = s[-2] + s[-1]
		if check1 == 'po':
			print('FILIPINO')
			continue
		check2 = s[-4] + s[-3] + s[-2] + s[-1]
		if check2 == 'desu' or check2 == 'masu':
			print('JAPANESE')
			continue
		check3 = s[-5] + s[-4] + s[-3] + s[-2] + s[-1]
		if check3 == 'mnida':
			print('KOREAN')


n = int(input())
for el in range(n):
	a = input()
	if a[-2:] == 'po':
		print('FILIPINO')
	elif a[-4:] == 'desu':
		print('JAPANESE')
	elif a[-4:] == 'masu':
		print('JAPANESE')
	else:
		print('KOREAN')


def language_test():
	s = input()
	print('FILIPINO') if s[-2:] == 'po' else print('JAPANESE') if s[-4:] == 'desu' or s[-4:] == 'masu' else print('KOREAN')
for i in ' ' * int(input()):
	language_test()


n = int(input())
tests = []
for i in range(n):
	tests.append(str(input()))
for i in tests:
	if i[-2:] == 'po':
		print('FILIPINO')
	elif i[-5:] == 'mnida':
		print('KOREAN')
	else:
		print('JAPANESE')


n = int(input())
my_list = []
for i in range(n):
	a = str(input())
	if a[-2:] == 'po':
		my_list.append('FILIPINO')
	elif a[-4:] == 'desu' or a[-4:] == 'masu':
		my_list.append('JAPANESE')
	elif a[-5:] == 'mnida':
		my_list.append('KOREAN')
for y in range(n):
	print(my_list[y])


import sys
r = lambda : sys.stdin.readline().rstrip()
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')


for _ in range(int(input())):
	s = str(input())
	a = len(s)
	if s[a - 2] == 'p' and s[a - 1] == 'o':
		print('FILIPINO')
	elif s[a - 4] == 'd' and s[a - 3] == 'e' and (s[a - 2] == 's') and (s[a - 1] == 'u'):
		print('JAPANESE')
	elif s[a - 4] == 'm' and s[a - 3] == 'a' and (s[a - 2] == 's') and (s[a - 1] == 'u'):
		print('JAPANESE')
	else:
		print('KOREAN')


for i in range(int(input())):
	texto = input()
	print('FILIPINO' if texto.endswith('po') else 'JAPANESE' if texto.endswith('desu') or texto.endswith('masu') else 'KOREAN')


n = int(input())
for i in range(0, n):
	s = str(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())
while t > 0:
	sentence = input()
	sentence = sentence.upper()
	if sentence.endswith('PO'):
		print('FILIPINO')
	elif sentence.endswith('DESU') or sentence.endswith('MASU'):
		print('JAPANESE')
	elif sentence.endswith('MNIDA'):
		print('KOREAN')
	t -= 1


n = int(input())
f = ['p', 'o']
j1 = ['d', 'e', 's', 'u']
j2 = ['m', 'a', 's', 'u']
for i in range(n):
	t = input()
	t = list(t)
	if t[-2:] == f:
		print('FILIPINO')
	elif t[-4:] == j1 or t[-4:] == j2:
		print('JAPANESE')
	else:
		print('KOREAN')


for _ in range(int(input())):
	m = [i for i in input()]
	if m[-1] == 'o':
		print('FILIPINO')
	elif m[-1] == 'u':
		print('JAPANESE')
	elif m[-1] == 'a':
		print('KOREAN')


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


no_of_testcase = int(input())
lng_output = []
for i in range(no_of_testcase):
	lng = input()
	if lng[-1] == 'o':
		lng_output.append('FILIPINO')
	elif lng[-1] == 'a':
		lng_output.append('KOREAN')
	else:
		lng_output.append('JAPANESE')
for i in lng_output:
	print(i)


n = int(input())
for i in range(0, n):
	my_str = str(input())
	splited = my_str.split('_')
	final_str = splited[len(splited) - 1]
	for j in range(0, len(final_str)):
		temp = ''
		for r in range(len(final_str) - 1 - j, len(final_str)):
			temp += final_str[r]
		if temp == 'po':
			print('FILIPINO')
			break
		elif temp == 'desu' or temp == 'masu':
			print('JAPANESE')
			break
		elif temp == 'mnida':
			print('KOREAN')
			break


q = int(input())
for x in range(q):
	word = input()
	if word[-2:] == 'po':
		print('FILIPINO')
	if word[-4:] == 'desu' or word[-4:] == 'masu':
		print('JAPANESE')
	if word[-5:] == 'mnida':
		print('KOREAN')


t = int(input())
in_data = []
endings = {'po': 'FILIPINO', 'desu': 'JAPANESE', 'masu': 'JAPANESE', 'mnida': 'KOREAN'}
for _ in range(t):
	in_data.append(input())
for s in in_data:
	for (ending, lang) in endings.items():
		if s.endswith(ending):
			print(lang)
			break


a = []
for i in range(int(input())):
	s = input()
	if s.endswith('po'):
		a.append('FILIPINO')
	if s.endswith('desu') or s.endswith('masu'):
		a.append('JAPANESE')
	if s.endswith('mnida'):
		a.append('KOREAN')
for i in a:
	print(i)


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


for x 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')


for _ in range(int(input())):
	s = input()
	if s[len(s) - 2:len(s)] == 'po':
		print('Filipino'.upper())
	elif s[len(s) - 4:len(s)] == 'desu' or s[len(s) - 4:len(s)] == 'masu':
		print('Japanese'.upper())
	else:
		print('Korean'.upper())


a = int(input())
for i in range(a):
	b = str(input()).lower()
	if b[len(b) - 2:len(b)] == 'po':
		print('FILIPINO')
	elif b[len(b) - 4:len(b)] == 'desu' or b[len(b) - 4:len(b)] == 'masu':
		print('JAPANESE')
	else:
		print('KOREAN')


fil = ['po']
jap = ['desu', 'masu']
kor = ['mnida']
for i in range(int(input())):
	l = input()
	if l[len(l) - 2:] in fil:
		print('FILIPINO')
	elif l[len(l) - 4:] in jap:
		print('JAPANESE')
	else:
		print('KOREAN')


t = int(input())
while t > 0:
	t -= 1
	s = input().split('_')
	s1 = s[-1]
	if s1[-2:] == 'po':
		print('FILIPINO')
	elif s1[-4:] == 'desu' or s1[-4:] == 'masu':
		print('JAPANESE')
	elif s1[-5:] == 'mnida':
		print('KOREAN')


for i in range(int(input())):
	s = input()
	s = s[::-1]
	if s.find('op') == 0:
		print('FILIPINO')
	elif s.find('adinm') == 0:
		print('KOREAN')
	else:
		print('JAPANESE')


japanese = ['desu', 'masu']
filipino = ['po']
korean = ['mnida']
for a0 in range(int(input())):
	s = input()
	s = s[-5:]
	if s[-2:] == 'po':
		print('FILIPINO')
	elif s[-4:] in japanese:
		print('JAPANESE')
	elif s == 'mnida':
		print('KOREAN')


dic = {'po': 'FILIPINO', 'desu': 'JAPANESE', 'masu': 'JAPANESE', 'mnida': 'KOREAN'}
for _ in range(int(input())):
	s = input()
	a = s[-5:]
	for i in dic:
		if i in a:
			print(dic[i])
			break


n = int(input())
for j in range(n):
	s = input()
	l = len(s) + 1
	if s[l - 3:l - 1] == 'po':
		print('FILIPINO')
	elif s[l - 5:l - 1] == 'desu' or s[l - 5:l - 1] == 'masu':
		print('JAPANESE')
	elif s[l - 6:l - 1] == 'mnida':
		print('KOREAN')
	else:
		print(s[l - 3:l - 1])


test_cases = int(input())
for test in range(test_cases):
	input_str = input()
	if input_str[-2:] == 'po':
		print('FILIPINO')
	elif input_str[-5:] == 'mnida':
		print('KOREAN')
	else:
		print('JAPANESE')


x = int(input())
ans = []
for i in range(x):
	s = input()
	if s.endswith('po'):
		ans.append('FILIPINO')
	elif s.endswith('mnida'):
		ans.append('KOREAN')
	else:
		ans.append('JAPANESE')
print('\n'.join(ans))


for _ in [0] * int(input()):
	n = input().split('_')
	n = n[len(n) - 1]
	if n[len(n) - 2:] == 'po':
		print('FILIPINO')
	elif n[len(n) - 4:] == 'desu' or n[len(n) - 4:] == 'masu':
		print('JAPANESE')
	else:
		print('KOREAN')


for t in range(int(input())):
	sentence = input().split('_')
	sentence = list(sentence[-1])
	i = len(sentence) - 1
	lang = []
	while i >= 0:
		lang.insert(0, sentence[i])
		temp = ''.join(lang)
		if temp == 'po':
			print('FILIPINO')
			break
		elif temp == 'mnida':
			print('KOREAN')
			break
		elif temp == 'desu' or temp == 'masu':
			print('JAPANESE')
			break
		i -= 1
		if i < 0:
			break


t = int(input())
for i in range(t):
	s = list(input())
	s.reverse()
	if s[0:2] == ['o', 'p']:
		print('FILIPINO')
	elif s[0:5] == ['a', 'd', 'i', 'n', 'm']:
		print('KOREAN')
	else:
		print('JAPANESE')


n = int(input())
for i in range(n):
	s = input().split('_')[-1]
	if s[-2:].lower() == 'po':
		print('FILIPINO')
	elif s[-4:].lower() == 'desu' or s[-4:].lower() == 'masu':
		print('JAPANESE')
	elif s[-5:].lower() == 'mnida':
		print('KOREAN')


words = int(input())
for i in range(words):
	word = input()
	if word[-1] == 'o':
		print('FILIPINO')
	elif word[-1] == 'u':
		print('JAPANESE')
	elif word[-1] == 'a':
		print('KOREAN')


t = int(input())
for T in range(t):
	s = input()
	S = ''
	if s[-1] == 'o' and s[-2] == 'p':
		S = 'FILIPINO'
	elif s[-1] == 'u' and s[-2] == 's' and (s[-3] == 'e') and (s[-4] == 'd'):
		S = 'JAPANESE'
	elif s[-1] == 'u' and s[-2] == 's' and (s[-3] == 'a') and (s[-4] == 'm'):
		S = 'JAPANESE'
	elif s[-1] == 'a' and s[-2] == 'd' and (s[-3] == 'i') and (s[-4] == 'n') and (s[-5] == 'm'):
		S = 'KOREAN'
	else:
		x = 0
	print(S)


import sys

def rint():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline().rstrip('\n')

def oint():
	return int(input())
fil = 'po'[::-1]
ja1 = 'desu'[::-1]
ja2 = 'masu'[::-1]
kor = 'mnida'[::-1]
t = oint()
for _ in range(t):
	s = input()
	s = s[::-1]
	if s[:2] == fil:
		print('FILIPINO')
	elif s[:4] == ja1 or s[:4] == ja2:
		print('JAPANESE')
	else:
		print('KOREAN')


def solve(s):
	if s[-2:] == 'po':
		return 'FILIPINO'
	if s[-4:] == 'desu' or s[-4:] == 'masu':
		return 'JAPANESE'
	return 'KOREAN'
t = int(input())
ans = [solve(input()) for x in range(t)]
print('\n'.join(ans))


n = int(input())
l = [input() for i in range(n)]
lang = {'po': 'FILIPINO', 'desu': 'JAPANESE', 'masu': 'JAPANESE', 'mnida': 'KOREAN'}
for s in l:
	for k in lang.keys():
		if s[-len(k):] == k:
			print(lang[k])


t = int(input())
tests = []
outs = []
for x in range(t):
	tests.append(input())
for test in tests:
	if test.endswith('po'):
		outs.append('FILIPINO')
	elif test.endswith('desu') or test.endswith('masu'):
		outs.append('JAPANESE')
	elif test.endswith('mnida'):
		outs.append('KOREAN')
for out in outs:
	print(out)


def check_lang(x):
	if x[-2:].lower() == 'po':
		return 'FILIPINO'
	elif x[-4:].lower() == 'desu' or x[-4:].lower() == 'masu':
		return 'JAPANESE'
	elif x[-5:].lower() == 'mnida':
		return 'KOREAN'
	else:
		return -1
n = int(input())
for i in range(n):
	sentence = input()
	output = check_lang(sentence)
	print(output)


n = int(input())
c = []
for i in range(n):
	x = input()
	if x[-3:].find('po') != -1:
		c.append('FILIPINO')
		continue
	elif x[-4:].find('desu') != -1 or x[-4:].find('masu') != -1:
		c.append('JAPANESE')
		continue
	else:
		c.append('KOREAN')
for i in c:
	print(i)


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


a = []
b = 0
n = int(input())
for i in range(n):
	s = input()
	a.append(s)
for i in range(n):
	t = a[i]
	b = len(t)
	if t[b - 1] == 'o' and t[b - 2] == 'p':
		print('FILIPINO')
	if t[b - 1] == 'u' and t[b - 2] == 's' and (t[b - 3] == 'e' or 'a') and (t[b - 4] == 'd' or 'm'):
		print('JAPANESE')
	if t[b - 1] == 'a' and t[b - 2] == 'd' and (t[b - 3] == 'i') and (t[b - 4] == 'n') and (t[b - 5] == 'm'):
		print('KOREAN')


t = int(input())
for each in range(t):
	sent = input()
	if sent.endswith('po'):
		print('FILIPINO')
	if sent.endswith('desu') or sent.endswith('masu'):
		print('JAPANESE')
	if sent.endswith('mnida'):
		print('KOREAN')


T = int(input())
for _ in range(T):
	name = input()
	string = name[::-1]
	tmp = string[:5]
	nam = tmp[::-1]
	if 'po' in nam:
		print('FILIPINO')
	elif 'desu' in nam:
		print('JAPANESE')
	elif 'masu' in nam:
		print('JAPANESE')
	elif 'mnida' in nam:
		print('KOREAN')


t = int(input())
for i in range(t):
	a = input()
	a = a[::-1]
	if a[:2] == 'op':
		print('FILIPINO')
	elif a[:4] == 'used' or a[:4] == 'usam':
		print('JAPANESE')
	else:
		print('KOREAN')


def language(naam):
	if naam[int(len(naam)) - 2:] == 'po':
		print('FILIPINO')
	elif naam[int(len(naam)) - 4:] == 'desu' or naam[len(naam) - 4:] == 'masu':
		print('JAPANESE')
	elif naam[len(naam) - 5:] == 'mnida':
		print('KOREAN')
name = []
n = int(input())
for a in range(n):
	name = input()
	language(name)


t = int(input())
for x in range(t):
	s = input()
	s = s[::-1]
	if s[0:2] == 'op':
		print('FILIPINO')
	elif s[0:4] == 'used' or s[0:4] == 'usam':
		print('JAPANESE')
	else:
		print('KOREAN')


def solve(s):
	if s[-1:-3:-1][::-1] == 'po':
		return 'FILIPINO'
	elif s[-1:-5:-1][::-1] == 'desu' or s[-1:-5:-1][::-1] == 'masu':
		return 'JAPANESE'
	elif s[-1:-6:-1][::-1] == 'mnida':
		return 'KOREAN'
n = int(input())
for i in range(n):
	print(solve(input()))


n = int(input())
for x in range(n):
	a = input()[::-1]
	if a[:2] == 'po'[::-1]:
		print('FILIPINO')
	if a[:4] == 'desu'[::-1]:
		print('JAPANESE')
	if a[:4] == 'masu'[::-1]:
		print('JAPANESE')
	if a[:5] == 'mnida'[::-1]:
		print('KOREAN')


test_cases = int(input())
for _ in range(test_cases):
	test = input()
	if test.endswith('po'):
		answer = 'FILIPINO'
	elif test.endswith('mnida'):
		answer = 'KOREAN'
	else:
		answer = 'JAPANESE'
	print(answer)


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


a = int(input())
b = {'o': 'FILIPINO', 'u': 'JAPANESE', 'a': 'KOREAN'}
c = []
for x in range(a):
	d = input()
	c.append(d)
for y in c:
	print(b[y[-1]])


for i in range(int(input())):
	str = input()
	check_f = str[len(str) - 2:]
	check_jap = str[len(str) - 4:]
	check_kor = str[len(str) - 5:]
	if 'po' in check_f:
		print('FILIPINO')
	elif 'desu' in check_jap or 'masu' in check_jap:
		print('JAPANESE')
	elif 'mnida' in check_kor:
		print('KOREAN')


from __future__ import division, print_function
import os, sys
import math
import collections
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey, reverse=True)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(n - r))

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def padded_bin_with_complement(x):
	if x < 0:
		return bin(2 ** 16 - abs(x))[2:].zfill(16)
	else:
		return bin(x)[2:].zfill(16)

def binaryToDecimal(binary):
	binary1 = binary
	(decimal, i, n) = (0, 0, 0)
	while binary != 0:
		dec = binary % 10
		decimal = decimal + dec * pow(2, i)
		binary = binary // 10
		i += 1
	print(decimal)

def CountFrequency(arr):
	return collections.Counter(arr)

def pos(a):
	b = [0] * len(a)
	c = sorted(a)
	for i in range(len(a)):
		for j in range(len(a)):
			if c[j] == a[i]:
				b[i] = j
				break
	return b

def main():
	for _ in range(ii()):
		s = si()
		if s[len(s) - 2:len(s)].count('po'):
			print('FILIPINO')
			continue
		if s[len(s) - 4:len(s)].count('desu') or s[len(s) - 4:len(s)].count('masu'):
			print('JAPANESE')
			continue
		if s[len(s) - 5:len(s)].count('mnida'):
			print('KOREAN')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


num = int(input())
dict_1 = {'po': 'FILIPINO', 'masu': 'JAPANESE', 'desu': 'JAPANESE', 'mnida': 'KOREAN'}
while num > 0:
	arr = list(map(str, input().split()))
	i = 0
	size = len(arr)
	while i < size:
		j = len(arr[i])
		if j < 2:
			break
		else:
			m = [2, 4, 5]
			c = 0
			while c < 3:
				k = j - m[c]
				if arr[i][k:] in dict_1:
					print(dict_1[arr[i][k:]])
					break
				c += 1
		i += 1
	num -= 1


n = int(input())
i = 0
masK = []
while i < n:
	i += 1
	mas = list(input())
	if mas[-1] == 'o' and mas[-2] == 'p':
		masK.append(1)
	if mas[-1] == 'u' and mas[-2] == 's' and (mas[-3] == 'e') and (mas[-4] == 'd'):
		masK.append(2)
	if mas[-1] == 'u' and mas[-2] == 's' and (mas[-3] == 'a') and (mas[-4] == 'm'):
		masK.append(2)
	if mas[-1] == 'a' and mas[-2] == 'd' and (mas[-3] == 'i') and (mas[-4] == 'n') and (mas[-5] == 'm'):
		masK.append(3)
i = 0
while i < n:
	if masK[i] == 1:
		print('FILIPINO')
	if masK[i] == 2:
		print('JAPANESE')
	if masK[i] == 3:
		print('KOREAN')
	i += 1


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


lang = {'po': 'FILIPINO', 'su': 'JAPANESE', 'da': 'KOREAN'}
for _ in range(int(input())):
	print(lang[input()[-2:]])


def check(s):
	if s[-2:] == 'po':
		return 'FILIPINO'
	elif s[-2:] == 'da':
		return 'KOREAN'
	else:
		return 'JAPANESE'
n = int(input())
for i in range(n):
	print(check(input()))


k = int(input(''))
s = 1
while s <= k:
	a = input('')
	r = len(a)
	z = a[r - 2] + a[r - 1]
	if z == 'po':
		print('FILIPINO')
	if z == 'su':
		print('JAPANESE')
	if z == 'da':
		print('KOREAN')
	s = s + 1


num_sentences = int(input())
list_of_sentences = []
for i in range(num_sentences):
	current_sentece = input()
	list_of_sentences.append(current_sentece)
list_of_answers = []
for current_sentece in list_of_sentences:
	if current_sentece[-1] == 'o':
		list_of_answers.append('FILIPINO')
	elif current_sentece[-1] == 'u':
		list_of_answers.append('JAPANESE')
	else:
		list_of_answers.append('KOREAN')
for answer in list_of_answers:
	print(answer)


t = int(input())
while t > 0:
	t -= 1
	sentence = input()
	if sentence[-2:] == 'po':
		print('FILIPINO')
	elif sentence[-4:] == 'desu' or sentence[-4:] == 'masu':
		print('JAPANESE')
	elif sentence[-5:] == 'mnida':
		print('KOREAN')


while True:
	n = int(input(''))
	if 1 <= n <= 30:
		break
p = 0
L = []
for i in range(n):
	while True:
		ch = input('')
		if 1 <= len(ch) <= 1000:
			break
		while p < n:
			for j in range(len(ch)):
				if (ch[j] > ord(a) and ch[j] < ord(z) or ch[j] == '_') and ch[1] != '_' and (ch[len(ch) - 1] != '_'):
					if ch[j] == '_' and ch[j + 1] == '_':
						p += 1
	L.append(ch)
for i in range(n):
	if L[i][len(L[i]) - 2:] == 'po':
		print('FILIPINO')
	elif L[i][len(L[i]) - 4:] == 'masu' or L[i][len(L[i]) - 4:] == 'desu':
		print('JAPANESE')
	else:
		print('KOREAN')


for _ in range(int(input())):
	word_list = input().split('_')
	if 'po' == word_list[-1][-2:]:
		print('FILIPINO')
	elif 'su' == word_list[-1][-2:]:
		print('JAPANESE')
	else:
		print('KOREAN')


t = int(input())
for i in range(t):
	name = input()
	if name.endswith('po'):
		print('FILIPINO')
		continue
	if name.endswith('desu') or name.endswith('masu'):
		print('JAPANESE')
		continue
	if name.endswith('mnida'):
		print('KOREAN')
		continue


tc = int(input().strip())
for t in range(tc):
	s = list(input().strip())
	if s[-1] == 'u':
		print('JAPANESE')
	elif s[-1] == 'o':
		print('FILIPINO')
	else:
		print('KOREAN')


a = int(input())
i = 1
while i <= a:
	b = str(input())
	if b[len(b) - 2:] == 'po':
		print('FILIPINO')
	elif b[len(b) - 4:] == 'desu' or b[len(b) - 4:] == 'masu':
		print('JAPANESE')
	elif b[len(b) - 5:] == 'mnida':
		print('KOREAN')
	i = i + 1


t = int(input())
for _ in range(t):
	s = input().split('_')[-1]
	try:
		i1 = s.index('po')
	except:
		i1 = -1
	try:
		i2 = s.index('mnida')
	except:
		i2 = -1
	try:
		i3 = s.index('desu')
	except:
		i3 = -1
	try:
		i4 = s.index('masu')
	except:
		i4 = -1
	i = max(i1, i2, i3, i4)
	if i1 == i:
		print('FILIPINO')
	elif i2 == i:
		print('KOREAN')
	else:
		print('JAPANESE')


for tc in range(int(input())):
	s = list(input())
	if s[-1] == 'o' and s[-2] == 'p':
		print('FILIPINO')
	elif s[-1] == 'a' and s[-2] == 'd' and (s[-3] == 'i') and (s[-4] == 'n') and (s[-5] == 'm'):
		print('KOREAN')
	else:
		print('JAPANESE')


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


num = int(input())
my_list = []
for x in range(num):
	temp = input()
	my_list.append(temp)
char2 = ''
char4 = ''
char5 = ''
for x in my_list:
	char2 = x[-2:]
	char4 = x[-4:]
	char5 = x[-5:]
	if char2 == 'po':
		print('FILIPINO')
		continue
	if char4 == 'desu' or char4 == 'masu':
		print('JAPANESE')
		continue
	if char5 == 'mnida':
		print('KOREAN')
		continue


def language(phrase):
	last = phrase[-1]
	if last == 'o':
		print('FILIPINO')
	elif last == 'u':
		print('JAPANESE')
	elif last == 'a':
		print('KOREAN')
tests = int(input())
for t in range(tests):
	s = input()
	language(s)


t = int(input())
for i in range(t):
	ele = input()
	ele = list(ele)
	if ele[len(ele) - 1] == 'o' and ele[len(ele) - 2] == 'p':
		print('FILIPINO')
	elif ele[len(ele) - 1] == 'u' and ele[len(ele) - 2] == 's' and (ele[len(ele) - 3] == 'e' or ele[len(ele) - 3] == 'a') and (ele[len(ele) - 4] == 'd' or ele[len(ele) - 4] == 'm'):
		print('JAPANESE')
	else:
		print('KOREAN')


exec(int(input()) * 'print({"o": "FILIPINO", "u": "JAPANESE", "a": "KOREAN"}[input()[-1]]);')


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


def solve():
	s = str(input())
	if s[-2:] == 'po':
		print('FILIPINO')
	elif s[-4:] == 'desu' or s[-4:] == 'masu':
		print('JAPANESE')
	elif s[-5:] == 'mnida':
		print('KOREAN')
t = int(input())
while t:
	solve()
	t -= 1


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


n = int(input())
arr = []
for i in range(n):
	arr.append(input())
for i in arr:
	if i[-2:] == 'po':
		print('FILIPINO')
	if i[-4:] == 'desu' or i[-4:] == 'masu':
		print('JAPANESE')
	if i[-5:] == 'mnida':
		print('KOREAN')


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


t = int(input())
sentence = []
for i in range(t):
	sentence.append(str(input()))
for i in sentence:
	if i[len(i) - 1] == 'o':
		print('FILIPINO')
	elif i[len(i) - 1] == 'u':
		print('JAPANESE')
	elif i[len(i) - 1] == 'a':
		print('KOREAN')
	else:
		pass


n = int(input())
for i in range(n):
	s = input()
	if s[:-3:-1] == 'op':
		print('FILIPINO')
	elif s[:-5:-1] == 'used' or s[:-5:-1] == 'usam':
		print('JAPANESE')
	else:
		print('KOREAN')


import sys
import bisect
import heapq
from math import *
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
mod = pow(10, 9) + 7

def inp():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nl():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def solve():
	s = inp()
	if s[len(s) - 1] == 'o':
		print('FILIPINO')
	elif s[len(s) - 1] == 'u':
		print('JAPANESE')
	else:
		print('KOREAN')
testcase(int(inp()))


n = int(input())
i = 0
string1 = ''
while i < n:
	string1 = string1 + input()
	i = i + 1
	if n - i >= 1:
		string1 = string1 + ' '
list1 = string1.split(' ')
for n in range(len(list1)):
	if list1[n].endswith('po'):
		print('FILIPINO')
	elif list1[n].endswith('desu') or list1[n].endswith('masu'):
		print('JAPANESE')
	elif list1[n].endswith('mnida'):
		print('KOREAN')


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


import sys
import collections
import heapq
import math
import bisect
input = sys.stdin.readline

def rints():
	return map(int, input().strip().split())

def rstr():
	return input().strip()

def rint():
	return int(input().strip())

def rintas():
	return [int(i) for i in input().strip().split()]

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
t = rint()
for _ in range(t):
	s = rstr()
	if len(s) >= 2 and s[-2:] == 'po':
		print('FILIPINO')
	elif len(s) >= 4 and (s[-4:] == 'desu' or s[-4:] == 'masu'):
		print('JAPANESE')
	elif len(s) >= 5 and s[-5:] == 'mnida':
		print('KOREAN')


a = int(input())
for i in range(a):
	b = input()
	c = b[::-1]
	if c.count('op') > 0:
		g = c.find('op')
		if g == 0:
			print('FILIPINO')
	if c.count('usam') > 0 or c.count('used') > 0:
		x = c.find('used')
		y = c.find('usam')
		if x == 0 or y == 0:
			print('JAPANESE')
	if c.count('adinm') > 0:
		l = c.find('adinm')
		if l == 0:
			print('KOREAN')


(A, B, C, D) = ('op', 'used', 'usam', 'adinm')
t = int(input().strip())
while t:
	(a, b, c, d) = (0, 0, 0, 0)
	s = input().strip()
	for i in range(len(s) - 1, len(s) - 6, -1):
		if i >= 0:
			if a <= 1 and s[i] == A[a]:
				a += 1
			if b <= 3 and s[i] == B[b]:
				b += 1
			if c <= 3 and s[i] == C[c]:
				c += 1
			if d <= 4 and s[i] == D[d]:
				d += 1
	ans = 'FILIPINO'
	if b == 4 or c == 4:
		ans = 'JAPANESE'
	if d == 5:
		ans = 'KOREAN'
	print(ans)
	t -= 1


def function(n):
	if n[-1:-3:-1] == 'op':
		print('FILIPINO')
		return
	if n[-1:-5:-1] == 'used' or n[-1:-5:-1] == 'usam':
		print('JAPANESE')
		return
	else:
		print('KOREAN')
		return
t = int(input())
while t:
	n = str(input())
	function(n)
	t -= 1


t = int(input())
while t:
	t -= 1
	a = input()
	if a[-4:] == 'desu' or a[-4:] == 'masu':
		print('Japanese'.upper())
	if a[-2:] == 'po':
		print('Filipino'.upper())
	if a[-5:] == 'mnida':
		print('Korean'.upper())


def main():
	n = int(input())
	words = []
	for _ in range(n):
		words.append(input().strip())
	mp = {'Filipino': ['po'], 'Japanese': ['desu', 'masu'], 'Korean': ['mnida']}
	ans = []
	for w in words:
		for (k, vs) in mp.items():
			for v in vs:
				if w.endswith(v):
					ans.append(k.upper())
					break
	print('\n'.join(ans))
main()


def sol(s):
	if s.endswith('po'):
		print('FILIPINO')
	elif s.endswith('desu') or s.endswith('masu'):
		print('JAPANESE')
	elif s.endswith('mnida'):
		print('KOREAN')
[sol(input()) for i in range(int(input()))]


li = ['po', 'desu', 'masu', 'mnida']
for _ in range(int(input())):
	s = input()
	if s[-2] + s[-1] in li:
		print('FILIPINO')
	elif s[-4] + s[-3] + s[-2] + s[-1] in li:
		print('JAPANESE')
	else:
		print('KOREAN')


for i in range(int(input())):
	a = input()
	if a[-1] == 'o':
		print('filipino'.upper())
	elif a[-1] == 'u':
		print('japanese'.upper())
	else:
		print('korean'.upper())


n = int(input())
for i in range(n):
	for ch in input():
		pass
	if ch == 'u':
		print('JAPANESE')
	if ch == 'o':
		print('FILIPINO')
	if ch == 'a':
		print('KOREAN')


from collections import defaultdict

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


import heapq
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 10 ** 9 + 7

def factors(n):
	return sorted(list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split(' ')]

def st():
	return input().rstrip('\n')

def val():
	return int(input())

def li2():
	return [i for i in input().rstrip('\n').split(' ')]
n = val()
for _ in range(n):
	s = st()
	if s[-1] == 'o':
		print('FILIPINO')
	elif s[-1] == 'u':
		print('JAPANESE')
	else:
		print('KOREAN')


x = int(input())
answer = []
for i in range(0, x):
	word = input()
	length = len(word)
	if word[length - 2:] == 'po':
		answer.append('FILIPINO')
	elif word[length - 2:] == 'su':
		answer.append('JAPANESE')
	else:
		answer.append('KOREAN')
for i in range(0, x):
	print(answer[i])


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


inp = int(input())
for i in range(inp):
	in1 = input().split('_')
	l = len(in1) - 1
	le2 = len(in1[l])
	if in1[l][le2 - 2:le2] == 'po':
		print('FILIPINO')
	elif in1[l][le2 - 5:le2] == 'mnida':
		print('KOREAN')
	else:
		print('JAPANESE')


n = int(input())
d = {'su': 'JAPANESE', 'da': 'KOREAN', 'po': 'FILIPINO'}
for _ in range(n):
	print(d[input()[-2:]])


t = int(input())
f = 'po'
j1 = 'desu'
j2 = 'masu'
k = 'mnida'
while t > 0:
	s = [x for x in input().split('_')]
	ans = s[len(s) - 1]
	if ans[len(ans) - 1] == 'o':
		print('FILIPINO')
	elif ans[len(ans) - 1] == 'u':
		print('JAPANESE')
	else:
		print('KOREAN')
	t -= 1


n = int(input())
for i in range(1, n + 1):
	x = input()
	if x[len(x) - 2] + x[len(x) - 1] == 'po':
		print('FILIPINO')
	if x[len(x) - 1] == 'u' or x[len(x) - 1] == 'u':
		print('JAPANESE')
	if x[len(x) - 1] == 'a':
		print('KOREAN')


t = int(input())
for _ in range(t):
	str = input()
	l = len(str)
	if str[-2:l + 1] == 'po':
		print('FILIPINO')
	if str[-4:l + 1] == 'desu' or str[-4:l + 1] == 'masu':
		print('JAPANESE')
	if str[-5:l + 1] == 'mnida':
		print('KOREAN')


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

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


n = int(input())
for k in range(n):
	a = input()
	l = len(a)
	if l > 1:
		if a[l - 2] + a[l - 1] == 'po':
			print('FILIPINO')
	if l > 3:
		if a[l - 4] + a[l - 3] + a[l - 2] + a[l - 1] == 'desu' or a[l - 4] + a[l - 3] + a[l - 2] + a[l - 1] == 'masu':
			print('JAPANESE')
		if a[l - 5] + a[l - 4] + a[l - 3] + a[l - 2] + a[l - 1] == 'mnida':
			print('KOREAN')


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


tests = int(input())
for __ in range(tests):
	string = input()
	if string[-2:] == 'po':
		print('FILIPINO')
	elif string[-2:] == 'su':
		print('JAPANESE')
	else:
		print('KOREAN')


def checkLang(txt):
	if txt[-2:] == 'po':
		return 'FILIPINO'
	elif txt[-4:] == 'desu' or txt[-4:] == 'masu':
		return 'JAPANESE'
	elif txt[-5:] == 'mnida':
		return 'KOREAN'
x = int(input())
word = []
for i in range(0, x):
	word.append(input())
for i in range(0, x):
	print(checkLang(word[i]))


n = int(input())
for i in range(n):
	s = input()
	a = s[-5:]
	if a == 'mnida':
		print('KOREAN')
	elif a[-4:] == 'masu' or a[-4:] == 'desu':
		print('JAPANESE')
	else:
		print('FILIPINO')


t = input()
for x in range(0, int(t)):
	s = input()
	arr = s.split('_')
	l = s[-2:]
	if l == 'po':
		print('FILIPINO')
	else:
		l = s[-4:]
		if l == 'desu' or l == 'masu':
			print('JAPANESE')
		else:
			l = s[-5:]
			if l == 'mnida':
				print('KOREAN')
	pass


t = int(input())
for i in range(t):
	x = str(input())
	s = ''
	for j in range(1, len(x) + 1):
		s = s + x[-j]
	if s[0] == 'o' and s[1] == 'p':
		print('FILIPINO')
	elif s[0] == 'u' and s[1] == 's' and (s[2] == 'e') and (s[3] == 'd'):
		print('JAPANESE')
	elif s[0] == 'u' and s[1] == 's' and (s[2] == 'a') and (s[3] == 'm'):
		print('JAPANESE')
	elif s[0] == 'a' and s[1] == 'd' and (s[2] == 'i') and (s[3] == 'n') and (s[4] == 'm'):
		print('KOREAN')


t = int(input())
while t > 0:
	s = input()
	length = len(s)
	if s[length - 1] == 'o':
		print('FILIPINO')
	elif s[length - 1] == 'u':
		print('JAPANESE')
	elif s[length - 1] == 'a':
		print('KOREAN')
	t -= 1


('po', 'desu', 'masu', 'mnida')

def solve(string):
	if string[-2:] == 'po':
		return 'FILIPINO'
	if string[-4:] == 'desu' or string[-4:] == 'masu':
		return 'JAPANESE'
	return 'KOREAN'
q = int(input())
for x in range(q):
	s = input()
	print(solve(s))


t = int(input())
for i in range(t):
	str = input()
	if len(str) > 1:
		s1 = str[-2:]
	if len(str) > 3:
		s2 = str[-4:]
	if len(str) > 4:
		s3 = str[-5:]
	if s1 == 'po':
		print('FILIPINO')
	elif s2 == 'desu' or s2 == 'masu':
		print('JAPANESE')
	else:
		print('KOREAN')


n = int(input())
while n > 0:
	s = input()
	if s.endswith('po'):
		print('FILIPINO')
	if s.endswith('desu'):
		print('JAPANESE')
	if s.endswith('masu'):
		print('JAPANESE')
	if s.endswith('mnida'):
		print('KOREAN')
	n -= 1


t = int(input())
s = []
for nnjg in range(0, t):
	w = input()
	q = len(w)
	r1 = ''
	r2 = ''
	for i in range(q - 2, q):
		r1 += w[i]
	for i in range(q - 4, q):
		r2 += w[i]
	if r1 == 'po':
		s.append('FILIPINO')
	elif r2 == 'desu' or r2 == 'masu':
		s.append('JAPANESE')
	else:
		s.append('KOREAN')
for i in s:
	print(i)


n = int(input())
for i in range(n):
	s = input()
	if s.endswith('o'):
		print('FILIPINO')
	if s.endswith('u'):
		print('JAPANESE')
	if s.endswith('a'):
		print('KOREAN')


def main():
	n = int(input())
	for _ in range(n):
		print({'o': 'FILIPINO', 'u': 'JAPANESE', 'a': 'KOREAN'}[input()[-1]])
main()


temp = int(input())
array = []
if temp >= 1 and temp <= 30:
	for i in range(temp):
		temp2 = input()
		if len(temp2) >= 1 and len(temp2) <= 1000:
			array.append(temp2)
for i in array:
	if i.endswith('po'):
		print('FILIPINO')
	elif i.endswith('desu') or i.endswith('masu'):
		print('JAPANESE')
	elif i.endswith('mnida'):
		print('KOREAN')


for i in range(int(input())):
	s = input()
	for i in range(len(s), -1, -1):
		d = s[i:]
		if 'po' in d:
			print('FILIPINO')
			break
		elif 'desu' in d or 'masu' in d:
			print('JAPANESE')
			break
		elif 'mnida' in d:
			print('KOREAN')
			break


for _ in range(int(input())):
	s = input()
	l_s = len(s)
	po = s[l_s - 2:].find('po')
	desu = s[l_s - 4:].find('desu')
	masu = s[l_s - 4:].find('masu')
	mnida = s[l_s - 5:].find('mnida')
	if po != -1:
		print('FILIPINO')
	elif desu != -1 or masu != -1:
		print('JAPANESE')
	elif mnida != -1:
		print('KOREAN')


n = int(input())
while n > 0:
	s = input()
	f = s[-4:]
	if f == 'masu' or f == 'desu':
		print('JAPANESE')
	else:
		m = s[-5:]
		if m == 'mnida':
			print('KOREAN')
		else:
			print('FILIPINO')
	n -= 1


t = int(input())
for _ in range(t):
	st = input()
	if st[-1] == 'a':
		print('KOREAN')
	elif st[-1] == 'u':
		print('JAPANESE')
	else:
		print('FILIPINO')


a = int(input())
l = []
for i in range(a):
	b = input()
	if b[-1] == 'a':
		l.append('KOREAN')
	if b[-1] == 'o':
		l.append('FILIPINO')
	if b[-1] == 'u':
		l.append('JAPANESE')
for i in l:
	print(i)


n = eval(input())
x = []
for i in range(n):
	m = input()
	x.append(m)
for j in x:
	if j[-2:] == 'po':
		print('FILIPINO')
	elif j[-5:] == 'mnida':
		print('KOREAN')
	elif j[-4:] in ['desu', 'masu']:
		print('JAPANESE')


n = int(input())
i = 0
while i < n:
	x = input()
	if x[-1] == 'o':
		print('FILIPINO')
	elif x[-1] == 'u':
		print('JAPANESE')
	elif x[-1] == 'a':
		print('KOREAN')
	i = i + 1


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


n = int(input())
result = []
for i in range(n):
	string = input()
	if string[-2:] == 'po':
		result.append(0)
	elif string[-4:] == 'desu' or string[-4:] == 'masu':
		result.append(1)
	else:
		result.append(2)
words = ['FILIPINO', 'JAPANESE', 'KOREAN']
for i in range(n):
	print(words[result[i]])


n = int(input())
ans = []
for i in range(n):
	st = input()
	if len(st) < 5:
		st = 'oooo' + st
	if st[len(st) - 5:len(st)] == 'mnida':
		ans.append('KOREAN')
	elif st[len(st) - 4:len(st)] == 'desu' or st[len(st) - 4:len(st)] == 'masu':
		ans.append('JAPANESE')
	else:
		ans.append('FILIPINO')
for i in range(n):
	print(ans[i])


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


tc = int(input())
for _ in range(tc):
	s = input()
	l = list(s)
	a = ['p', 'o']
	b = ['d', 'e', 's', 'u']
	c = ['m', 'a', 's', 'u']
	d = ['m', 'n', 'i', 'd', 'a']
	if l[len(l) - 2:] == a:
		print('FILIPINO')
	elif l[len(l) - 4:] == b or l[len(l) - 4:] == c:
		print('JAPANESE')
	else:
		print('KOREAN')


language = ['FILIPINO', 'JAPANESE', 'KOREAN']
for _ in [0] * int(input()):
	print(language['oua'.index(input()[-1])])


t = int(input())
for i in range(0, t):
	text = input()
	n = len(text)
	ans = ''
	for i in range(n - 1, -1, -1):
		ans += text[i]
		if ans == 'op':
			print('FILIPINO')
			break
		elif ans == 'used' or ans == 'usam':
			print('JAPANESE')
			break
		elif ans == 'adinm':
			print('KOREAN')
			break


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


for io in range(int(input())):
	a = input()
	x = a[len(a) - 1]
	if x == 'a':
		print('KOREAN')
	elif x == 'u':
		print('JAPANESE')
	else:
		print('FILIPINO')


import sys
input = sys.stdin.readline
from bisect import bisect_left
from bisect import bisect_right
from math import ceil, factorial

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	s = input().strip()
	if s[len(s) - 2:] == 'po':
		print('FILIPINO')
	elif s[len(s) - 4:] in ['desu', 'masu']:
		print('JAPANESE')
	else:
		print('KOREAN')


p = print
for _ in range(int(input())):
	s = input()
	n = len(s)
	if s[n - 1] == '0' or s[n - 2] == 'p':
		print('FILIPINO')
	elif s[n - 4] == 'd' or s[n - 4] == 'm':
		print('JAPANESE')
	elif s[n - 1] == 'a':
		print('KOREAN')


inp = input
li = list
iinp = lambda : int(inp())
ent = lambda : map(int, inp().split())
lient = lambda : li(ent())
n = iinp()
for i in range(n):
	sen = inp()
	if sen[-2:] == 'po':
		print('FILIPINO')
	elif sen[-4:] == 'desu' or sen[-4:] == 'masu':
		print('JAPANESE')
	else:
		print('KOREAN')


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


testcases = int(input())
for i in range(testcases):
	s = str(input())
	if 'o' == s[-1]:
		print('Filipino'.upper())
	elif 'u' in s[-1] or 'u' in s[-1]:
		print('Japanese'.upper())
	else:
		print('Korean'.upper())


testcase = int(input())
i = 0
while i < testcase:
	stri = input()
	rev = stri[::-1]
	if rev[0:2] == 'op':
		print('FILIPINO')
	elif rev[0:4] == 'used' or rev[0:4] == 'usam':
		print('JAPANESE')
	elif rev[0:5] == 'adinm':
		print('KOREAN')
	i = i + 1


n = int(input())
l = []
for i in range(n):
	ch = input()
	l.append(ch)
for i in range(n):
	if l[i][-1] == 'o':
		print('FILIPINO')
	elif l[i][-1] == 'a':
		print('KOREAN')
	else:
		print('JAPANESE')


for _ in range(int(input())):
	n = input()
	n = n[::-1]
	if len(n) >= 2 and n[0:2] == 'op':
		print('FILIPINO')
	elif len(n) >= 4 and n[0:4] == 'used' or n[0:4] == 'usam':
		print('JAPANESE')
	elif len(n) >= 5 and n[0:5] == 'adinm':
		print('KOREAN')


Data = {'o': 'FILIPINO', 'u': 'JAPANESE', 'a': 'KOREAN'}
for _ in range(int(input())):
	print(Data[input().strip()[-1]])


n = int(input())
arr = []
for i in range(n):
	a = input()
	arr.append(a)
for x in range(len(arr)):
	if arr[x][-2:] == 'po':
		print('FILIPINO')
	elif arr[x][-5:] == 'mnida':
		print('KOREAN')
	else:
		print('JAPANESE')


for _ in '0' * int(input()):
	print(['FILIPINO', 'JAPANESE', 'KOREAN']['oua'.find(input()[-1])])


import re
t = int(input())
while t > 0:
	t -= 1
	ostr = str(input())
	string = ostr[-2:]
	raw = ' '.join(re.findall('po', string))
	res = ''
	if raw != '':
		res = raw[0] + raw[1]
	if res == 'po':
		print('FILIPINO')
		continue
	else:
		string = ostr[-5:]
		raw1 = ' '.join(re.findall('mnida', string))
		res1 = ''
		if raw1 != '':
			res1 = raw1[0] + raw1[1] + raw1[2] + raw1[3] + raw1[4]
		if res1 == 'mnida':
			print('KOREAN')
			continue
		else:
			string = ostr[-4:]
			raw2 = ' '.join(re.findall('desu', string))
			raw3 = ' '.join(re.findall('masu', string))
			res2 = ''
			if raw2 != '':
				res2 = raw2[0] + raw2[1] + raw2[2] + raw2[3]
			res3 = ''
			if raw3 != '':
				res3 = raw3[0] + raw3[1] + raw3[2] + raw3[3]
			if res2 == 'desu' or res3 == 'masu':
				print('JAPANESE')
				continue


t = int(input())
for i in range(t):
	phrase = input().split('_')
	suffix = phrase[-1]
	if suffix[len(suffix) - 2:] == 'po':
		print('FILIPINO')
	elif suffix[len(suffix) - 4:] == 'desu' or suffix[len(suffix) - 4:] == 'masu':
		print('JAPANESE')
	else:
		print('KOREAN')


lst = []
for i in range(int(input())):
	s = str(input())
	if s[len(s) - 2:len(s)] == 'po':
		lst.append('FILIPINO')
	elif s[len(s) - 4:len(s)] == 'desu' or s[len(s) - 4:len(s)] == 'masu':
		lst.append('JAPANESE')
	elif s[len(s) - 5:len(s)] == 'mnida':
		lst.append('KOREAN')
for i in lst:
	print(i)


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


n = int(input())
for i in range(n):
	l = input()
	if 'p' == l[-2]:
		print('FILIPINO')
	elif 's' == l[-2]:
		print('JAPANESE')
	elif 'd' == l[-2]:
		print('KOREAN')


for _ in range(int(input())):
	x = input()
	print('FILIPINO' if x[-1] == 'o' else 'JAPANESE' if x[-1] == 'u' else 'KOREAN')


for _ in range(int(input())):
	s = input()[::-1]
	if s[:2] == 'op':
		print('FILIPINO')
	elif s[:5] == 'adinm':
		print('KOREAN')
	else:
		print('JAPANESE')


n = int(input())
all_input = []
for i in range(n):
	one_input = input()
	all_input.append(one_input)

def last(x):
	s = []
	w = x.split('_')
	w = w[-1]
	return w[-1]
for i in all_input[:]:
	if last(i) == 'u':
		print('JAPANESE')
	elif last(i) == 'o':
		print('FILIPINO')
	else:
		print('KOREAN')


n = int(input())
words = []
for _ in range(n):
	words.append(input())
for s in words:
	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 you in range(t):
	s = input().split('_')
	z = s[-1]
	if z[-2:] == 'po':
		print('FILIPINO')
	if len(z) >= 4 and (z[-4:] == 'desu' or z[-4:] == 'masu'):
		print('JAPANESE')
	if len(z) >= 5 and z[-5:] == 'mnida':
		print('KOREAN')


for _ in range(int(input())):
	s = input()
	r = s[-1]
	if r == 'o':
		print('FILIPINO')
	if r == 'u':
		print('JAPANESE')
	if r == 'a':
		print('KOREAN')


def program():
	s = input()
	l = len(s)
	ms = s[l - 2:l]
	if ms == 'po':
		print('FILIPINO')
	elif ms == 'su':
		print('JAPANESE')
	elif ms == 'da':
		print('KOREAN')
t = int(input())
for i in range(t):
	program()


n = int(input())

def distinguish(sentence):
	if sentence[-2:] == 'po':
		print('FILIPINO')
	elif (sentence[-4:] == 'desu') | (sentence[-4:] == 'masu'):
		print('JAPANESE')
	else:
		print('KOREAN')
for i in range(n):
	distinguish(input())


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


t = int(input())
import math
for _ in range(t):
	s = list(input())
	if len(s) >= 5:
		y = len(s) - 5
	else:
		y = 0
	x = s[y:]
	z = x
	x = ''.join(x)
	if x == 'mnida':
		print('KOREAN')
	else:
		z = x
		q = 0
		if x == 'desu':
			print('JAPANESE')
			q = 1
		elif x == 'masu':
			print('JAPANESE')
			q = 1
		x = x[1:]
		if x == 'desu' and q != 1:
			print('JAPANESE')
		elif x == 'masu' and q != 1:
			print('JAPANESE')
		elif q != 1:
			z = x
			x = x[2:]
			if x == 'po':
				print('FILIPINO')
			elif len(z) < 4:
				print('FILIPINO')


n = int(input())
lang_dict = {'o': 'FILIPINO', 'u': 'JAPANESE', 'a': 'KOREAN'}
for _ in range(n):
	s = input()
	print(lang_dict[s[-1]])


n = int(input())
for i in range(n):
	w = input()
	f = w[-2:].lower()
	j = w[-4:].lower()
	k = w[-5:].lower()
	if f == 'po':
		print('FILIPINO')
	elif j == 'desu' or j == 'masu':
		print('JAPANESE')
	elif k == 'mnida':
		print('KOREAN')


t = int(input().rstrip())
for i in range(t):
	suffix = str(input().rstrip())
	if suffix[-2:] == 'po':
		print('FILIPINO')
	elif suffix[-4:] in ['desu', 'masu']:
		print('JAPANESE')
	else:
		print('KOREAN')


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


n = int(input())
ans = []
for i in range(n):
	word = input()
	l = len(word)
	filipino = word.find('po', l - 2)
	korean = word.find('mnida', l - 5)
	if filipino != -1:
		ans.append('FILIPINO')
	elif korean != -1:
		ans.append('KOREAN')
	else:
		ans.append('JAPANESE')
for i in range(n):
	print(ans[i])


t = int(input())
while t > 0:
	s = list(input())
	l = len(s)
	if s[l - 1] == 'o' or s[l - 1] == 'O':
		print('FILIPINO')
	elif s[l - 1] == 'u' or s[l - 1] == 'U':
		print('JAPANESE')
	else:
		print('KOREAN')
	t = t - 1


def lang(s):
	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):
	lang(input())


t = int(input())
for i in range(t):
	s = input()
	a = 'po'
	b = 'su'
	c = 'da'
	x = s[-2:]
	if x == a:
		print('FILIPINO')
	elif x == b:
		print('JAPANESE')
	else:
		print('KOREAN')


x = int(input())
y = []
for i in range(x):
	y.append(input())
for i in range(x):
	s = y[i]
	if s.endswith('po'):
		print('FILIPINO')
	elif s.endswith(('desu', 'masu')):
		print('JAPANESE')
	else:
		print('KOREAN')


from sys import stdin, stdout
import math
import heapq
import collections
input = stdin.readline

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputstringnum():
	return [ord(x) - ord('a') for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	s = inputstring()
	if s[len(s) - 2] == 'o':
		print('FILIPINO')
	elif s[len(s) - 2] == 'u':
		print('JAPANESE')
	else:
		print('KOREAN')


for _ in range(int(input())):
	s = input()
	s = s[::-1]
	if len(s) >= 2 and s[:2] == 'op':
		print('FILIPINO')
	elif len(s) >= 4 and s[:4] in ['used', 'usam']:
		print('JAPANESE')
	else:
		print('KOREAN')


a = int(input())
for i in range(a):
	b = input()
	c = b[-1:]
	if c == 'o':
		print('FILIPINO')
	elif c == 'u':
		print('JAPANESE')
	elif c == 'a':
		print('KOREAN')


n = int(input())
cont = 0
while cont < n:
	palavra = input().lower()
	final = palavra[-5:]
	if 'po' in final:
		print('FILIPINO')
	elif 'desu' in final:
		print('JAPANESE')
	elif 'masu' in final:
		print('JAPANESE')
	elif 'mnida' in final:
		print('KOREAN')
	cont += 1


N = int(input())
for _ in range(N):
	s = input()
	if s[-2:] == 'po':
		print('FILIPINO')
	elif s[-2:] == 'su':
		print('JAPANESE')
	elif s[-2:] == 'da':
		print('KOREAN')


a = input()
for i in range(int(a)):
	temp = input()
	if temp.endswith('po'):
		print('FILIPINO')
	if temp.endswith('desu'):
		print('JAPANESE')
	if temp.endswith('masu'):
		print('JAPANESE')
	if temp.endswith('mnida'):
		print('KOREAN')


T = int(input())
for case in range(T):
	S = input().split('_')
	ans = ''
	last = -1
	if S[-1].find('po') > last:
		ans = 'FILIPINO'
		last = S[-1].find('po')
	if S[-1].find('mnida') > last:
		ans = 'KOREAN'
		last = S[-1].find('mnida')
	if S[-1].find('desu') > last:
		ans = 'JAPANESE'
		last = S[-1].find('desu')
	if S[-1].find('masu') > last:
		ans = 'JAPANESE'
		last = S[-1].find('masu')
	print(ans)


from math import ceil
from math import factorial
from collections import Counter
from operator import itemgetter
ii = lambda : int(input())
iia = lambda : list(map(int, input().split()))
isa = lambda : list(input().split())
n = ii()
for i in range(n):
	s = input()
	if s[-2:] == 'po':
		print('FILIPINO')
	elif s[-4:] == 'desu' or s[-4:] == 'masu':
		print('JAPANESE')
	else:
		print('KOREAN')


def main():
	word_count = int(input())
	words = []
	for i in range(word_count):
		words.append(input())
	for word in words:
		if word[-2:] == 'po':
			print('FILIPINO')
		elif word[-4:] == 'desu' or word[-4:] == 'masu':
			print('JAPANESE')
		elif word[-5:] == 'mnida':
			print('KOREAN')
		else:
			print('not possible..')
main()


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


def solve(test):
	s = input()
	ans = 'JAPANESE'
	if s.endswith('po'):
		ans = 'FILIPINO'
	elif s.endswith('mnida'):
		ans = 'KOREAN'
	print(ans)
t = int(input())
for _ in range(t):
	solve(_ + 1)


n = int(input())
lista = []
list = []
for i in range(n):
	sent = input()
	lista.append(sent)
for i in lista:
	if i[-1] == 'o':
		list.append('FILIPINO')
	if i[-1] == 'u':
		list.append('JAPANESE')
	if i[-1] == 'a':
		list.append('KOREAN')
for i in list:
	print(i)


T = int(input())
for i in range(0, T):
	s = input().split('_')
	x = s[len(s) - 1]
	if 'po' in x[len(x) - 2:]:
		print('FILIPINO')
	elif 'desu' in x[len(x) - 4:] or 'masu' in x[len(x) - 4:]:
		print('JAPANESE')
	elif 'mnida' in x[len(x) - 5:]:
		print('KOREAN')
	else:
		pass


for t in range(int(input())):
	s = input()
	c1 = ''
	c2 = ''
	c3 = ''
	cnt = 1
	for i in range(len(s) - 1, -1, -1):
		if cnt >= 6:
			break
		if cnt < 3:
			c1 = s[i] + c1
		if cnt < 5:
			c2 = s[i] + c2
		if cnt < 6:
			c3 = s[i] + c3
		cnt += 1
	if c1 == 'po':
		print('FILIPINO')
	elif c3 == 'mnida':
		print('KOREAN')
	else:
		print('JAPANESE')


length = int(input())
for a in range(0, length):
	input_str = input()
	if str(input_str[-2:]) == 'po':
		print('FILIPINO')
	elif str(input_str[-4:]) == 'desu' or str(input_str[-4:]) == 'masu':
		print('JAPANESE')
	elif str(input_str[-5:]) == 'mnida':
		print('KOREAN')


lang = {'o': 'Filipino', 'u': 'Japanese', 'a': 'Korean'}
for _ in range(int(input())):
	x = input()[-1]
	print(lang[x].upper())


t = int(input())
sentences = []
for i in range(t):
	sentences.append(input())
for sentence in sentences:
	if sentence.endswith('po'):
		print('FILIPINO')
	elif sentence.endswith('desu') or sentence.endswith('masu'):
		print('JAPANESE')
	elif sentence.endswith('mnida'):
		print('KOREAN')


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


t = int(input())
while t:
	t = t - 1
	string = input()
	size = len(string)
	string1 = string[size::-1]
	if string1.find('op') == 0:
		print('FILIPINO')
	if string1.find('used') == 0 or string1.find('usam') == 0:
		print('JAPANESE')
	if string1.find('adinm') == 0:
		print('KOREAN')


def find_language(string):
	length = len(string)
	check = string[length - 1]
	if check == 'o':
		print('FILIPINO')
	elif check == 'u':
		print('JAPANESE')
	else:
		print('KOREAN')
n = int(input())
for i in range(n):
	string = input()
	find_language(string)


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


def solve(string):
	s = string
	(f, j, k) = ('FILIPINO', 'JAPANESE', 'KOREAN')
	if len(s) >= 5:
		if s[-5:] == 'mnida':
			return k
	if len(s) >= 4:
		if s[-4:] == 'desu' or s[-4:] == 'masu':
			return j
	if len(s) >= 2:
		if s[-2:] == 'po':
			return f
for _ in range(int(input())):
	s = input()
	print(solve(s))


t = int(input())
for _ in range(t):
	s = input().strip()
	if s[-2:] == 'po':
		print('FILIPINO')
	elif s[-4:] in ('desu', 'masu'):
		print('JAPANESE')
	elif s[-5:] == 'mnida':
		print('KOREAN')
	else:
		raise Exception('SIW')


lena = int(input())
for i in range(lena):
	lenb = input()
	if lenb[-1:] == 'o':
		print('FILIPINO')
	elif lenb[-1:] == 'u':
		print('JAPANESE')
	elif lenb[-1:] == 'a':
		print('KOREAN')


tests = int(input())
for te in range(tests):
	stringa = input()
	n = len(stringa)
	if n >= 2:
		if stringa[n - 2:] == 'po':
			print('FILIPINO')
	if n >= 4:
		if stringa[n - 4:] == 'desu' or stringa[n - 4:] == 'masu':
			print('JAPANESE')
	if n >= 5:
		if stringa[n - 5:] == 'mnida':
			print('KOREAN')


no = int(input())
for i in range(no):
	lin = input()
	if lin[len(lin) - 2:] == 'po':
		print('FILIPINO')
	elif lin[len(lin) - 4:] == 'desu' or lin[len(lin) - 4:] == 'masu':
		print('JAPANESE')
	else:
		print('KOREAN')


from sys import stdin
rl = lambda : stdin.readline().strip()
t = int(rl())
for i in range(t):
	sentence = rl()
	if len(sentence) >= 2 and sentence[-2:] == 'po':
		print('FILIPINO')
	elif len(sentence) >= 4 and (sentence[-4:] == 'desu' or sentence[-4:] == 'masu'):
		print('JAPANESE')
	elif len(sentence) >= 5 and sentence[-5:] == 'mnida':
		print('KOREAN')


T = int(input())
a = ['po', 'desu', 'masu', 'mnida']
for t in range(T):
	s = input()
	for st in a:
		if s[len(s) - len(st):] == st:
			if st == 'po':
				print('FILIPINO')
				break
			elif st == 'desu' or st == 'masu':
				print('JAPANESE')
				break
			elif st == 'mnida':
				print('KOREAN')
				break


tc = int(input())
for i in range(tc):
	sen = input()
	if sen[len(sen) - 2:len(sen)] == 'po':
		print('FILIPINO')
	elif sen[len(sen) - 2:len(sen)] == 'su':
		print('JAPANESE')
	elif sen[len(sen) - 2:len(sen)] == 'da':
		print('KOREAN')


n = int(input())
for i in range(n):
	stroka = str(input())
	if stroka[-1] == 'o':
		print('FILIPINO')
	if stroka[-1] == 'u':
		print('JAPANESE')
	if stroka[-1] == 'a':
		print('KOREAN')


for i in range(int(input())):
	a = input()
	s = a[::-1]
	if s[0:2] == 'op':
		print('FILIPINO')
	elif s[0:4] == 'used' or s[0:4] == 'usam':
		print('JAPANESE')
	elif s[0:5] == 'adinm':
		print('KOREAN')


a_data = int(input())
count = 0
result = []
while count < a_data:
	tem_string = list(input().strip().lower())
	tem_string.reverse()
	if tem_string[0] == 'o':
		result.append('FILIPINO')
	elif tem_string[0] == 'u':
		result.append('JAPANESE')
	elif tem_string[0] == 'a':
		result.append('KOREAN')
	count += 1
count = 0
while count < a_data:
	print(result[count])
	count += 1


t = int(input())
for x in range(t):
	a = input()
	c = len(a)
	if a[c - 1] == 'o':
		print('FILIPINO')
	elif a[c - 1] == 'u':
		print('JAPANESE')
	elif a[c - 1] == 'a':
		print('KOREAN')


test_cases = int(input())
ans = []
while test_cases != 0:
	sentence = input()
	if sentence.endswith('o'):
		ans.append('FILIPINO')
	elif sentence.endswith('u'):
		ans.append('JAPANESE')
	elif sentence.endswith('a'):
		ans.append('KOREAN')
	test_cases -= 1
for x in ans:
	print(x)


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


sentences = int(input())
for i in range(sentences):
	sentence = input()
	if sentence.endswith('po'):
		print('FILIPINO')
	elif sentence.endswith('desu') or sentence.endswith('masu'):
		print('JAPANESE')
	else:
		print('KOREAN')


import sys
import math
input = sys.stdin.readline
from collections import defaultdict as dc
for _ in range(int(input())):
	s = input()[:-1]
	if s.endswith('po'):
		print('FILIPINO')
	elif s.endswith('desu') or s.endswith('masu'):
		print('JAPANESE')
	else:
		print('KOREAN')


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	s = sys.stdin.readline()[:-1]
	if s[-1] == 'u':
		print('JAPANESE')
	elif s[-1] == 'o':
		print('FILIPINO')
	else:
		print('KOREAN')


t = int(input())
while t != 0:
	s = input()
	s1 = s[-1:-5:-1]
	s2 = s[-1:-6:-1]
	s1 = s1[::-1]
	s2 = s2[::-1]
	if s1 == 'desu' or s1 == 'masu':
		print('JAPANESE')
	elif s2 == 'mnida':
		print('KOREAN')
	else:
		print('FILIPINO')
	t = t - 1


T = int(input())
for _ in range(T):
	ch = input()
	if ch.rfind('po') == len(ch) - 2:
		print('FILIPINO')
	elif ch.rfind('desu') == len(ch) - 4 or ch.rfind('masu') == len(ch) - 4:
		print('JAPANESE')
	else:
		print('KOREAN')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
for _ in range(int(ri())):
	s = ri()
	if s[-2:].find('po') == 0:
		print('FILIPINO')
	elif s[-4:].find('desu') == 0 or s[-4:].find('masu') == 0:
		print('JAPANESE')
	elif s[-5:].find('mnida') == 0:
		print('KOREAN')


t = int(input())
sentences = []
for item in range(t):
	sentences.append(input().split('_'))
for item in sentences:
	if item[-1][-1] == 'o':
		print('FILIPINO')
	elif item[-1][-1] == 'a':
		print('KOREAN')
	else:
		print('JAPANESE')


n = int(input(''))
lst = []
if n <= 30 and n >= 1:
	for i in range(n):
		x = input('')
		if len(x) <= 1000 or len(x) >= 0:
			if x.endswith('po'):
				lst.append('FILIPINO')
			elif x.endswith('desu') or x.endswith('masu'):
				lst.append('JAPANESE')
			elif x.endswith('mnida'):
				lst.append('KOREAN')
	for i in range(n):
		print(lst[i])


for i in range(int(input())):
	b = input()
	if list(b)[len(b) - 1] == 'o':
		print('FILIPINO')
	if list(b)[len(b) - 1] == 'u':
		print('JAPANESE')
	if list(b)[len(b) - 1] == 'a':
		print('KOREAN')


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


t = int(input())
for i in range(0, t):
	s = input()
	if len(s) >= 5:
		if s[-5:] == 'mnida':
			flag = 3
		elif s[-4:] == 'desu' or s[-4:] == 'masu':
			flag = 2
		else:
			flag = 1
	elif len(s) >= 4:
		if s[-4:] == 'desu' or s[-4:] == 'masu':
			flag = 2
		else:
			flag = 1
	else:
		flag = 1
	if flag == 1:
		print('FILIPINO')
	elif flag == 2:
		print('JAPANESE')
	else:
		print('KOREAN')


t = int(input())
while t:
	s = input()
	ln = len(s)
	if s.rfind('po') == ln - 2:
		print('FILIPINO')
	elif s.rfind('desu') == ln - 4 or s.rfind('masu') == ln - 4:
		print('JAPANESE')
	else:
		print('KOREAN')
	t -= 1


t = int(input())
if t >= 1 and t <= 30:
	for i in range(t):
		char = input()
		length = len(char)
		filipino = char[length - 2:length]
		japanese = char[length - 4:length]
		korean = char[length - 5:length]
		if filipino == 'po':
			print('FILIPINO')
		elif japanese == 'desu' or japanese == 'masu':
			print('JAPANESE')
		elif korean == 'mnida':
			print('KOREAN')


cases = int(input())

def find(string, suffix):
	if len(string) < len(suffix):
		return False
	k = 0
	for i in range(len(string) - len(suffix), len(string)):
		if string[i] is not suffix[k]:
			return False
		k = k + 1
	return True
for _ in range(cases):
	string = input()
	if find(string, 'desu') or find(string, 'masu'):
		print('JAPANESE')
	elif find(string, 'mnida'):
		print('KOREAN')
	elif find(string, 'po'):
		print('FILIPINO')


import sys

def get_single_int():
	return int(sys.stdin.readline().strip())

def get_string():
	return sys.stdin.readline().strip()

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
for i in range(get_single_int()):
	s = get_string()
	if s.endswith('po') == True:
		print('FILIPINO')
	if s.endswith('desu') == True or s.endswith('masu'):
		print('JAPANESE')
	if s.endswith('mnida') == True:
		print('KOREAN')


t = int(input())
for i in range(0, t):
	str1 = input()
	if str1.endswith('po'):
		print('FILIPINO')
	if str1.endswith('desu') or str1.endswith('masu'):
		print('JAPANESE')
	if str1.endswith('mnida'):
		print('KOREAN')


t = int(input())
while t != 0:
	starr = str(input())
	if 'po' in starr[-2:]:
		print('FILIPINO')
	elif 'desu' in starr[-4:]:
		print('JAPANESE')
	elif 'masu' in starr[-4:]:
		print('JAPANESE')
	elif 'mnida' in starr[-5:]:
		print('KOREAN')
	t -= 1


t = int(input())
for _ in range(t):
	l = input()
	s = l[-5:]
	ans = ''
	for i in s:
		ans = i + ans
	s = ans
	if s[:2] == 'op':
		print('FILIPINO')
	elif s[:4] == 'used' or s[:4] == 'usam':
		print('JAPANESE')
	else:
		print('KOREAN')


n = int(input())
for i in range(n):
	res = ''
	s = input()
	for i in range(len(s) - 1, -1, -1):
		res = res + s[i]
		if len(res) == 2 and res == 'op':
			print('FILIPINO')
			break
		elif len(res) == 4 and (res == 'used' or res == 'usam'):
			print('JAPANESE')
			break
		elif len(res) == 5 and res == 'adinm':
			print('KOREAN')
			break


op = []
t = int(input())
l = []
for i in range(t):
	l.append(input())
name = 'sapo'
print(name[-1:-2])
for j in range(len(l)):
	name = l[j]
	if name[-2:] == 'po':
		print('FILIPINO')
		continue
	elif name[-4:] == 'desu':
		print('JAPANESE')
		continue
	elif name[-4:] == 'masu':
		print('JAPANESE')
	elif name[-5:] == 'mnida':
		print('KOREAN')
		continue


import re
freg = re.compile('.*po$')
jreg1 = re.compile('.*desu$')
jreg2 = re.compile('.*masu$')
kreg = re.compile('.*mnida$')
for _ in [0] * int(input()):
	curr = input()
	if re.match(freg, curr):
		print('FILIPINO')
	if re.match(jreg1, curr) or re.match(jreg2, curr):
		print('JAPANESE')
	if re.match(kreg, curr):
		print('KOREAN')


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	s = input().strip()
	n = len(s)

	def endswith(x):
		x = x.strip()
		m = len(x)
		if n < m:
			return 0
		if s[n - m:n] == x:
			return 1
		return 0
	if endswith('po'):
		print('FILIPINO')
	elif endswith('desu') or endswith('masu'):
		print('JAPANESE')
	elif endswith('mnida'):
		print('KOREAN')


t = int(input())
for i in range(t):
	a = input().strip()
	p1 = reversed(a)
	p = list(p1)
	if p[0:2] == ['o', 'p']:
		print('FILIPINO')
	elif p[0:4] == ['u', 's', 'e', 'd'] or p[0:4] == ['u', 's', 'a', 'm']:
		print('JAPANESE')
	else:
		print('KOREAN')


import os
import sys
import bisect
from math import gcd, ceil
from heapq import heapify, heappop, heappush
from io import BytesIO, IOBase

def main():
	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')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = lambda s: self.buffer.write(s.encode()) if self.writable else None

	def read(self):
		if self.buffer.tell():
			return self.buffer.read().decode('ascii')
		return os.read(self._fd, os.fstat(self._fd).st_size).decode('ascii')

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline().decode('ascii')

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

def print(*args, sep=' ', end='\n', file=sys.stdout, flush=False):
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(end)
	if flush:
		file.flush()
(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
sys.setrecursionlimit(10000)
main()


number = int(input())
for n in range(number):
	word = input()
	if word[-2:] == 'po':
		print('FILIPINO')
	elif word[-4:] == 'desu' or word[-4:] == 'masu':
		print('JAPANESE')
	elif word[-5:] == 'mnida':
		print('KOREAN')


def Bitplus():
	n = int(input())
	x = 0
	for i in range(n):
		a = input()
		if '+' in a:
			x += 1
		else:
			x -= 1
	print(x)

def GiftSetidk():
	n = int(input())
	for i in range(n):
		all = input().split(' ')
		x = int(all[0])
		y = int(all[1])
		a = int(all[2])
		b = int(all[3])
		counter = 0
		count = True
		while count:
			if x >= a and y >= b:
				x -= a
				y -= b
				counter += 1
			elif x >= b and y >= a:
				x -= b
				y -= a
				counter += 1
			else:
				count = False
		print(counter)

def Team():
	n = int(input())
	problemcount = 0
	for i in range(n):
		count = 0
		answer = input().split(' ')
		for i in range(len(answer)):
			answer[i] = int(answer[i])
		for i in answer:
			if i == 1:
				count += 1
		if count >= 2:
			problemcount += 1
	print(problemcount)

def NextRound():
	nk = input().split(' ')
	n = int(nk[0])
	k = int(nk[1])
	print(n, k)
	scores = input().split(' ')
	count = 0
	for i in range(n):
		scores[i] = int(scores[i])
	five = scores[k]
	for i in range(n):
		if scores[i] >= five and scores[i] > 0:
			count += 1
	print(count)

def Beautifulmatrix():
	steps = 0
	matrixes = []
	for i in range(5):
		i = [input().split(' ')]
		matrixes += i
	for i in range(5):
		for j in range(5):
			matrixes[i][j] = int(matrixes[i][j])
	for i in range(5):
		for j in range(5):
			if matrixes[i][j] > 0:
				x = j
				y = i
				break
	while x != 2 or y != 2:
		if x > 2:
			x -= 1
			steps += 1
		elif x < 2:
			x += 1
			steps += 1
		elif y > 2:
			y -= 1
			steps += 1
		elif y < 2:
			y += 1
			steps += 1
	print(steps)

def HelpfulMahts():
	s = input().split('+')
	s.sort()
	print('+'.join(s))

def WordCapitalization():
	word = input()
	List = []
	for i in word:
		List.append(i)
	List[0] = List[0].upper()
	s = ''
	for i in List:
		s += i
	print(s)

def Stonesonthetable():
	n = int(input())
	stones = []
	rrg = input()
	counter = 0
	for i in rrg:
		stones.append(i)
	for i in range(n - 1):
		if stones[i] == stones[i + 1]:
			counter += 1
	print(counter)

def BearandBigBrother():
	inpuut = input().split(' ')
	a = int(inpuut[0])
	b = int(inpuut[1])
	year = 0
	while a <= b:
		a *= 3
		b *= 2
		year += 1
	print(year)

def Wrongsubtraction():
	nk = input().split(' ')
	n = int(nk[0])
	k = int(nk[1])
	for i in range(k):
		p = str(n)
		if p[len(p) - 1] == '0':
			n //= 10
		else:
			n -= 1
	print(n)
import string

def Word():
	word = input()
	lower = 0
	upper = 0
	for i in word:
		if i in string.ascii_lowercase:
			lower += 1
		else:
			upper += 1
	if upper > lower:
		word = word.upper()
	else:
		word = word.lower()
	print(word)

def QueueattheSchool():
	nt = input().split(' ')
	n = nt[0]
	t = int(nt[1])
	a = input()
	b = []
	ref = ''
	for i in a:
		b.append(i)
	for k in range(t):
		whre = []
		for i in range(len(b) - 1):
			if b[i] == 'B' and b[i + 1] != 'B':
				whre.insert(0, i)
		for j in whre:
			b.pop(j)
			b.insert(j + 1, 'B')
	for i in b:
		ref += i
	print(ref)

def Nearlyluckynumber():
	n = input()
	if n.count('7') + n.count('4') == 7 or n.count('7') + n.count('4') == 4:
		print('YES')
	else:
		print('NO')

def Translation():
	s = input()
	t = input()
	n = []
	for i in t:
		n.insert(0, i)
	t = ''
	for i in n:
		t += i
	if t == s:
		print('YES')
	else:
		print('NO')

def ANTONandDanik():
	n = int(input())
	s = input()
	A = s.count('A')
	D = s.count('D')
	if A > D:
		print('Anton')
	elif D > A:
		print('Danik')
	else:
		print('Friendship')

def GeorgeandAccomodation():
	n = int(input())
	rooms = 0
	for i in range(n):
		pq = input().split(' ')
		p = int(pq[0])
		q = int(pq[1])
		if q - p >= 2:
			rooms += 1
	print(rooms)

def Magnets():
	n = int(input())
	Rows = []
	groups = 1
	for i in range(n):
		Rows += [input()]
	for i in range(n - 1):
		if Rows[i] != Rows[i + 1]:
			groups += 1
	print(groups)

def InSearcoanEasyProblem():
	n = int(input())
	counter = 0
	s = input().split(' ')
	if '1' in s:
		print('HARD')
	else:
		print('EASY')

def Hulk():
	c = int(input())
	i = 'I'
	s = ''
	it = 'it'
	for i in range(1, c + 1):
		if i == 1:
			s += 'hate '
		elif i % 2 == 0:
			s += 'that I love '
		else:
			s += 'that I hate '
	print(f'I {s}it')

def CalculatingFunctionidk():
	n = int(input())
	c = 0
	for i in range(1, n + 1):
		if i % 2 != 0:
			c -= i
		else:
			c += i
	print(c)

def IWannaBetheGuyidk():
	n = int(input())
	p = input().split(' ')
	q = input().split(' ')
	counter = 0
	for i in range(1, n + 1):
		if str(i) in p or str(i) in q:
			counter += 1
	if counter == n:
		print('I become the guy.')
	else:
		print('Oh, my keyboard!')

def horsesheo():
	n = input().split(' ')
	many = 4
	whatwas = []
	for i in range(len(n)):
		n[i] = int(n[i])
		if n[i] not in whatwas:
			whatwas.append(n[i])
	print(many - len(whatwas))

def ArrivaloftheGeneralidk():
	n = int(input())
	a = input().split(' ')
	max = 0
	minlist = []
	for i in range(n):
		a[i] = int(a[i])
	for i in a:
		if i > max:
			max = i
	maxloc = a.index(max)
	for i in a:
		minlist.insert(0, i)
	min = max
	for i in a:
		if i < min:
			min = i
	minloc = minlist.index(min)
	print(minloc + maxloc)

def UltraFastMathematician():
	first = input()
	second = input()
	s = ''
	for i in range(len(first)):
		if first[i] == '0' and second[i] == '1':
			s += '1'
		elif first[i] == '1' and second[i] == '0':
			s += '1'
		elif first[i] == '0' and second[i] == '0':
			s += '0'
		elif first[i] == '1' and second[i] == '1':
			s += '0'
	print(s)

def Insomniacure():
	klmn = []
	for i in range(4):
		klmn.append(int(input()))
	d = int(input())
	List = []
	if 1 in klmn:
		return d
	for i in range(4):
		mulit = klmn[i]
		while klmn[i] <= d:
			if klmn[i] not in List:
				List.append(klmn[i])
			klmn[i] += mulit
	return len(List)

def AntonandLetters():
	first = input()
	List = []
	for i in first:
		if i not in List and i in string.ascii_lowercase:
			List.append(i)
	print(len(List))

def Pangram():
	n = int(input())
	word = input().lower()
	List = []
	if n >= 26:
		for i in word:
			if i not in List:
				List.append(i)
		if len(List) == 26:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')

def Collectingcoons():
	n = int(input())
	for i in range(n):
		abcd = input().split(' ')
		for i in range(len(abcd)):
			abcd[i] = int(abcd[i])
		d = abcd[3]
		abcd.pop()
		maxi = 0
		for i in abcd:
			if i > maxi:
				maxi = i
		allindexes = [0, 1, 2]
		indexmax = abcd.index(maxi)
		allindexes.pop(indexmax)
		allminus = 0
		for i in allindexes:
			allminus += abcd[indexmax] - abcd[i]
		d -= allminus
		if d % 3 == 0 and d >= 0:
			print('YES')
		else:
			print('NO')

def Brainsphotos():
	nm = input().split(' ')
	colors = []
	for i in range(int(nm[0])):
		colors += input().split(' ')
	for i in colors:
		if i == 'C' or i == 'M' or i == 'Y':
			return '#Color'
	return '#Black&White'

def SerejaandDima():
	n = int(input())
	card = input().split(' ')
	S = 0
	D = 0
	sturn = True
	for i in range(n):
		if int(card[0]) > int(card[len(card) - 1]):
			if sturn:
				S += int(card[0])
				card.pop(0)
				sturn = False
			else:
				D += int(card[0])
				card.pop(0)
				sturn = True
		elif sturn:
			S += int(card[len(card) - 1])
			card.pop(len(card) - 1)
			sturn = False
		else:
			D += int(card[len(card) - 1])
			card.pop(len(card) - 1)
			sturn = True
	print(f'{S} {D}')

def Vanyaandcubes():
	n = int(input())
	counter = 1
	countdodo = 0
	rows = 0
	while n > 0:
		countdodo += counter
		counter += 1
		rows += 1
		n -= countdodo
	if n == 0:
		print(rows)
	else:
		print(rows - 1)

def GennadyandaCarGame():
	card = input()
	cards = input().replace(' ', '')
	for i in card:
		for j in cards:
			if i == j:
				return 'YES'
	return 'NO'

def FafaandhisCompany():
	n = int(input())
	ways = 0
	for i in range(1, n):
		a = n
		a -= i
		if a % i == 0:
			ways += 1
	print(ways)

def Mahmoudandehabandtheevenoddgame():
	n = int(input())
	Mahmoudsturn = True
	Mahmoudlsot = False
	Ehablost = False
	a = 0
	while not Mahmoudlsot and (not Ehablost):
		if Mahmoudsturn:
			if n % 2 == 0 and n >= 2:
				Ehablost = True
			elif n % 2 != 0 and n >= 2:
				a = n - 1
			else:
				Mahmoudlsot = True
		elif n % 2 == 1 and n >= 1:
			Mahmoudlsot = True
		elif n % 2 == 0 and n >= 1:
			a = n - 1
		else:
			Ehablost = False
		n -= a
		if Mahmoudsturn == True:
			Mahmoudsturn = False
		else:
			Mahmoudsturn = True
	if Mahmoudlsot == True:
		print('Ehab')
	else:
		print('Mahmoud')

def FloorNumber():
	t = int(input())
	for i in range(t):
		nx = input().split(' ')
		n = int(nx[0])
		x = int(nx[1])
		aparteements = 2
		floor = 1
		while n > aparteements:
			aparteements += x
			floor += 1
		print(floor)

def VustheCossackandaContest():
	nmk = input().split(' ')
	n = int(nmk[0])
	m = int(nmk[1])
	k = int(nmk[2])
	if n <= m and n <= k:
		print('Yes')
	else:
		print('No')

def NightattheMuseum():
	word = input()
	rotations = 0
	lower = string.ascii_lowercase + string.ascii_lowercase + string.ascii_lowercase
	loc = lower.index('a', 26, 2 * 26)
	for i in word:
		cplus = loc
		cminus = loc
		keep = True
		while keep:
			if i == lower[cplus] or i == lower[cminus]:
				keep = False
			else:
				cplus += 1
				cminus -= 1
				rotations += 1
				loc = lower.index(i, 26, 2 * 26)
	print(rotations)

def OrdinarYnumbers():
	n = int(input())
	for i in range(n):
		k = int(input())
		counter = 0
		for j in range(1, k + 1):
			a = str(j)
			if len(a) == a.count(a[0]):
				counter += 1
		print(counter)

def DieRoll():
	n = input().split(' ')
	y = int(n[0])
	w = int(n[1])
	number = 0
	dec = 6
	if y >= w:
		for i in range(y, 7):
			number += 1
	else:
		for i in range(w, 7):
			number += 1
	if number % 6 == 0:
		number = number // 6
		dec = 1
	elif number % 3 == 0:
		number = number // 3
		dec = 2
	elif number % 2 == 0:
		number = number // 2
		dec = 3
	print(f'{number}/{dec}')

def Borze():
	n = input()
	l = ''
	k = ''
	for i in n:
		if i == '.' and len(l) == 0:
			k += '0'
		else:
			l += i
			if len(l) == 2:
				if l == '-.':
					k += '1'
					l = ''
				else:
					k += '2'
					l = ''
	print(k)

def FairPlayoff():
	n = int(input())
	for i in range(n):
		loser = {}
		winner = {}
		count = 0
		k = input().split(' ')
		if int(k[0]) > int(k[1]):
			loser['one'] = int(k[1])
			winner['two'] = int(k[0])
		else:
			loser['one'] = int(k[0])
			winner['two'] = int(k[1])
		if int(k[2]) > int(k[3]):
			loser['two'] = int(k[3])
			winner['one'] = int(k[2])
		else:
			loser['two'] = int(k[2])
			winner['one'] = int(k[3])
		for i in loser:
			if loser[i] < winner[i]:
				count += 1
		if count >= 2:
			print('YES')
		else:
			print('NO')

def Bustoudaylanbd():
	n = int(input())
	s = []
	rem = -1
	first = True
	ss = ''
	for i in range(n):
		s += input().split('|')
	for i in range(len(s)):
		if s[i] == 'OO' and first:
			rem = i
			s[i] = '++'
			first = False
	for i in range(len(s)):
		if i % 2 == 0:
			ss += s[i] + '|'
		else:
			ss += s[i] + '\n'
	if not first:
		print('YES')
		print(ss)
	else:
		print('NO')

def Maximumincrease():
	n = int(input())
	arraa = input().split(' ')
	for i in range(len(arraa)):
		arraa[i] = int(arraa[i])
	counter = {}
	for i in range(n):
		counter[i] = 0
	count = 0
	last = 0
	for i in arraa:
		if i > last:
			last = i
			counter[count] += 1
		else:
			last = i
			count += 1
			counter[count] += 1
	max = 0
	for i in range(n):
		if counter[i] > max:
			max = counter[i]
	print(max)

def Jugglingletters():
	n = int(input())
	for i in range(n):
		k = int(input())
		s = ''
		map = {}
		possible = True
		for i in range(k):
			s += input()
		for i in s:
			if i not in map:
				map[i] = 1
			else:
				map[i] += 1
		for i in map:
			if map[i] % k != 0:
				possible = False
		if possible:
			print('YES')
		else:
			print('NO')

def Panoramixsprediction():
	nm = input().split(' ')
	n = int(nm[0])
	m = int(nm[1])
	first = True
	for i in range(n + 1, m):
		count = 0
		for j in range(2, i):
			if i % j == 0:
				count += 1
		if count == 0:
			first = False
			break
	if first:
		count = 0
		for j in range(2, m):
			if m % j == 0:
				count += 1
		if count == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')

def ThreepilesofCanides():
	k = int(input())
	for i in range(k):
		n = input().split(' ')
		canides = 0
		for i in n:
			canides += int(i)
		if canides % 2 != 0:
			canides -= 1
		print(canides // 2)

def filename():
	n = int(input())
	name = input()
	more = 0
	map = {}
	map[more] = 0
	count = 0
	for i in name:
		if i == 'x':
			map[more] += 1
		elif map[more] != 0:
			more += 1
			map[more] = 0
	for i in map:
		if map[i] >= 3:
			while map[i] > 2:
				map[i] -= 1
				count += 1
	print(count)

def Football():
	map = {}
	current = 0
	s = input()
	f = s[0]
	map[current] = 0
	check = False
	for i in s:
		if i == f:
			map[current] += 1
		else:
			current += 1
			map[current] = 1
			f = i
	for i in map:
		if map[i] >= 7:
			check = True
	if check:
		print('YES')
	else:
		print('NO')

def CombinationLock1():
	n = int(input())
	fl = input()
	sl = input()
	count = 0
	for i in range(n):
		goup = int(fl[i])
		god = int(fl[i])
		cu = 0
		cd = 0
		keep = True
		while keep:
			if goup + 1 <= 9:
				goup += 1
				cu += 1
			else:
				goup = 0
				cu += 1
			if god - 1 >= 0:
				god -= 1
				cd += 1
			else:
				god = 9
				cd += 1
			if goup == int(sl[i]):
				count += cu
				keep = False
			elif god == int(sl[i]):
				count += cd
				keep = False
	print(count)

def Watermelon():
	n = int(input())
	down = n // 2
	up = n - down
	rge = up
	for i in range(rge):
		if up % 2 == 0 and down % 2 == 0:
			return print('YES')
		elif up + 1 < n and down - 1 > 0:
			up += 1
			down -= 1
		else:
			return print('NO')

def Dominopiling():
	nk = input().split(' ')
	n = int(nk[0])
	k = int(nk[1])
	mnk = n * k
	print(mnk // 2)

def yetanotherBookshelf():
	n = int(input())
	for i in range(n):
		le = int(input())
		K = input().split(' ')
		SK = []
		lili = []
		for i in range(le):
			if i + 1 <= le - 1:
				if K[i] == '1' and K[i + 1] == '1':
					lili.append(i)
		lili.reverse()
		for i in lili:
			K.pop(i)
		coun = 0
		while K.count('1') > 1:
			f = K.index('1')
			K.pop(f)
			K.insert(f + 1, '1')
			f += 1
			if K[f + 1] == '1':
				K.pop(f)
			coun += 1
		print(coun)

def Combinationlockittakestolong():
	n = int(input())
	fl = input()
	sl = input()
	counter = 0
	for i in range(n):
		up = int(fl[i])
		down = int(fl[i])
		while True:
			if up + 1 <= 9:
				up += 1
			else:
				up = 0
			if down - 1 >= 0:
				down -= 1
			else:
				down = 9
			counter += 1
			if up == int(sl) or down == int(sl):
				break

def iwannabetheguytolong():
	n = int(input())
	lvl = input().split(' ')
	lvls = input().split(' ')
	for i in range(1, n + 1):
		if str(i) not in lvl and str(i) not in lvls:
			return print('Oh, my keyboard!')
	return print('I become the guy.')

def giftsettolong():
	n = int(input())
	for i in range(n):
		rb = input().split(' ')
		x = int(rb[0])
		y = int(rb[1])
		a = int(rb[2])
		b = int(rb[3])
		giftset = 0
		while True:
			if x - a >= 0 and y - b >= 0:
				x -= a
				y -= b
				giftset += 1
			elif x - b >= 0 and y - a >= 0:
				x -= b
				y -= a
				giftset += 1
			else:
				break
		print(giftset)

def uniquwbidauctiontime():
	n = int(input())
	for i in range(n):
		k = int(input())
		list = input().split(' ')
		o = -1
		for i in range(k):
			if list.count(list[i]) == 1:
				if o == -1 or list[i] < o:
					o = list[i]
		if o != -1:
			print(list.index(o) + 1)
		else:
			print(o)

def equalizepriceagain():
	n = int(input())
	for i in range(n):
		k = int(input())
		numbers = input().split(' ')
		for i in range(len(numbers)):
			numbers[i] = int(numbers[i])
		total = 0
		for i in numbers:
			total += i
		if total % k == 0:
			print(total // k)
		else:
			while total % k != 0:
				total += 1
			print(total // k)

def shortsubstrings():
	n = int(input())
	for i in range(n):
		s = input()
		laist = []
		for i in range(len(s)):
			if i % 2 != 0 and i != len(s) - 1:
				laist.append(i)
		laist.reverse()
		s = list(s)
		for i in laist:
			s.pop(i)
		sa = ''
		for i in s:
			sa += i
		print(sa)

def policerecruits():
	n = int(input())
	k = input().split(' ')
	officers = 0
	crimes = 0
	for i in k:
		if int(i) == -1:
			if officers == 0:
				crimes += 1
			else:
				officers -= 1
		else:
			officers += int(i)
	print(crimes)

def thenewyear():
	xxx = input().split(' ')
	for i in range(len(xxx)):
		xxx[i] = int(xxx[i])
	xxx.sort()
	way = 0
	way += abs(int(xxx[1]) - int(xxx[0]))
	way += abs(int(xxx[1]) - int(xxx[2]))
	print(way)

def frogjumpingtimelimit():
	n = int(input())
	for i in range(n):
		abk = input().split(' ')
		a = int(abk[0])
		b = int(abk[1])
		k = int(abk[2])
		all = 0
		for i in range(k):
			if i % 2 == 0:
				all += a
			else:
				all -= b
		print(all)

def patrickandshopping():
	d = input().split(' ')
	d3 = 0
	for i in range(len(d)):
		if int(d[i]) > d3:
			d3 = int(d[i])
	d.pop(d.index(str(d3)))
	d1 = int(d[0])
	d2 = int(d[1])
	distance = d1 + d2
	if d3 <= distance:
		distance += d3
	else:
		distance += distance
	print(distance)

def Freeicecream():
	nx = input().split(' ')
	n = int(nx[0])
	ice = int(nx[1])
	diskid = 0
	for i in range(n):
		k = input().split(' ')
		if k[0] == '+':
			ice += int(k[1])
		elif ice >= int(k[1]):
			ice -= int(k[1])
		else:
			diskid += 1
	print(ice, diskid)

def Reviewsite():
	t = int(input())
	for i in range(t):
		n = int(input())
		upvotes = 0
		votes = input().split(' ')
		for i in votes:
			if i != '2':
				upvotes += 1
		print(upvotes)

def Lastyeasrtssubstring():
	t = int(input())
	for i in range(t):
		n = int(input())
		s = input()
		if s[0:4] == '2020' or s[n - 4:n] == '2020':
			print('YES')
		elif s[0:3] == '202' and s[n - 1] == '0':
			print('YES')
		elif s[n - 3:n] == '020' and s[0] == '2':
			print('YES')
		elif s[0:2] == '20' and s[n - 2] == '20':
			print('YES')
		elif s[n - 2:n] == '20' and s[0:2] == '20':
			print('YES')
		else:
			print('NO')

def Arena():
	t = int(input())
	for i in range(t):
		n = int(input())
		heros = input().split(' ')
		heorsint = [int(i) for i in heros]
		heorsint.sort()
		min = heorsint[0]
		winner = n - heorsint.count(min)
		print(winner)

def twoRabbitstoolongbutright():
	t = int(input())
	for i in range(t):
		xyab = input().split(' ')
		x = int(xyab[0])
		y = int(xyab[1])
		a = int(xyab[2])
		b = int(xyab[3])
		seconds = 0
		while x < y:
			x += a
			y -= b
			seconds += 1
		if x == y:
			print(seconds)
		else:
			print(-1)

def systemofequations():
	nm = input().split(' ')
	n = int(nm[0])
	m = int(nm[1])
	nm = [int(i) for i in nm]
	nm.sort()
	count = 0
	for i in range(nm[0] + 1):
		for j in range(nm[0] + 1):
			if i ** 2 + j == n and j ** 2 + i == m:
				count += 1
	print(count)

def polycarpwspockets():
	n = int(input())
	coins = input().split(' ')
	coins = [int(i) for i in coins]
	pocket = 0
	for i in coins:
		nmumbver = coins.count(i)
		if nmumbver > pocket:
			pocket = nmumbver
	print(pocket)

def repeaqtijgcipher():
	n = int(input())
	s = input()
	counter = 0
	rep = 1
	ns = ''
	while counter < n:
		counter += rep
		ns += s[counter - 1]
		rep += 1
	print(ns)

def Neaarestinterestingnumber():
	a = input()
	s = int(a)
	while True:
		if sum((int(i) for i in str(s))) % 4 == 0:
			return print(s)
		else:
			s += 1

def therearetwotzpesofburgers():
	t = int(input())
	for i in range(t):
		ess = input().split(' ')
		ess = [int(i) for i in ess]
		price = input().split(' ')
		buns = int(ess[0])
		totalmoney = 0
		first = True
		if int(price[0]) > int(price[1]):
			patties = ess[1]
			otherpatties = ess[2]
			money = int(price[0])
			othermoney = int(price[1])
		else:
			patties = ess[2]
			otherpatties = ess[1]
			money = int(price[1])
			othermoney = int(price[0])
		keep = True
		while keep:
			if buns - 2 >= 0 and patties - 1 >= 0:
				buns -= 2
				patties -= 1
				totalmoney += money
			elif buns - 2 >= 0 and patties == 0:
				if first:
					patties = otherpatties
					money = othermoney
					first = False
				else:
					print(totalmoney)
					keep = False
			else:
				print(totalmoney)
				keep = False

def threeswimmerstimelimitebutseemsright():
	t = int(input())
	for i in range(t):
		pabc = input().split(' ')
		pabc = [int(i) for i in pabc]
		a = 0
		b = 0
		c = 0
		p = pabc[0]
		keep = True
		while keep:
			if a < p:
				a += pabc[1]
			if b < p:
				b += pabc[2]
			if c < p:
				c += pabc[3]
			if a >= p and b >= p and (c >= p):
				list = [a - p, b - p, c - p]
				list.sort()
				print(list[0])
				keep = False

def Gregsworkout():
	n = int(input())
	training = input().split(' ')
	training = [int(i) for i in training]
	map = [0, 0, 0]
	current = 0
	for i in training:
		map[current] += i
		if current < 2:
			current += 1
		else:
			current = 0
	sorte = []
	for i in map:
		sorte.append(i)
	sorte.sort()
	index = map.index(sorte[2])
	if index == 0:
		print('chest')
	elif index == 1:
		print('biceps')
	else:
		print('back')

def heisttimelimitebutseemsright():
	n = int(input())
	all = input().split(' ')
	all = [int(i) for i in all]
	all.sort()
	counter = 0
	for i in range(all[0], all[len(all) - 1]):
		if i not in all:
			counter += 1
	print(counter)

def nonzero():
	t = int(input())
	for i in range(t):
		n = int(input())
		numbers = input().split(' ')
		count = numbers.count('0')
		for i in range(count):
			ind = numbers.index('0')
			numbers.pop(ind)
			numbers.insert(ind, '1')
		numbers = [int(i) for i in numbers]
		if sum(numbers) == 0:
			count += 1
		print(count)

def distinctdigits():
	lr = input().split(' ')
	for i in range(int(lr[0]), int(lr[1]) + 1):
		couynt = []
		for j in str(i):
			if j not in couynt:
				couynt.append(j)
		if len(couynt) == len(str(i)):
			return print(i)
	else:
		return print(-1)

def dawidandbagsofcandies():
	bags = input().split(' ')
	bags = [int(i) for i in bags]
	bags.sort()
	if bags[0] + bags[3] == bags[1] + bags[2]:
		print('YES')
	elif bags[3] == bags[0] + bags[1] + bags[2]:
		print('YES')
	else:
		print('NO')

def lastminuteenhancements():
	t = int(input())
	for i in range(t):
		n = int(input())
		notes = input().split(' ')
		lists = []
		for i in notes:
			if int(i) not in lists:
				lists.append(int(i))
			elif int(i) + 1 not in lists:
				lists.append(int(i) + 1)
		print(len(lists))

def Cakeminator():
	rc = input().split(' ')
	cake = []
	pices = 0
	rows = 0
	for i in range(int(rc[0])):
		cake.append([i for i in input()])
	for i in range(int(rc[1])):
		count = 0
		for j in range(int(rc[0])):
			if cake[j][i] == '.':
				count += 1
			if count == int(rc[0]):
				pices += count
				rows += 1
	for i in range(int(rc[0])):
		if 'S' not in cake[i]:
			pices += int(rc[1]) - rows
	print(pices)

def CME():
	t = int(input())
	for i in range(t):
		n = int(input())
		four = 4
		while four < n:
			four += 2
		print(four - n)

def FriendsandCandies():
	t = int(input())
	for i in range(t):
		n = int(input())
		cadies = input().split(' ')
		cadies = [int(i) for i in cadies]
		all = sum(cadies) % n
		count = 0
		if all != 0:
			print(-1)
		else:
			for i in cadies:
				if i > sum(cadies) // n:
					count += 1
			print(count)

def tworivalstudents():
	t = int(input())
	for i in range(t):
		nxab = input().split(' ')
		n = int(nxab[0])
		x = int(nxab[1])
		if int(nxab[2]) >= int(nxab[3]):
			bigger = int(nxab[2])
			smaller = int(nxab[3])
		else:
			bigger = int(nxab[3])
			smaller = int(nxab[2])
		for i in range(x):
			if bigger < n:
				bigger += 1
			elif smaller > 1:
				smaller -= 1
			else:
				break
		print(bigger - smaller)

def OmkarandPassword():
	t = int(input())
	for i in range(t):
		n = int(input())
		array = input().split(' ')
		array = [int(i) for i in array]
		pointer = 0
		while array.count(array[0]) != len(array):
			if array[pointer] != array[pointer + 1]:
				array.insert(pointer, array[pointer] + array[pointer + 1])
				array.pop(pointer)
				array.pop(pointer + 1)
			elif pointer + 1 < len(array) - 1:
				pointer += 1
			else:
				pointer = 0
		print(len(array))

def tanyaasndstairways():
	n = int(input())
	k = input().split(' ')
	k = [int(i) for i in k]
	last = []
	storeys = k.count(1)
	for i in range(n - 1):
		if k[i] >= k[i + 1]:
			last.append(k[i])
	last.append(k[n - 1])
	print(storeys)
	printable = ''
	for i in last:
		printable += str(i) + ' '
	print(printable)

def adjacentreplacements():
	t = int(input())
	wowowo = input()
	wo = wowowo.split(' ')
	wo = [int(i) for i in wo]
	for i in range(t):
		if wo[i] % 2 == 0:
			wo[i] -= 1
	s = ''
	for i in wo:
		s += str(i) + ' '
	print(s)

def Divideit():
	t = int(input())
	for i in range(t):
		n = int(input())
		counter = 0
		while n > 1:
			if n % 2 == 0:
				n = n // 2
				counter += 1
			elif n % 3 == 0:
				n = 2 * n // 3
				counter += 1
			elif n % 5 == 0:
				n = 4 * n // 5
				counter += 1
			else:
				counter = -1
				break
		print(counter)

def DiverseTeam():
	nk = input().split(' ')
	n = int(nk[0])
	k = int(nk[1])
	rating = input().split(' ')
	list = []
	s = ''
	for i in range(n):
		if rating[i] not in list:
			list.append(rating[i])
			s += str(i + 1) + ' '
		if len(list) == k:
			print('YES')
			return print(s)
	return print('NO')

def phoenixandgold():
	t = int(input())
	for i in range(t):
		nx = input().split(' ')
		n = int(nx[0])
		x = int(nx[1])
		gold = input().split(' ')
		gold = [int(i) for i in gold]
		count = 0
		s = ''
		if sum(gold) == x:
			print('NO')
		else:
			while len(gold) != 0:
				for i in range(len(gold)):
					if i < len(gold):
						if gold[i] + count != x:
							count += gold[i]
							s += str(gold[i]) + ' '
							gold.pop(i)
			print('YES')
			print(s)

def ingamechat():
	t = int(input())
	for i in range(t):
		n = int(input())
		s = input()
		c = 0
		for i in s:
			if i == ')':
				c += 1
			else:
				c = 0
		if c > n - c:
			print('Yes')
		else:
			print('No')

def IntegerSAequencedividing():
	list = [int(i) for i in range(1, int(input()) + 1)]
	list.reverse()
	A = 0
	B = 0
	while len(list) > 0:
		if len(list) != 1:
			one = list[0]
			two = list[1]
			list.pop(0)
			list.pop(0)
		else:
			one = list[0]
			list.pop(0)
			two = 0
		if abs(A + one - (B + two) <= abs(B + one - (A + two))):
			A += one
			B += two
		else:
			A += two
			B += one
	print(abs(A - B))

def shortestpathwithobstacle():
	t = int(input())
	for i in range(t):
		s = input()
		A = [int(i) for i in input().split(' ')]
		B = [int(i) for i in input().split(' ')]
		F = [int(i) for i in input().split(' ')]
		distance = abs(A[0] - B[0]) + abs(A[1] - B[1])
		if A[0] == B[0] and A[0] == F[0] and (min(A[1], B[1]) < F[1]) and (F[1] < max(A[1], B[1])) or (A[1] == B[1] and A[1] == F[1] and (min(A[0], B[0]) < F[0]) and (F[0] < max(A[0], B[0]))):
			distance += 2
		print(distance)

def Removeduplicates():
	t = int(input())
	numbers = input().split(' ')
	numbers.reverse()
	removed = []
	for i in numbers:
		if i not in removed:
			removed.append(i)
	removed.reverse()
	s = ''
	for i in removed:
		s += i + ' '
	print(len(removed))
	print(s)

def Threestrings():
	t = int(input())
	for i in range(t):
		a = input()
		b = input()
		c = input()
		work = True
		for i in range(len(a)):
			if a[i] != c[i] and b[i] != c[i]:
				work = False
		if work:
			print('YES')
		else:
			print('NO')

def specifictastesofandre():
	t = int(input())
	for i in range(t):
		li = [1 for i in range(int(input()))]
		s = ''
		for i in li:
			s += str(i) + ' '
		print(s)

def dejavu():
	t = int(input())
	for i in range(t):
		s = input()
		if s + 'a' == 'a' + s:
			print('NO')
		else:
			sl = list(s + 'a')
			rsl = []
			for i in sl:
				rsl.insert(0, i)
			if sl != rsl:
				print('YES')
				print(s + 'a')
			else:
				print('YES')
				print('a' + s)

def buythestring():
	t = int(input())
	for i in range(t):
		ncch = [int(i) for i in input().split(' ')]
		s = input()
		money = 0
		for i in s:
			if i == '0':
				money += min(ncch[1], ncch[2] + ncch[3])
			else:
				money += min(ncch[2], ncch[1] + ncch[3])
		print(money)

def Keyraces():
	svvtt = [int(i) for i in input().split(' ')]
	first = 2 * svvtt[3] + svvtt[0] * svvtt[1]
	scond = 2 * svvtt[4] + svvtt[0] * svvtt[2]
	if first > scond:
		print('Second')
	elif first < scond:
		print('First')
	else:
		print('Friendship')

def Angrystudents():
	t = int(input())
	for i in range(t):
		len = int(input())
		s = list(input())
		counter = 0
		counterlist = [0]
		if s.count('A') != 0:
			firstp = s.index('A')
			for i in range(firstp, len):
				if s[i] == 'P':
					counter += 1
				else:
					counterlist.append(counter)
					counter = 0
			counterlist.append(counter)
		print(max(counterlist))

def Frence():
	t = int(input())
	for i in range(t):
		d = sum([int(i) for i in input().split(' ')]) - 1
		print(d)

def playongwhithdice():
	ab = [int(i) for i in input().split(' ')]
	a = ab[0]
	b = ab[1]
	awins = 0
	draw = 0
	bwins = 0
	for i in range(1, 7):
		if abs(i - a) < abs(i - b):
			awins += 1
		elif abs(i - a) > abs(i - b):
			bwins += 1
		else:
			draw += 1
	print(awins, draw, bwins)

def arrayandpeaks():
	t = int(input())
	for i in range(t):
		(n, k) = [int(i) for i in input().split(' ')]
		listaa = [i for i in range(1, n - k + 1)]
		listoo = [i for i in range(n - k + 1, n + 1)]
		s = ''
		if len(listaa) > len(listoo):
			for i in range(len(listaa)):
				s += str(listaa[0]) + ' '
				listaa.pop(0)
				if len(listoo) != 0:
					s += str(listoo[0]) + ' '
					listoo.pop(0)
		else:
			s = '-1'
		print(s)

def mishkaandContest():
	(n, k) = [int(i) for i in input().split()]
	problems = [int(i) for i in input().split()]
	fp = 0
	sp = 0
	first = True
	for i in problems:
		if i <= k and first:
			fp += 1
		elif i > k and first:
			first = False
		elif i <= k and (not first):
			sp += 1
		else:
			sp = 0
	print(sp + fp)

def gotanygrapes():
	xyz = [int(i) for i in input().split(' ')]
	abc = [int(i) for i in input().split(' ')]
	c = 0
	for i in range(3):
		c += abc[i]
		c -= xyz[i]
		if c < 0:
			return print('NO')
	return print('YES')

def stringgenerations():
	t = int(input())
	ABC = ['a', 'b', 'c']
	for i in range(t):
		s = ''
		(n, k) = input().split(' ')
		for i in range(int(n)):
			s += ABC[i % 3]
		print(s)

def gradeallocation():
	t = int(input())
	for i in range(t):
		(n, m) = [int(i) for i in input().split(' ')]
		scores = [int(i) for i in input().split(' ')]
		summa = sum(scores)
		if summa >= m:
			print(m)
		else:
			print(summa)

def shashaandsticks():
	(n, k) = [int(i) for i in input().split(' ')]
	counter = n // k
	if counter % 2 == 0:
		print('NO')
	else:
		print('YES')

def Hoteliero():
	n = int(input())
	s = []
	for i in input():
		s.append(i)
	rooms = [0 for i in range(10)]
	for i in s:
		if i == 'L':
			index = rooms.index(0)
			rooms[index] = 1
		elif i == 'R':
			rooms.reverse()
			index = rooms.index(0)
			rooms[index] = 1
			rooms.reverse()
		else:
			index = int(i)
			rooms[index] = 0
	f = ''
	for i in rooms:
		f += str(i)
	print(f)

def barrels():
	t = int(input())
	for i in range(t):
		(n, k) = [int(i) for i in input().split(' ')]
		barrels = [int(i) for i in input().split(' ')]
		maxbarrelcount = barrels.pop(barrels.index(max(barrels)))
		for i in range(k):
			maxbarrelindex = barrels.index(max(barrels))
			maxbarrelcount += barrels[maxbarrelindex]
			barrels.pop(maxbarrelindex)
		print(maxbarrelcount)

def lovetriangle():
	n = int(input())
	planes = [int(i) - 1 for i in input().split(' ')]
	for i in range(n):
		if planes[planes[planes[i]]] == i:
			return print('YES')
	return print('NO')

def lovesong():
	(n, q) = [int(i) for i in input().split(' ')]
	s = input()
	for i in range(q):
		(l, r) = [int(i) for i in input().split(' ')]
		l -= 1
		substr = s[l:r]
		c = 0
		for i in substr:
			c += string.ascii_lowercase.index(i) + 1
		print(c)

def coins():
	(n, S) = [int(i) for i in input().split(' ')]
	if S % n == 0:
		print(S // n)
	else:
		print(S // n + 1)

def penandpencils9():
	t = int(input())
	for i in range(t):
		(a, b, c, d, k) = [int(i) for i in input().split(' ')]
		(x, y) = (0, 0)
		x += a // c
		if a % c != 0:
			x += 1
		y = b // d
		if b % d != 0:
			y += 1
		if y + x <= k:
			print(x, y)
		else:
			print(-1)

def phonenumber():
	t = int(input())
	for i in range(2):
		n = int(input())
		number = input()
		if '8' in number:
			if n - number.index('8') >= 10:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')

def cars():
	n = int(input())
	cards = [int(i) for i in input().split(' ')]
	playercount = n // 2
	eachplayer = sum(cards) // playercount
	for i in range(n):
		if cards[i] != 0:
			x = cards[i]
			cards.pop(i)
			cards.insert(i, 0)
			y = cards.index(eachplayer - x)
			cards.pop(y)
			cards.insert(y, 0)
			print(i + 1, y + 1)

def suffixthree():
	t = int(input())
	for i in range(t):
		l = input().split('_')
		s = l[len(l) - 1]
		if 'po' == s[len(s) - 2:]:
			print('FILIPINO')
		elif 'desu' == s[len(s) - 4:] or 'masu' == s[len(s) - 4:]:
			print('JAPANESE')
		else:
			print('KOREAN')
suffixthree()


t = int(input())
b = ''
c = ''
while t > 0:
	t -= 1
	a = input()
	b = str(a)
	c = b[len(b) - 1]
	if 'o' in c:
		print('FILIPINO')
	elif 'u' in c:
		print('JAPANESE')
	elif 'a' in c:
		print('KOREAN')


def main():
	l = input()
	if 'po' == l[-2:]:
		print('FILIPINO')
		return
	if 'mnida' == l[-5:]:
		print('KOREAN')
		return
	elif 'desu' == l[-4:] or 'masu' == l[-4:]:
		print('JAPANESE')
tc = 1
tc = int(input())
for _ in range(tc):
	main()


for _ in range(int(input())):
	s = input()
	if len(s) >= 2:
		str_ = s[-2:]
		if str_ == 'po':
			print('FILIPINO')
			continue
	if len(s) >= 4:
		str_ = s[-4:]
		if str_ == 'desu' or str_ == 'masu':
			print('JAPANESE')
			continue
	print('KOREAN')


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


import math
import os
import random
import re
import sys

def function(s):
	if s.endswith('o'):
		print('FILIPINO')
	elif s.endswith('u'):
		print('JAPANESE')
	else:
		print('KOREAN')
m = int(input())
i = 0
while i < m:
	s = str(input())
	function(s)
	i = i + 1


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


m = int(input())
for i in range(m):
	s = input()
	if s.endswith('po'):
		print('FILIPINO')
	elif s.endswith('mnida'):
		print('KOREAN')
	elif s.endswith('desu'):
		print('JAPANESE')
	elif s.endswith('masu'):
		print('JAPANESE')


tests = int(input())
for test in range(tests):
	text = input()
	if text[-1] == 'o':
		print('FILIPINO')
	elif text[-1] == 'u':
		print('JAPANESE')
	else:
		print('KOREAN')


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


n = int(input())
words = []
for word in range(n):
	words.append(input())
language = {'a': 'KOREAN', 'u': 'JAPANESE', 'o': 'FILIPINO'}
for (idx, vals) in enumerate(words):
	if words[idx][-1] == 'a':
		print(language['a'])
	elif words[idx][-1] == 'u':
		print(language['u'])
	elif words[idx][-1] == 'o':
		print(language['o'])


T = int(input())
for _ in range(0, T):
	s = input()
	if s.endswith('po'):
		print('FILIPINO')
	if s.endswith('desu') or s.endswith('masu'):
		print('JAPANESE')
	if s.endswith('mnida'):
		print('KOREAN')


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


T = int(input())
for cas in range(T):
	str = input()
	l = len(str)
	if str[l - 2] == 'p':
		print('FILIPINO')
	elif str[l - 2] == 's':
		print('JAPANESE')
	else:
		print('KOREAN')


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


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


MyDict = {'o': 'FILIPINO', 'u': 'JAPANESE', 'a': 'KOREAN'}
print(*[MyDict[input()[-1]] for i in range(int(input()))], sep='\n')


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


suffix = ['po', 'desu', 'masu', 'mnida']
n = int(input())
for i in range(n):
	word = input().split('_')
	if word[-1].endswith('po'):
		print('FILIPINO')
	elif word[-1].endswith('masu') or word[-1].endswith('desu'):
		print('JAPANESE')
	else:
		print('KOREAN')


t = int(input())
for i in range(t):
	ch = input()
	n = len(ch)
	if ch[-1] == 'o':
		if ch[n - 2] == 'p':
			print('FILIPINO')
	elif ch[-1] == 'u':
		if ch[n - 4:n] == 'desu' or ch[n - 4:n] == 'masu':
			print('JAPANESE')
	elif ch[n - 5:n] == 'mnida':
		print('KOREAN')


x = int(input())
for i in range(x):
	st = input()
	if 'po' in st[-2:]:
		print('FILIPINO')
	elif 'desu' in st[-5:] or 'masu' in st[-5:]:
		print('JAPANESE')
	else:
		print('KOREAN')


numberOfInputs = int(input())
suffixes = ('desu', 'masu')
for i in range(0, numberOfInputs):
	inputString = input()
	if inputString.endswith(suffixes):
		print('JAPANESE')
	elif inputString.endswith('po'):
		print('FILIPINO')
	else:
		print('KOREAN')


n = int(input())
for _ in range(n):
	a = list(input())
	f = ''.join(a[-2:])
	j = ''.join(a[-4:])
	k = ''.join(a[-5:])
	if f == 'po':
		print('FILIPINO')
	elif j in ('desu', 'masu'):
		print('JAPANESE')
	else:
		print('KOREAN')


from sys import stdin
t = int(stdin.readline().rstrip())
for i in range(t):
	s = stdin.readline().rstrip()
	if s[-2:] == 'po':
		print('FILIPINO')
	elif s[-5:] == 'mnida':
		print('KOREAN')
	else:
		print('JAPANESE')


import re
T = int(input())
for _ in range(0, T):
	line = str(input())
	if re.compile('po$').search(line):
		print('FILIPINO')
	elif re.compile('desu$').search(line) or re.compile('masu$').search(line):
		print('JAPANESE')
	elif re.compile('mnida$').search(line):
		print('KOREAN')


n = int(input())
for _ in range(n):
	s = input()[-5:]
	for a in ['po', 'masu', 'desu', 'mnida']:
		if a in s:
			print({'po': 'FILIPINO', 'masu': 'JAPANESE', 'desu': 'JAPANESE', 'mnida': 'KOREAN'}[a])


def main():
	l = input()
	if 'po' == l[-2:]:
		print('FILIPINO')
		return
	if 'mnida' == l[-5:]:
		print('KOREAN')
		return
	else:
		print('JAPANESE')
tc = 1
tc = int(input())
for _ in range(tc):
	main()


inp = int(input())
list = []
list2 = []
for i in range(inp):
	list.append(input())
for i in range(inp):
	list2 = list[i]
	if list2.endswith('po'):
		print('FILIPINO')
	elif list2.endswith('desu') or list2.endswith('masu'):
		print('JAPANESE')
	elif list2.endswith('mnida'):
		print('KOREAN')


n = int(input())
x = []
for i in range(n):
	sb = input()
	if sb.lower().endswith('mnida'):
		x.append('KOREAN')
	elif sb.lower().endswith('desu') or sb.lower().endswith('masu'):
		x.append('JAPANESE')
	else:
		x.append('FILIPINO')
[print(i) for i in x]


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


y = []
for c in range(int(input())):
	y.append(input().split('_')[-1])
for c in y:
	if c[-1] == 'o':
		print('FILIPINO')
	if c[-1] == 'a':
		print('KOREAN')
	if c[-1] == 'u':
		print('JAPANESE')


n = int(input())
l = [input() for i in range(n)]
lang = {'po': 'FILIPINO', 'desu': 'JAPANESE', 'masu': 'JAPANESE', 'mnida': 'KOREAN'}
for s in l:
	for k in lang.keys():
		pos = s.find(k)
		if pos != -1 and s[-len(k):] == k:
			print(lang[k])


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


test_cases = int(input())
for i in range(test_cases):
	sent = input()
	output = ''
	if sent.endswith('po'):
		output = 'FILIPINO'
	if sent.endswith('desu'):
		output = 'JAPANESE'
	if sent.endswith('masu'):
		output = 'JAPANESE'
	if sent.endswith('mnida'):
		output = 'KOREAN'
	print(output)


n = int(input())
list = []
for i in range(1, n + 1):
	list.append(input())
final = []

def to_list(x):
	transform = []
	a = 0
	for i in str(x):
		transform.append(i)
		a += 1
	if transform[a - 1] == 'o':
		final.append('FILIPINO')
	elif transform[a - 1] == 'u':
		final.append('JAPANESE')
	elif transform[a - 1] == 'a':
		final.append('KOREAN')
for i in range(0, len(list)):
	to_list(list[i])

def output():
	for i in range(len(final)):
		print(final[i])
output()


import re
t = int(input())
l = [input() for i in range(t)]
for i in l:
	if re.search('po$', i) is not None:
		print('FILIPINO')
	elif re.search('mnida$', i) is not None:
		print('KOREAN')
	else:
		print('JAPANESE')


numberOfWords = int(input())
listofSuffix = []
for i in range(numberOfWords):
	words = input()
	if words[-2:] == 'po':
		listofSuffix.append('FILIPINO')
	elif words[-4:] == 'masu' or words[-4:] == 'desu':
		listofSuffix.append('JAPANESE')
	elif words[-5:] == 'mnida':
		listofSuffix.append('KOREAN')
print(*listofSuffix, sep='\n')


x = eval(input())
while x > 0:
	y = input()
	x -= 1
	a = len(y) - 1
	if y[a] == 'o' and y[a - 1] == 'p':
		p = 'FILIPINO'
	elif y[a] == 'u' and y[a - 1] == 's' and (y[a - 2] == 'e' and y[a - 3] == 'd' or (y[a - 2] == 'a' and y[a - 3] == 'm')):
		p = 'JAPANESE'
	elif y[a] == 'a' and y[a - 1] == 'd' and (y[a - 2] == 'i') and (y[a - 3] == 'n') and (y[a - 4] == 'm'):
		p = 'KOREAN'
	print(p)


def process():
	s = input()
	if s.endswith('po'):
		print('FILIPINO')
	if s.endswith('desu') or s.endswith('masu'):
		print('JAPANESE')
	if s.endswith('mnida'):
		print('KOREAN')
tests = int(input())
for test in range(tests):
	process()


def solve():
	st = input()
	if st.endswith('po'):
		print('FILIPINO')
	elif st.endswith('mnida'):
		print('KOREAN')
	else:
		print('JAPANESE')
test = 1
test = int(input())
for i in range(test):
	solve()


t = int(input())
for _ in range(t):
	word = input().split('_')[-1]
	if len(word) >= 5:
		if word[-5:] == 'mnida':
			print('KOREAN')
		elif word[-4:] == 'desu' or word[-4:] == 'masu':
			print('JAPANESE')
		elif word[-2:] == 'po':
			print('FILIPINO')
	elif len(word) >= 4:
		if word[-4:] == 'desu' or word[-4:] == 'masu':
			print('JAPANESE')
		elif word[-2:] == 'po':
			print('FILIPINO')
	else:
		print('FILIPINO')


def suffixThree(s):
	if s.endswith('po'):
		return 'FILIPINO'
	if s.endswith('desu') or s.endswith('masu'):
		return 'JAPANESE'
	if s.endswith('mnida'):
		return 'KOREAN'
inputs = []
n = input()
for _ in range(int(n)):
	s = input()
	inputs.append(s)
for i in range(int(n)):
	print(suffixThree(inputs[i]))


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


for _ in range(int(input())):
	a = input()
	if a[-1:-3:-1] == 'op':
		print('FILIPINO')
	elif a[-1:-5:-1] == 'used' or a[-1:-5:-1] == 'usam':
		print('JAPANESE')
	else:
		print('KOREAN')


for t in range(int(input())):
	s = input()
	if s.endswith('o'):
		print('FILIPINO')
	elif s.endswith('u'):
		print('JAPANESE')
	else:
		print('KOREAN')


t = int(input())
for i in range(t):
	n = list(map(str, input().split('_')))
	if 'a' in n[-1][-1]:
		print('KOREAN')
	elif 'u' in n[-1][-1]:
		print('JAPANESE')
	else:
		print('FILIPINO')


t = int(input())
sen = []
for i in range(1, t + 1):
	sen.append(input())
for val in sen:
	l = len(val)
	if val[l - 1] == 'o':
		print('FILIPINO')
	elif val[l - 1] == 'u':
		print('JAPANESE')
	elif val[l - 1] == 'a':
		print('KOREAN')


test_cases = int(input())
for i in range(test_cases):
	sentence = input()
	if sentence.endswith('po'):
		print('FILIPINO')
	elif sentence.endswith('desu') or sentence.endswith('masu'):
		print('JAPANESE')
	elif sentence.endswith('mnida'):
		print('KOREAN')


import re
import sys
from typing import List
lang = {'desu': 'JAPANESE', 'masu': 'JAPANESE', 'po': 'FILIPINO', 'mnida': 'KOREAN'}

def main(inp: List[str]):
	countries = []
	pat = re.compile('(desu|masu|po|mnida)$')
	for s in inp:
		countries.append(lang[pat.search(s).group(0)])
	return '\n'.join(countries)
data = [i.strip() for i in sys.stdin.readlines()[1:]]
print(main(data))


import math
from collections import *
import sys
from functools import reduce

def get_ints():
	return map(int, input().strip().split())

def get_list():
	return list(get_ints())

def get_string():
	return list(input().strip().split())

def printxsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')
DIRECTIONS = [[0, 1], [0, -1], [1, 0], [1, -1]]
NEIGHBOURS = [(i, j) for i in range(-1, 2) for j in range(-1, 2) if i != 0 or j != 0]
OrdUnicode_a = ord('a')
OrdUnicode_A = ord('A')
CAPS_ALPHABETS = {chr(i + OrdUnicode_A): i for i in range(26)}
SMOL_ALPHABETS = {chr(i + OrdUnicode_a): i for i in range(26)}
UGLYMOD = int(1000000000.0) + 7
SEXYMOD = 998244353
MAXN = int(100000.0) + 1
INFINITY = float('inf')
for _testcases_ in range(int(input())):
	S = input()
	if S.endswith('po'):
		print('FILIPINO')
	elif S.endswith('mnida'):
		print('KOREAN')
	else:
		print('JAPANESE')


for n in range(int(input())):
	string = input()
	if string.endswith('po'):
		print('FILIPINO')
	elif string.endswith('desu') or string.endswith('masu'):
		print('JAPANESE')
	elif string.endswith('mnida'):
		print('KOREAN')
exit(0)


n = int(input())
j = 0
while j < n:
	s = str(input())
	p = s[-2:]
	q = s[-4:]
	r = s[-5:]
	if p == 'po':
		print('FILIPINO')
	if q == 'desu' or q == 'masu':
		print('JAPANESE')
	if r == 'mnida':
		print('KOREAN')
	j = j + 1


m = int(input())
for i in range(m):
	n = input()
	if n.endswith('po') == True:
		print('FILIPINO')
	elif n.endswith('desu') == True or n.endswith('masu') == True:
		print('JAPANESE')
	else:
		print('KOREAN')


t = int(input())
A = [str(input()) for i in range(t)]
for i in range(t):
	s = A[i][::-1]
	if s.find('op') == 0:
		print('FILIPINO')
	if s.find('used') == 0 or s.find('usam') == 0:
		print('JAPANESE')
	if s.find('adinm') == 0:
		print('KOREAN')


n = int(input())
suffixes = {'o': 'FILIPINO', 'u': 'JAPANESE', 'a': 'KOREAN'}
for sentence in range(n):
	print(suffixes[input()[-1]])


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


for i in range(int(input())):
	x = input()
	if x.endswith('po'):
		print('FILIPINO')
	elif x.endswith('mnida'):
		print('KOREAN')
	else:
		print('JAPANESE')


for t in range(int(input())):
	l = list(input().split('_'))
	x = l[len(l) - 1]
	if 'po' == x[len(x) - 2:]:
		print('FILIPINO')
	elif 'desu' == x[len(x) - 4:] or 'masu' == x[len(x) - 4:]:
		print('JAPANESE')
	else:
		print('KOREAN')


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


for _ in range(int(input())):
	s = input()
	s1 = s[-1:-3:-1]
	if s1 == 'op':
		print('FILIPINO')
	else:
		s1 = s[-1:-5:-1]
		if s1 == 'used' or s1 == 'usam':
			print('JAPANESE')
		else:
			print('KOREAN')


t = int(input())
out = []
for i in range(t):
	s = input()
	if s[-2:] == 'po':
		out.append('FILIPINO')
	elif s[-4:] == 'desu' or s[-4:] == 'masu':
		out.append('JAPANESE')
	else:
		out.append('KOREAN')
for o in out:
	print(o)


t = int(input())
while t != 0:
	s = input()
	l = len(s)

	def helper(s, l):
		if s[l - 2:l] == 'po':
			return 'FILIPINO'
		if s[l - 4:l] == 'desu' or s[l - 4:l] == 'masu':
			return 'JAPANESE'
		else:
			return 'KOREAN'
	print(helper(s, l))
	t -= 1


n = int(input())
for i in range(n):
	s = input()
	l1 = s[len(s) - 5:]
	l2 = s[len(s) - 4:]
	if l1 == 'mnida':
		print('KOREAN')
	elif l2 == 'desu' or l2 == 'masu':
		print('JAPANESE')
	else:
		print('FILIPINO')


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


c = int(input())
inputs = []
outputs = []
for i in range(c):
	inputs.append(input())
	if inputs[i][len(inputs[i]) - 1] == 'o':
		outputs.append('FILIPINO')
	elif inputs[i][len(inputs[i]) - 1] == 'u':
		outputs.append('JAPANESE')
	elif inputs[i][len(inputs[i]) - 1] == 'a':
		outputs.append('KOREAN')
for i in range(c):
	print(outputs[i])


n = int(input())
for i in range(1, n + 1):
	str = input()
	if str[-5:] == 'mnida':
		print('KOREAN')
	elif str[-4:] == 'desu' or str[-4:] == 'masu':
		print('JAPANESE')
	else:
		print('FILIPINO')


from collections import defaultdict
T = int(input())
D = defaultdict(lambda : '')
D['po'] = 'FILIPINO'
D['desu'] = 'JAPANESE'
D['masu'] = 'JAPANESE'
D['mnida'] = 'KOREAN'
for _ in range(T):
	S = input()
	for i in [5, 4, 2]:
		if S[-i:] in D.keys():
			print(D[S[-i:]])
			break


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


T = int(input())
for _ in range(T):
	s = input()
	if s[-2] == 'p':
		print('FILIPINO')
	elif s[-2] == 's':
		print('JAPANESE')
	else:
		print('KOREAN')


n = eval(input())
y = []
for i in range(n):
	u = input()
	y.append(u)
for j in y:
	if j[-2:] == 'po':
		print('FILIPINO')
	elif j[-5:] == 'mnida':
		print('KOREAN')
	elif j[-4:] in ['desu', 'masu']:
		print('JAPANESE')


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


from sys import stdin
inp = stdin.readline
t = int(inp().strip())
while t:
	t -= 1
	s = inp().strip()
	if len(s) > 1:
		if s[-2:] == 'po':
			print('FILIPINO')
			continue
	if len(s) > 3:
		if s[-4:] == 'desu' or s[-4:] == 'masu':
			print('JAPANESE')
			continue
	if len(s) > 4:
		if s[-5:] == 'mnida':
			print('KOREAN')


dic = {'masu': 'JAPANESE', 'po': 'FILIPINO', 'mnida': 'KOREAN', 'desu': 'JAPANESE'}
temp = {'desu', 'po', 'masu', 'mnida'}
for _ in range(int(input())):
	s = input()
	t = ''
	for i in s[::-1]:
		t += i
		if t[::-1] in temp:
			print(dic[t[::-1]])
			break


import math, sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
lili = lambda : list(map(int, sys.stdin.readlines()))
li = lambda : list(map(int, input().split()))
I = lambda : int(input())
S = lambda : input().strip()
t = I()
for i in range(0, t):
	s = S()
	l = len(s) - 1
	if s[-2] + s[-1] == 'po':
		print('FILIPINO')
	elif s[l - 3:] == 'masu' or s[l - 3:] == 'desu':
		print('JAPANESE')
	else:
		print('KOREAN')


n1 = int(input(), 10)
out = [''] * n1
for i in range(n1):
	my_str = input()
	str_end = my_str[-2:]
	if str_end == 'po':
		out[i] = 'FILIPINO'
		continue
	str_end = my_str[-4:]
	if str_end == 'desu' or str_end == 'masu':
		out[i] = 'JAPANESE'
		continue
	str_end = my_str[-5:]
	if str_end == 'mnida':
		out[i] = 'KOREAN'
		continue
for i in range(n1):
	print(out[i])


def categorize(sent):
	category = ['FILIPINO', 'JAPANESE', 'KOREAN']
	check_f = sent[len(sent) - 2:]
	check_jap = sent[len(sent) - 4:]
	check_kor = sent[len(sent) - 5:]
	if 'po' in check_f:
		return category[0]
	elif 'desu' in check_jap or 'masu' in check_jap:
		return category[1]
	elif 'mnida' in check_kor:
		return category[2]
n = int(input())
inps = []
for i in range(n):
	print(categorize(input()))


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


def examA():
	T = I()
	ans = []
	d = {'po': 'FILIPINO', 'desu': 'JAPANESE', 'masu': 'JAPANESE', 'mnida': 'KOREAN'}
	for _ in range(T):
		S = SI()
		if S[-1] == 'o':
			ans.append(d['po'])
		elif S[-1] == 'u':
			ans.append(d['desu'])
		elif S[-1] == 'a':
			ans.append(d['mnida'])
	for v in ans:
		print(v)
	return

def examB():
	T = I()
	for _ in range(T):
		N = I()
	return

def examC():
	T = I()
	ans = []
	for _ in range(T):
		pass
	return

def examD():
	T = I()
	for _ in range(T):
		N = I()
	return
import sys, copy, bisect, itertools, heapq, math
from heapq import heappop, heappush, heapify
from collections import Counter, defaultdict, deque

def I():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LSI():
	return list(map(str, sys.stdin.readline().split()))

def LS():
	return sys.stdin.readline().split()

def SI():
	return sys.stdin.readline().strip()
mod = 10 ** 9 + 7
inf = float('inf')
examA()


def find(pat, txt):
	for (p, l) in zip(pat[::-1], txt):
		if p != l:
			return False
	return True
n = int(input())
cases = {'po': 'FILIPINO', 'desu': 'JAPANESE', 'masu': 'JAPANESE', 'mnida': 'KOREAN'}
for _ in range(n):
	word = input()
	word = word[::-1]
	for (pat, lang) in cases.items():
		if find(pat, word):
			print(lang)


size = int(input())
array = []
for i in range(0, size):
	name = input()
	array.append(name)
for name in array:
	if name.endswith('po'):
		print('FILIPINO')
	elif name.endswith('desu') or name.endswith('masu'):
		print('JAPANESE')
	elif name.endswith('mnida'):
		print('KOREAN')


import sys
import math
import re
import io
import queue
import bisect

def main():
	for _ in range(int(input())):
		s = input()
		if re.fullmatch('.*po', s):
			print('FILIPINO')
		elif re.fullmatch('.*desu', s):
			print('JAPANESE')
		elif re.fullmatch('.*masu', s):
			print('JAPANESE')
		elif re.fullmatch('.*mnida', s):
			print('KOREAN')
main()


a = int(input())
for i in range(a):
	s = input()
	r = s[::-1]
	if r[0:2] == 'op':
		print('FILIPINO')
	elif r[0:4] == 'used' or r[0:4] == 'usam':
		print('JAPANESE')
	else:
		print('KOREAN')


for i in range(int(input())):
	word = input()
	if word[len(word) - 2] + word[len(word) - 1] == 'po':
		print('FILIPINO')
	elif word[len(word) - 4] + word[len(word) - 3] + word[len(word) - 2] + word[len(word) - 1] == 'desu' or word[len(word) - 4] + word[len(word) - 3] + word[len(word) - 2] + word[len(word) - 1] == 'masu':
		print('JAPANESE')
	else:
		print('KOREAN')


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


n = int(input())
suffixes = {'po': 'FILIPINO', 'masu': 'JAPANESE', 'desu': 'JAPANESE', 'mnida': 'KOREAN'}
for _ in range(n):
	string = input()
	if string in suffixes:
		print(suffixes[string])
	else:
		suffix = ''
		for i in range(len(string) - 1, 0, -1):
			suffix = string[i] + suffix
			if suffix in suffixes:
				print(suffixes[suffix])
				break


kl = int(input())
for kt in range(kl):
	s = str(input())
	if s[len(s) - 1] == 'o':
		print('FILIPINO')
	if s[len(s) - 1] == 'u':
		print('JAPANESE')
	if s[len(s) - 1] == 'a':
		print('KOREAN')


x = int(input())
l = []
for i in range(x):
	a = input()
	b = a[-5:]
	if b[-2:] == 'po':
		print('FILIPINO')
	elif b[-5:] == 'mnida':
		print('KOREAN')
	else:
		print('JAPANESE')


t = int(input())
while t:
	l = input()
	n = len(l)
	for i in range(n - 1, -1, -1):
		if l[i] == 'u':
			print('JAPANESE')
			break
		if l[i] == 'a':
			print('KOREAN')
			break
		else:
			print('FILIPINO')
			break
	t -= 1


from sys import stdin, stdout
n = input()
for i in range(int(n)):
	a = input()
	if a[-1] == 'o':
		print('FILIPINO')
	elif a[-1] == 'u':
		print('JAPANESE')
	else:
		print('KOREAN')


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


m = int(input())
for i in range(m):
	n = list(input())
	x = len(n)
	y = n[x - 1]
	if y == 'o':
		print('FILIPINO')
	elif y == 'u':
		print('JAPANESE')
	else:
		print('KOREAN')


hm = int(input())
for i in range(hm):
	inp = input()
	if inp.endswith('po'):
		print('FILIPINO')
	elif inp.endswith('desu') or inp.endswith('masu'):
		print('JAPANESE')
	elif inp.endswith('mnida'):
		print('KOREAN')


numwords = input()

def language(word):
	kr_test = word[len(word) - 5::1]
	jp_test = word[len(word) - 4::1]
	fp_test = word[len(word) - 2::1]
	if kr_test == 'mnida':
		return 'KOREAN'
	if jp_test == 'desu':
		return 'JAPANESE'
	if jp_test == 'masu':
		return 'JAPANESE'
	if fp_test == 'po':
		return 'FILIPINO'
	return 'Word Not Found'
for i in range(int(numwords)):
	print(language(input()))


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


cases = int(input())
for each in range(cases):
	data = str(input())
	split_data = data.split('_')
	suffix = split_data[-1][-1]
	if 'o' in suffix:
		print('FILIPINO')
	elif 'a' in suffix:
		print('KOREAN')
	else:
		print('JAPANESE')


t = int(input())
while t > 0:
	t = t - 1
	s = input()
	l = len(s)
	g = s[l - 2:l]
	if g == 'po':
		print('FILIPINO')
		continue
	n = s[l - 4:l]
	if n == 'masu':
		print('JAPANESE')
		continue
	if n == 'desu':
		print('JAPANESE')
		continue
	m = s[l - 5:l]
	if m == 'mnida':
		print('KOREAN')
		continue


def suff(l):
	for i in range(0, len(l)):
		a = l[i][-5:]
		if a[-2:] == 'po':
			print('FILIPINO')
		elif a[-4:] == 'desu' or a[-4:] == 'masu':
			print('JAPANESE')
		elif a[-5:] == 'mnida':
			print('KOREAN')
n = int(input())
l = []
for i in range(0, n):
	a = input()
	l.append(a)
	a = ''
suff(l)


n = int(input())
for i in range(n):
	k = input()
	if k[-1] == 'o':
		print('FILIPINO')
	if k[-1] == 'u':
		print('JAPANESE')
	if k[-1] == 'a':
		print('KOREAN')


n = int(input())
i = 1
while i <= n:
	i += 1
	v = input()
	v_aux = v.lower()
	if v_aux[-2:] == 'po':
		print('FILIPINO')
	elif v_aux[-4:] == 'desu' or v[-4:] == 'masu':
		print('JAPANESE')
	elif v_aux[-5:] == 'mnida':
		print('KOREAN')


for x in range(int(input())):
	inputLanguage = input()
	if inputLanguage[-1] == 'o':
		print('FILIPINO')
	elif inputLanguage[-1] == 'u':
		print('JAPANESE')
	else:
		print('KOREAN')


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
from itertools import permutations, combinations
mod = int(1000000000.0) + 7
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')
t = ip()
for _ in range(t):
	s = ips()
	n = len(s)
	if s[len(s) - 2:len(s)] == 'po':
		ans = 'FILIPINO'
	elif s[n - 4:n] == 'desu' or s[n - 4:n] == 'masu':
		ans = 'JAPANESE'
	elif s[n - 5:n] == 'mnida':
		ans = 'KOREAN'
	out(ans)


for i in range(int(input())):
	s = input()
	if s[-2] == 'p':
		print('FILIPINO')
	if s[-2] == 's':
		print('JAPANESE')
	if s[-2] == 'd':
		print('KOREAN')


n = int(input())
for i in range(n):
	s = input()
	sz = len(s)
	if sz >= 2 and s[-2:] == 'po':
		print('FILIPINO')
	elif sz >= 4 and (s[-4:] == 'desu' or s[-4:] == 'masu'):
		print('JAPANESE')
	elif sz >= 5 and s[-5:] == 'mnida':
		print('KOREAN')


t = int(input())
i = 0
tab = []
while i < t:
	a = input()
	tab.append(a)
	i = i + 1
i = 0
while i < t:
	w = tab[i]
	if w[-1] == 'o':
		print('FILIPINO')
	elif w[-1] == 'u':
		print('JAPANESE')
	elif w[-1] == 'a':
		print('KOREAN')
	i = i + 1


T = int(input())
for i in range(T):
	S = input()
	if len(S) < 3:
		print('FILIPINO')
	elif S[len(S) - 2:len(S)] == 'po':
		print('FILIPINO')
	elif S[len(S) - 4:len(S)] == 'masu' or S[len(S) - 4:len(S)] == 'desu':
		print('JAPANESE')
	else:
		print('KOREAN')


for i in range(int(input())):
	a = input()
	b = list(a)
	if b[-1] == 'o' and b[-2] == 'p':
		print('FILIPINO')
	elif b[-1] == 'u' and b[-2] == 's' and (b[-3] == 'e') and (b[-4] == 'd'):
		print('JAPANESE')
	elif b[-1] == 'u' and b[-2] == 's' and (b[-3] == 'a') and (b[-4] == 'm'):
		print('JAPANESE')
	else:
		print('KOREAN')


for tests in range(int(input())):
	s = input()
	a = len(s)
	if a < 5:
		if a == 4:
			s = s[a - 4:]
			if s == 'desu' or s == 'masu':
				print('JAPANESE')
			elif s[2:] == 'po':
				print('FILIPINO')
		else:
			print('FILIPINO')
		continue
	s = s[a - 5:]
	if s[3:] == 'po':
		print('FILIPINO')
	elif s[1:] == 'desu' or s[1:] == 'masu':
		print('JAPANESE')
	elif s == 'mnida':
		print('KOREAN')


for n in range(int(input())):
	s = input()
	a = s[len(s) - 2:]
	if a == 'po':
		print('FILIPINO')
	else:
		a = s[len(s) - 4:]
		if a == 'desu' or a == 'masu':
			print('JAPANESE')
		else:
			a = s[len(s) - 5:]
			if a == 'mnida':
				print('KOREAN')


import sys

class IoTool:
	DEBUG = 0

	def _reader_dbg():
		with open('./input.txt', 'r') as f:
			lines = f.readlines()
		for l in lines:
			yield l.strip()

	def _reader_oj():
		return iter(sys.stdin.read().split('\n'))
	reader = _reader_dbg() if DEBUG else _reader_oj()

	def read():
		return next(IoTool.reader)
input = IoTool.read

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


n = int(input())
dic = {}
dic['po'] = 'FILIPINO'
dic['desu'] = 'JAPANESE'
dic['masu'] = 'JAPANESE'
dic['mnida'] = 'KOREAN'
list_1 = []
for i in range(n):
	x = input()
	if x.rfind('po') == len(x) - 2:
		list_1.append('po')
	elif x.rfind('desu') == len(x) - 4 or x.rfind('masu') == len(x) - 4:
		list_1.append('desu')
	elif x.rfind('mnida') == len(x) - 5:
		list_1.append('mnida')
for i in range(len(list_1)):
	a = list_1[i]
	print(dic[a])


def split_char(str):
	return [char for char in str]
for i in range(int(input())):
	x = split_char(input())
	if x[len(x) - 1] == 'o':
		print('FILIPINO')
	elif x[len(x) - 1] == 'u':
		print('JAPANESE')
	else:
		print('KOREAN')


d = int(input())
for i in range(0, d):
	j = str(input())
	p = len(j)
	t = p - 1
	if j[t] == 'u':
		print('JAPANESE')
	elif j[t] == 'o':
		print('FILIPINO')
	elif j[t] == 'a':
		print('KOREAN')


t = int(input())
for i in range(t):
	s = input()
	n = len(s) - 1
	f = s[n - 1] + s[n]
	if f == 'po':
		print('FILIPINO')
	elif f == 'su' or f == 'su':
		print('JAPANESE')
	elif f == 'da':
		print('KOREAN')


for __ in range(int(input())):
	arr = [str(s) for s in input().split('_')]
	x = len(arr) - 1
	s = arr[x][len(arr[x]) - 2:]
	s1 = arr[x][len(arr[x]) - 4:]
	s2 = arr[x][len(arr[x]) - 5:]
	if s == 'po':
		print('FILIPINO')
		continue
	if s1 == 'desu' or s1 == 'masu':
		print('JAPANESE')
		continue
	if s2 == 'mnida':
		print('KOREAN')
		continue


def get_string_input():
	return input()

def get_int_input():
	return int(input())

def main():
	t = get_int_input()
	sentence_list = []
	for i in range(t):
		sentence_list.append(get_string_input())
	for sentence in sentence_list:
		if sentence.endswith('po'):
			print('FILIPINO')
		elif sentence.endswith('desu') or sentence.endswith('masu'):
			print('JAPANESE')
		elif sentence.endswith('mnida'):
			print('KOREAN')
		else:
			print('Something weird happened')
main()


t = int(input())
fl = [['po'], 'FILIPINO']
jp = [['desu', 'masu'], 'JAPANESE']
kr = [['mnida'], 'KOREAN']
result = str()
for x in range(t):
	text = input()
	if text[-len(fl[0][0]):] == fl[0][0]:
		result = f'{result}{fl[1]}\n'
	elif text[-len(jp[0][0]):] == jp[0][0] or text[-len(jp[0][1]):] == jp[0][1]:
		result = f'{result}{jp[1]}\n'
	elif text[-len(kr[0][0]):] == kr[0][0]:
		result = f'{result}{kr[1]}\n'
else:
	result = result.strip()
print(result)


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


t = int(input())
r = []
for i in range(t):
	s = str(input())
	s = s[-1]
	if s == 'o':
		r.append('FILIPINO')
	elif s == 'u':
		r.append('JAPANESE')
	elif s == 'a':
		r.append('KOREAN')
for i in range(0, t):
	print(r[i])


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


n = int(input())
for i in range(n):
	word = input()
	if word.find('po') != -1 and word.find('po') > word.find('desu') and (word.find('po') > word.find('masu')) and (word.find('po') > word.find('mnida')):
		print('FILIPINO')
	if word.find('desu') != -1 and word.find('desu') > word.find('po') and (word.find('desu') > word.find('masu')) and (word.find('desu') > word.find('mnida')):
		print('JAPANESE')
	if word.find('masu') != -1 and word.find('masu') > word.find('po') and (word.find('masu') > word.find('desu')) and (word.find('masu') > word.find('mnida')):
		print('JAPANESE')
	if word.find('mnida') != -1 and word.find('mnida') > word.find('po') and (word.find('mnida') > word.find('desu')) and (word.find('mnida') > word.find('masu')):
		print('KOREAN')


term = int(input())
i = 0
name = []
while i < term:
	name.append(input())
	i += 1
i = 0
while i < term:
	word = str(name[i])
	length = len(name[i])
	word = name[i]
	new = word[::-1]
	last_part = new[0:2:1]
	last = last_part[::-1]
	if last == 'po':
		print('FILIPINO')
	last_part = new[0:4:1]
	last = last_part[::-1]
	if last == 'desu':
		print('JAPANESE')
	last_part = new[0:4:1]
	last = last_part[::-1]
	if last == 'masu':
		print('JAPANESE')
	last_part = new[0:5:1]
	last = last_part[::-1]
	if last == 'mnida':
		print('KOREAN')
	i += 1


t = int(input())
while t:
	x = input()
	if x[len(x) - len('po'):] == 'po':
		print('FILIPINO')
	if x[len(x) - len('desu'):] == 'desu' or x[len(x) - len('desu'):] == 'masu':
		print('JAPANESE')
	if x[len(x) - len('mnida'):] == 'mnida':
		print('KOREAN')
	t -= 1


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


for i in range(int(input())):
	a = input()
	if a.endswith('po'):
		print('FILIPINO')
	elif a.endswith('desu'):
		print('JAPANESE')
	elif a.endswith('masu'):
		print('JAPANESE')
	else:
		print('KOREAN')


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


def func(x):
	if x[-2:] == 'po':
		return 'FILIPINO'
	elif x[-2:] == 'su':
		return 'JAPANESE'
	elif x[-2:] == 'da':
		return 'KOREAN'
y = int(input())
for i in range(y):
	x = input()
	print(func(x))


import re
for _ in range(int(input())):
	str = input()
	filipino = 'po$'
	japanese = '((desu)|(masu))$'
	if re.search(filipino, str):
		print('FILIPINO')
	elif re.search(japanese, str):
		print('JAPANESE')
	else:
		print('KOREAN')


test = int(input())
for i in range(test):
	string = input()
	if string[-2:] == 'po':
		print('FILIPINO')
	if string[-4:] == 'desu':
		print('JAPANESE')
	if string[-4:] == 'masu':
		print('JAPANESE')
	if string[-5:] == 'mnida':
		print('KOREAN')


n = int(input())

def determine(s):
	if s[-2:] == 'po':
		return 'FILIPINO'
	if s[-4:] == 'desu' or s[-4:] == 'masu':
		return 'JAPANESE'
	if s[-5:] == 'mnida':
		return 'KOREAN'
for step in range(n):
	print(determine(input()))


t = int(input())
arr = []
for i in range(t):
	arr.append(str(input()))
for i in range(t):
	if arr[i].endswith('po'):
		print('FILIPINO')
	elif arr[i].endswith('masu'):
		print('JAPANESE')
	elif arr[i].endswith('desu'):
		print('JAPANESE')
	elif arr[i].endswith('mnida'):
		print('KOREAN')


import math

def list_str(l, char):
	output_str = ''
	for i in range(len(l) - 1):
		output_str += str(l[i]) + char
	output_str += str(l[len(l) - 1])
	return output_str

def str_list(s, char):
	output_list = []
	intermediate = ''
	for i in range(len(s)):
		if s[i] != char:
			intermediate += s[i]
			if i == len(s) - 1:
				output_list.append(int(intermediate))
		elif intermediate:
			output_list.append(int(intermediate))
			intermediate = ''
	return output_list

def merge_sort(l):

	def merge(l1, l2):
		(i, j) = (0, 0)
		output_list = []
		while i < len(l1) and j < len(l2):
			if l1[i] > l2[j]:
				output_list.append(l1[i])
				i += 1
			else:
				output_list.append(l2[j])
				j += 1
		if i == len(l1):
			output_list += l2[j:]
		elif j == len(l2):
			output_list += l1[i:]
		return output_list

	def sort(l):
		if len(l) < 2:
			return l
		else:
			mid = len(l) // 2
			left = sort(l[:mid])
			right = sort(l[mid:])
			return merge(left, right)
	return sort(l)

def quicksort(l):

	def partition(l, start, end):
		i = start
		ind_pivot = end
		for j in range(start, end):
			if l[j] >= l[ind_pivot]:
				(l[j], l[i]) = (l[i], l[j])
				i += 1
		(l[ind_pivot], l[i]) = (l[i], l[ind_pivot])
		return i

	def quick_sort(l, start, end):
		if len(l) < 2:
			return l
		elif start < end:
			p = partition(l, start, end)
			quick_sort(l, start, p - 1)
			quick_sort(l, p + 1, end)
	quick_sort(l, 0, len(l) - 1)
	return l

def collector_recursive(l):
	output_list = []

	def colec(l, start, end, cl):
		if start > end:
			return cl
		else:
			cl.append(f'{l[start][1]} {l[end][1]}')
			return colec(l, start + 1, end - 1, cl)
	return colec(l, 0, len(l) - 1, output_list)

def main_function():
	output_list = []
	test_cases = range(int(input()))
	for test_case in test_cases:
		s = input()
		if s[-1] == 'o':
			rep = 'FILIPINO'
		elif s[-1] == 'a':
			rep = 'KOREAN'
		else:
			rep = 'JAPANESE'
		output_list.append(rep)
	return list_str(output_list, '\n')
print(main_function())


from math import *
from copy import *
from string import *
from random import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math

def bin1(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = k ** mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin1(mid + 1, r, k, t, b, val, ans)
		else:
			return bin1(l, mid - 1, k, t, b, val, ans)

def bin2(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = t * k ** mid + b * mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin2(l, mid - 1, k, t, b, val, ans)
		else:
			return bin2(mid + 1, r, k, t, b, val, ans)

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	l = []
	for i in range(2, n + 1):
		if prime[i]:
			l.append(i)
	return l

def bin(l, r, ll, val):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		if val >= ll[mid][0] and val <= ll[mid][1]:
			return mid
		elif val < ll[mid][0]:
			return bin(l, mid - 1, ll, val)
		else:
			return bin(mid + 1, r, ll, val)

def deci(n):
	s = ''
	while n != 0:
		if n % 2 == 0:
			n = n // 2
			s = '0' + s
		else:
			n = n // 2
			s = '1' + s
	return s

def diff(s1, s2):
	if len(s1) < len(s2):
		v = len(s1)
		while v != len(s2):
			s1 = '0' + s1
			v = v + 1
	else:
		v = len(s2)
		while v != len(s1):
			s2 = '0' + s2
			v = v + 1
	c = 0
	for i in range(len(s1)):
		if s1[i:i + 1] != s2[i:i + 1]:
			c = c + 1
	return c
from sys import stdin, stdout

def fac(a, b):
	v = a
	while a != b:
		v *= a - 1
		a = a - 1
	return v

def bino(l, r, n):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		val1 = math.log(n / mid + 1, 2)
		val2 = int(val1)
		if val1 == val2:
			return val1
		elif val1 < 1.0:
			return bino(l, mid - 1, n)
		else:
			return bino(mid + 1, r, n)

def binary(l, r, ll, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		if ll[mid] == val:
			return ll[mid]
		elif ll[mid] < val:
			ans = ll[mid]
			return binary(mid + 1, r, ll, val, ans)
		else:
			return binary(l, mid - 1, ll, val, ans)

def check(n):
	v = 1
	while n != 0:
		if n % 10 == 0 or n % 10 == 1:
			n = n // 10
		else:
			v = 0
			break
	return v
t = int(input())
for i in range(t):
	s = str(input())
	if len(s) <= 3:
		print('FILIPINO')
	elif len(s) < 5:
		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) - 2:] == 'po':
		print('FILIPINO')
	elif s[len(s) - 4:] == 'desu' or s[len(s) - 4:] == 'masu':
		print('JAPANESE')
	else:
		print('KOREAN')


from sys import stdin
for i in range(int(stdin.readline())):
	sent = stdin.readline()
	if sent.endswith('po\n'):
		print('FILIPINO')
	elif sent.endswith('desu\n') or sent.endswith('masu\n'):
		print('JAPANESE')
	elif sent.endswith('mnida\n'):
		print('KOREAN')


T = int(input())
for t in range(T):
	words = input().split('_')
	last = words[-1]
	if last[-2:] == 'po':
		print('FILIPINO')
	elif last[-4:] == 'desu' or last[-4:] == 'masu':
		print('JAPANESE')
	elif last[-5:] == 'mnida':
		print('KOREAN')


n = int(input())
I = []
for i in range(n):
	l = input()
	I.append(l)

def check(k):
	if k == 'u':
		return 'JAPANESE'
	elif k == 'o':
		return 'FILIPINO'
	else:
		return 'KOREAN'
for i in range(n):
	print(check(I[i][-1]))


t = int(input())
while t:
	k2 = ''
	sent = input()[::-1]
	dic = {'jap1': 'desu'[::-1], 'jap2': 'masu'[::-1], 'fil': 'po'[::-1], 'kor': 'mnida'[::-1]}
	for keys in dic.keys():
		try:
			k = sent.index(dic[keys])
		except ValueError as e:
			continue
		if k == 0:
			k2 = keys
	t = t - 1
	if 'jap' in k2:
		print('JAPANESE')
	if 'kor' in k2:
		print('KOREAN')
	if 'fil' in k2:
		print('FILIPINO')


t = int(input())
patt = {'po': 'FILIPINO', 'desu': 'JAPANESE', 'masu': 'JAPANESE', 'mnida': 'KOREAN'}
for _ in range(t):
	string = input()
	n = len(string)
	if string[n - 2:] == 'po':
		print(patt['po'])
	elif string[n - 4:] == 'desu' or string[n - 4:] == 'masu':
		print(patt['desu'])
	else:
		print(patt['mnida'])


input_time = int(input())
sentence = []
while input_time > 0:
	line = str(input())
	sentence.append(line)
	input_time -= 1
for word in sentence:
	if word.endswith('po'):
		print('FILIPINO')
	elif word.endswith('desu') or word.endswith('masu'):
		print('JAPANESE')
	elif word.endswith('mnida'):
		print('KOREAN')


from collections import defaultdict

def getlist():
	return list(map(int, input().split()))

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


n = int(input())
for i in range(n):
	c = input().lower()
	if c[-1] == 'u':
		print('JAPANESE')
	elif c[-1] == 'a':
		print('KOREAN')
	else:
		print('FILIPINO')


n = int(input())
o = []
for i in range(0, n):
	s = input()
	if s[len(s) - 2:len(s)] == 'po':
		o.append('FILIPINO')
	elif s[len(s) - 4:len(s)] == 'desu' or s[len(s) - 4:len(s)] == 'masu':
		o.append('JAPANESE')
	elif s[len(s) - 5:len(s)] == 'mnida':
		o.append('KOREAN')
for i in o:
	print(i)


for _ in range(int(input())):
	word = input()
	if word[-2] + word[-1] == 'po':
		print('FILIPINO')
	elif word[-4] + word[-3] + word[-2] + word[-1] in ['masu', 'desu']:
		print('JAPANESE')
	elif word[-5] + word[-4] + word[-3] + word[-2] + word[-1] == 'mnida':
		print('KOREAN')


n = input()
i = 0
while i < int(n):
	s = input()
	if s[len(s) - 1] == 'u':
		print('JAPANESE')
	elif s[len(s) - 1] == 'o':
		print('FILIPINO')
	else:
		print('KOREAN')
	i = i + 1


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


t = int(input())
for i in range(t):
	s = str(input())
	s = s[-5:]
	if s == 'mnida':
		print('KOREAN')
	else:
		s = s[-4:]
		if s == 'desu' or s == 'masu':
			print('JAPANESE')
		else:
			print('FILIPINO')


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


n = int(input())
for i in range(n):
	string = input()
	l = string[-1]
	if l == 'u':
		print('JAPANESE')
	if l == 'o':
		print('FILIPINO')
	if l == 'a':
		print('KOREAN')


n = eval(input())
a = []
for i in range(n):
	b = input()
	a.append(b)
for i in range(0, n):
	if a[i][::-1][0:2] == 'op':
		print('FILIPINO')
	elif a[i][::-1][0:4] == 'used':
		print('JAPANESE')
	elif a[i][::-1][0:4] == 'usam':
		print('JAPANESE')
	else:
		print('KOREAN')


numinput = int(input())
text_arr = []
for i in range(0, numinput):
	text = input()
	text_arr.append(text)
for i in range(0, numinput):
	if text_arr[i][len(text_arr[i]) - 2:] == 'po':
		print('FILIPINO')
	if text_arr[i][len(text_arr[i]) - 4:] == 'desu' or text_arr[i][len(text_arr[i]) - 4:] == 'masu':
		print('JAPANESE')
	if text_arr[i][len(text_arr[i]) - 5:] == 'mnida':
		print('KOREAN')


prefixes = ['po', 'desu', 'masu', 'mnida']

def eval_lang(str):
	if str[len(str) - 2:] == 'po':
		return 'FILIPINO'
	elif str[len(str) - 4:] in ['desu', 'masu']:
		return 'JAPANESE'
	elif str[len(str) - 5:] == 'mnida':
		return 'KOREAN'
num_cases = int(input())
str_list = []
for i in range(0, num_cases):
	str_list.append(input())
for i in range(0, len(str_list)):
	print(eval_lang(str_list[i]))


n = int(input())
l = []
res = []
for i in range(n):
	l.append(input())
for el in l:
	x = el[-1]
	if x == 'o':
		res.append('FILIPINO')
	elif x == 'u':
		res.append('JAPANESE')
	else:
		res.append('KOREAN')
for el in res:
	print(el)


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


n = int(input())
arr = {'po': 'FILIPINO', 'desu': 'JAPANESE', 'masu': 'JAPANESE', 'mnida': 'KOREAN'}
for i in range(n):
	w = input()
	if len(w) >= 5:
		word = w[len(w) - 5:len(w)]
	else:
		word = w
	for j in arr:
		if j in word and j[len(j) - 1] == word[len(word) - 1]:
			print(arr[j])


def main():
	string = str(input())
	if string[-2:] == 'po':
		print('FILIPINO')
	elif string[-5:] == 'mnida':
		print('KOREAN')
	else:
		print('JAPANESE')
	return

def test():
	t = int(input())
	while t:
		main()
		t -= 1
test()


t = int(input())
list = []
check = ['op', 'used', 'usam', 'adinm']
ans = []
for i in range(t):
	list.append(input())
	list[i] = list[i][::-1]
	if list[i][:2] == check[0]:
		ans.append('FILIPINO')
	elif list[i][:4] == check[1] or list[i][:4] == check[2]:
		ans.append('JAPANESE')
	elif list[i][:5] == check[3]:
		ans.append('KOREAN')
print(*ans, sep='\n')


n = int(input())
list = []
for i in range(n):
	list.append(input())
for index in list:
	temp = index[-5:-1] + index[-1]
	if 'po' in temp:
		print('FILIPINO')
	elif 'mnida' in temp:
		print('KOREAN')
	elif 'desu' or 'masu' in temp:
		print('JAPANESE')


import os
import operator
from collections import defaultdict
import sys
from io import BytesIO, IOBase
import bisect

def main():
	for _ in range(int(input())):
		st = input()
		lis = st.split('_')
		word = lis[-1]
		if word[-1] == 'o' and word[-2] == 'p':
			print('FILIPINO')
			continue
		if word[-1] == 'u' and word[-2] == 's' and (word[-3] == 'e') and (word[-4] == 'd') or (word[-1] == 'u' and word[-2] == 's' and (word[-3] == 'a') and (word[-4] == 'm')):
			print('JAPANESE')
			continue
		else:
			print('KOREAN')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
x = []
for i in range(n):
	a = input()
	x.append(a)
for j in x:
	if j[-1] == 'o' and j[-2] == 'p':
		print('FILIPINO')
	if j[-1] == 'u' and j[-2] == 's' and (j[-3] == 'a') and (j[-4] == 'm'):
		print('JAPANESE')
	if j[-1] == 'u' and j[-2] == 's' and (j[-3] == 'e') and (j[-4] == 'd'):
		print('JAPANESE')
	if j[-1] == 'a' and j[-2] == 'd' and (j[-3] == 'i') and (j[-4] == 'n') and (j[-5] == 'm'):
		print('KOREAN')
	else:
		pass


t = int(input())
for _ in range(t):
	sentence = input()
	last = len(sentence)
	if sentence[last - 1] == 'u':
		print('JAPANESE')
	elif sentence[last - 1] == 'a':
		print('KOREAN')
	else:
		print('FILIPINO')


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')


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


for _ in range(int(input())):
	string = input()
	string_ch = ''
	if string[-2] + string[-1] == 'po':
		print('FILIPINO')
	else:
		for i in range(-4, 0):
			string_ch += string[i]
		if string_ch == 'desu' or string_ch == 'masu':
			print('JAPANESE')
		else:
			print('KOREAN')


t = int(input())
while t:
	string = input()
	if string.endswith('po'):
		print('FILIPINO')
	elif string.endswith('desu') or string.endswith('masu'):
		print('JAPANESE')
	else:
		print('KOREAN')
	t -= 1


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


n = int(input())
x = n
idiomas = []
while n != 0:
	frase = input()
	if frase.endswith('po'):
		idiomas.append('FILIPINO')
	elif frase.endswith('mnida'):
		idiomas.append('KOREAN')
	else:
		idiomas.append('JAPANESE')
	n -= 1
for i in range(x):
	print(idiomas[i])


n = int(input())
list_ = []
for i in range(n):
	string_ = input()
	list_.append(string_)
a = 'po'
b = 'desu'
c = 'masu'
d = 'mnida'
for item in list_:
	slice_ = item[-5:]
	if a in slice_:
		print('FILIPINO')
	elif d in slice_:
		print('KOREAN')
	elif c or d in slice_:
		print('JAPANESE')


t = int(input())
for i in range(t):
	s = input()
	x = s[-1:-3:-1]
	if x == 'op':
		print('FILIPINO')
	elif x == 'us':
		print('JAPANESE')
	else:
		print('KOREAN')


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


def solve():
	s = input()
	switchers = {'po': 'FILIPINO', 'desu': 'JAPANESE', 'masu': 'JAPANESE', 'mnida': 'KOREAN'}
	for (k, v) in switchers.items():
		if s.endswith(k):
			return v
n = int(input())
for i in range(n):
	print(solve())


def languageProcessing():
	numberOfWords = int(input())
	words = []
	for x in range(numberOfWords):
		word = input()
		words.append(word)
	for word in words:
		if word[-2:] == 'po':
			print('FILIPINO')
		elif word[-4:] == 'desu' or word[-4:] == 'masu':
			print('JAPANESE')
		elif word[-5:] == 'mnida':
			print('KOREAN')
languageProcessing()


a = int(input())
d = []
for i in range(a):
	b = str(input())
	b = 'aaaa' + b
	if b[-2:] == 'po':
		d.append('FILIPINO')
	elif b[-4:] == 'desu' or b[-4:] == 'masu':
		d.append('JAPANESE')
	else:
		d.append('KOREAN')
for i in range(a):
	print(d[i])


def solve(s):
	if len(s) < 4:
		print('FILIPINO')
		return
	if len(s) < 5:
		if s[-1] == 'o' and s[-2] == 'p':
			print('FILIPINO')
			return
		else:
			print('JAPANESE')
			return
	elif s.startswith('po', len(s) - 2):
		print('FILIPINO')
	elif s.startswith('desu', len(s) - 4) or s.startswith('masu', len(s) - 4):
		print('JAPANESE')
	else:
		print('KOREAN')
t = int(input())
for i in range(t):
	s = input()
	solve(s)


T = int(input())
for i in range(T):
	S = str(input())
	S = S[::-1]
	if S[:2] == 'op':
		print('FILIPINO')
	if S[:4] == 'used' or S[:4] == 'usam':
		print('JAPANESE')
	if S[:5] == 'adinm':
		print('KOREAN')


n = int(input())
for i in range(0, n):
	word = input()
	a = word[-2:]
	if a == 'su':
		print('JAPANESE')
	elif a == 'po':
		print('FILIPINO')
	else:
		print('KOREAN')


t = int(input())
answers = []
for i in range(t):
	s = input()
	if s.endswith('po'):
		answers.append('FILIPINO')
	elif s.endswith('mnida'):
		answers.append('KOREAN')
	else:
		answers.append('JAPANESE')
for a in answers:
	print(a)


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')


queries = int(input(''))
answer = []
for i in range(queries):
	lang = input('')
	if lang.endswith('po'):
		answer.append('Filipino')
	elif lang.endswith('desu') or lang.endswith('masu'):
		answer.append('Japanese')
	else:
		answer.append('Korean')
for j in answer:
	print(j.upper())


t = int(input())
for _ in range(t):
	string = input()
	if string.endswith('po'):
		print('FILIPINO')
	elif string.endswith('desu') or string.endswith('masu'):
		print('JAPANESE')
	else:
		print('KOREAN')


import sys
for line in sys.stdin.read().split('\n'):
	if line[-2:] == 'po':
		sys.stdout.write('FILIPINO\n')
	elif line[-4:] == 'desu' or line[-4:] == 'masu':
		sys.stdout.write('JAPANESE\n')
	elif line[-5:] == 'mnida':
		sys.stdout.write('KOREAN\n')


l = {'o': 'FILIPINO', 'u': 'JAPANESE', 'a': 'KOREAN'}
for _ in range(int(input())):
	print(l[input()[-1]])


n = int(input())
list1 = []
s = ''
for x in range(n):
	list1.append(input())
k = int(len(list1))
for y in range(k):
	s = s + list1[y]
	l = s[::-1]
	if l[0] == 'o':
		print('FILIPINO')
	elif l[0] == 'u':
		print('JAPANESE')
	elif l[0] == 'a':
		print('KOREAN')
s = ''


import sys
Input = sys.stdin.readline
n = int(Input())
for i in range(n):
	x = input()
	if x.endswith('po'):
		print('FILIPINO')
	elif x.endswith('mnida'):
		print('KOREAN')
	else:
		print('JAPANESE')


n = int(input())
for i in range(n):
	k = str(input())
	l = len(k)
	if k[l - 2:l] == 'po':
		print('FILIPINO')
	elif k[l - 4:l] == 'desu' or k[l - 4:l] == 'masu':
		print('JAPANESE')
	else:
		print('KOREAN')


N = int(input())
for n in range(N):
	string = input()
	if string[-2:] == 'po':
		print('FILIPINO')
	if string[-4:] == 'masu' or string[-4:] == 'desu':
		print('JAPANESE')
	if string[-5:] == 'mnida':
		print('KOREAN')


import sys
from math import gcd
from heapq import heappop
from heapq import heappush
from heapq import heapify
from bisect import insort
from bisect import bisect_right
from bisect import bisect_left
from sys import stdin, stdout
from collections import defaultdict, deque
from math import log2, ceil, floor
inp = lambda : int(input())
sip = lambda : input()
mulip = lambda : map(int, input().split())
lst = lambda : list(map(int, input().split()))
slst = lambda : list(sip())
arr2d = lambda x: [[int(j) for j in input().split()] for i in range(x)]
odds = lambda l: len(list(filter(lambda x: x % 2 != 0, l)))
evens = lambda l: len(list(filter(lambda x: x % 2 == 0, l)))
mod = pow(10, 9) + 7
Judge = 0
if Judge:
	sys.stdin = open('input.in', 'r')
for _ in range(inp()):
	s = list(input())
	if s[-1] == 'o' and s[-2] == 'p':
		print('FILIPINO')
	elif s[-1] == 'u' and s[-2] == 's' and (s[-3] == 'a') and (s[-4] == 'm'):
		print('JAPANESE')
	elif s[-1] == 'u' and s[-2] == 's' and (s[-3] == 'e') and (s[-4] == 'd'):
		print('JAPANESE')
	else:
		print('KOREAN')


from math import *
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')


test_case = int(input())
for _ in range(test_case):
	sentence = input()
	if sentence.endswith('po'):
		print('FILIPINO')
	elif sentence.endswith('masu') or sentence.endswith('desu'):
		print('JAPANESE')
	else:
		print('KOREAN')


N = int(input())
for _ in range(N):
	s = list(map(str, input().split()))
	if s[-1][-2:] == 'po':
		print('FILIPINO')
	elif s[-1][-4:] == 'desu' or s[-1][-4:] == 'masu':
		print('JAPANESE')
	elif s[-1][-5:] == 'mnida':
		print('KOREAN')


suffixes = {'po': 'FILIPINO', 'desu': 'JAPANESE', 'masu': 'JAPANESE', 'mnida': 'KOREAN'}
sentences = []
for i in range(int(input())):
	sentences.append(input())
for i in range(len(sentences)):
	for (suffix, language) in suffixes.items():
		if sentences[i][-len(suffix):] == suffix:
			print(language)
			break


from string import *
b = []
for _ in range(int(input())):
	a = input()
	if a.find('po', -2) != -1:
		b.append('FILIPINO')
	if a.find('desu', -4) != -1 or a.find('masu', -4) != -1:
		b.append('JAPANESE')
	if a.find('mnida', -5) != -1:
		b.append('KOREAN')
[print(i) for i in b]


for _ in range(int(input())):
	s = input()
	if s[-1] == 'o' and s[-2] == 'p':
		print('FILIPINO')
	elif s[len(s) - 4:] == 'desu' or s[len(s) - 4:] == 'masu':
		print('JAPANESE')
	elif s[len(s) - 5:] == 'mnida':
		print('KOREAN')


def main():
	t = int(input())
	for i in range(t):
		s = input()
		suff = ''
		for c in range(len(s)):
			suff += s[-c - 1]
			if suff == 'used' or suff == 'usam':
				print('JAPANESE')
				break
			elif suff == 'adinm':
				print('KOREAN')
				break
			elif suff == 'op':
				print('FILIPINO')
				break
main()


lst = [input() for _ in [0] * int(input())]
my_dict = {'o': 'FILIPINO', 'u': 'JAPANESE', 'a': 'KOREAN'}
for i in lst:
	print(my_dict[i[-1]])


n = int(input())
for i in range(n):
	suffix_three = list(input())
	j = len(suffix_three)
	if suffix_three[j - 1] == 'u':
		print('JAPANESE')
	elif suffix_three[j - 1] == 'o':
		print('FILIPINO')
	elif suffix_three[j - 1] == 'a':
		print('KOREAN')


n = int(input())
a = []
for i in range(n):
	s = input()
	arr = []
	for c in s:
		arr.append(c)
	char = arr[len(arr) - 1]
	if char == 'o':
		a.append('FILIPINO')
	elif char == 'u':
		a.append('JAPANESE')
	elif char == 'a':
		a.append('KOREAN')
for c in a:
	print(c)


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()


a = int(input())
for i in range(a):
	n = input()
	x = len(n)
	det = n[x - 4:x]
	det2 = n[x - 2:x]
	det3 = n[x - 5:x]
	if det2 == 'po':
		print('FILIPINO')
	elif det == 'masu' or det == 'desu':
		print('JAPANESE')
	elif det3 == 'mnida':
		print('KOREAN')


import sys
import math
import itertools
import collections

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return ' '.join(map(str, arr))

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
t = ii()
for _ 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')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def main():
	t = I()
	rr = []
	for _ in range(t):
		s = S()
		t = 0
		for c in s.split('_'):
			if c[-2:] == 'po':
				t = 0
			elif c[-4:] in ['desu', 'masu']:
				t = 1
			elif c[-5:] == 'mnida':
				t = 2
		r = ['FILIPINO', 'JAPANESE', 'KOREAN']
		rr.append(r[t])
	return JA(rr, '\n')
print(main())


n = int(input())
for _ in range(n):
	a = input()
	if a[-2] + a[-1] == 'po':
		print('FILIPINO')
	elif a[-4] + a[-3] + a[-2] + a[-1] == 'desu' or a[-4] + a[-3] + a[-2] + a[-1] == 'masu':
		print('JAPANESE')
	elif a[-5] + a[-4] + a[-3] + a[-2] + a[-1] == 'mnida':
		print('KOREAN')


T = int(input().strip())
for t in range(T):
	S = str(input().strip())
	N = len(S)
	if S[N - 2:N] == 'po':
		print('FILIPINO')
	elif S[N - 4:N] == 'desu' or S[N - 4:N] == 'masu':
		print('JAPANESE')
	else:
		print('KOREAN')


x = int(input())
for i in range(x):
	string = str(input())
	result = ''
	maxNum = -1
	if string.rfind('po') >= 0:
		num = string.rfind('po')
		if maxNum < num:
			maxNum = num
			result = 'FILIPINO'
	if string.rfind('desu') >= 0:
		num = string.rfind('desu')
		if maxNum < num:
			maxNum = num
			result = 'JAPANESE'
	if string.rfind('masu') >= 0:
		num = string.rfind('masu')
		if maxNum < num:
			maxNum = num
			result = 'JAPANESE'
	if string.rfind('mnida') >= 0:
		num = string.rfind('mnida')
		if maxNum < num:
			maxNum = num
			result = 'KOREAN'
	print(result)


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


def solve(text):
	if text.endswith('po'):
		return 'FILIPINO'
	elif text.endswith('mnida'):
		return 'KOREAN'
	else:
		return 'JAPANESE'
T = int(input())
for i in range(T):
	text = input()
	y = solve(text)
	print(y)


n = int(input())
lst = []
for i in range(n):
	lst.append(input())
for i in lst:
	if i.endswith('po'):
		print('FILIPINO')
	elif i.endswith('desu') or i.endswith('masu'):
		print('JAPANESE')
	else:
		print('KOREAN')


a = input()
i = int(a)
n = 0
lst2 = []
while n < i:
	n += 1
	b = input()
	lst = b.split(' ')
	for j in b:
		lst2 += j
		x = lst2[-1]
	if x == 'o':
		print('FILIPINO')
	if x == 'u':
		print('JAPANESE')
	if x == 'a':
		print('KOREAN')


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


t = int(input())
output = []
for _ in range(t):
	x = input()
	if x[-2:] == 'po':
		output.append('FILIPINO')
	elif x[-4:] == 'desu' or x[-4:] == 'masu':
		output.append('JAPANESE')
	elif x[-5:] == 'mnida':
		output.append('KOREAN')
for x in output:
	print(x)


num = int(input())
for i in range(0, num):
	p = input()
	pn = len(p) - 1
	if p[pn] == 'o':
		print('FILIPINO')
	elif p[pn] == 'u':
		print('JAPANESE')
	else:
		print('KOREAN')


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


country = {'o': 'FILIPINO', 'u': 'JAPANESE', 'a': 'KOREAN'}
t = int(input())
for _ in range(t):
	s = input()
	print(country.get(s[len(s) - 1]))


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from collections import defaultdict as dd
(t,) = I()
while t:
	t -= 1
	s = input()
	if s[-2:] == 'po':
		print('FILIPINO')
	elif s[-4:] in ['desu', 'masu']:
		print('JAPANESE')
	else:
		print('KOREAN')


test_n = int(input())
while test_n > 0:
	sentence = input().strip()
	end_char = sentence[-1]
	if end_char == 'o':
		print('FILIPINO')
	elif end_char == 'u':
		print('JAPANESE')
	elif end_char == 'a':
		print('KOREAN')
	test_n -= 1


def print_sol(s):
	l = s.split('_')
	ls = list(l[-1])
	lw = ''.join(ls[-2:])
	if lw == 'po':
		print('FILIPINO')
	elif lw == 'su':
		print('JAPANESE')
	else:
		print('KOREAN')

def main():
	t = int(input())
	for _ in range(t):
		print_sol(input())
main()


queries = int(input())
for query in range(queries):
	q = input()
	if q[-2::1] == 'po':
		print('FILIPINO')
	elif q[-4::1] == 'desu' or q[-4::1] == 'masu':
		print('JAPANESE')
	elif q[-5::1] == 'mnida':
		print('KOREAN')


import sys
t = int(input())
result = []
for i in range(t):
	s = input()
	if s.endswith('po'):
		result.append('FILIPINO')
	elif s.endswith('mnida'):
		result.append('KOREAN')
	else:
		result.append('JAPANESE')
for s in result:
	print(s)


import sys
t = int(sys.stdin.readline())
for l in map(str.rstrip, sys.stdin):
	if l.endswith('po'):
		print('FILIPINO')
	elif l.endswith('desu') or l.endswith('masu'):
		print('JAPANESE')
	else:
		print('KOREAN')


from sys import stdin

def main():
	input = lambda : stdin.readline()[:-1]
	T = int(input())
	for _ in [0] * T:
		S = input()
		s = S[::-1]
		if s[:5] == 'adinm':
			print('KOREAN')
		elif s[:4] in ('used', 'usam'):
			print('JAPANESE')
		elif s[:2] == 'op':
			print('FILIPINO')
main()


for i in range(int(input())):
	arr = ['po', 'desu', 'masu', 'mnida']
	p = []
	string = input()
	p.append(string[-2:])
	p.append(string[-4:])
	p.append(string[-5:])
	for k in range(3):
		if p[k] in arr:
			z = k
			break
	if z == 0:
		print('FILIPINO')
	elif z == 1:
		print('JAPANESE')
	elif z == 2:
		print('KOREAN')


cases = int(input())
for i in range(0, cases):
	s = input()
	if s[len(s) - 2:len(s)] == 'po':
		print('FILIPINO')
	if s[len(s) - 4:len(s)] == 'desu':
		print('JAPANESE')
	if s[len(s) - 4:len(s)] == 'masu':
		print('JAPANESE')
	if s[len(s) - 5:len(s)] == 'mnida':
		print('KOREAN')


I = lambda : int(input())
ID = lambda : map(int, input().split())
IL = lambda : list(ID())
t = I()
for _ in range(t):
	a = list(input())
	if a[-1] == 'o':
		print('FILIPINO')
	elif a[-1] == 'u':
		print('JAPANESE')
	else:
		print('KOREAN')


case = int(input())
for i in range(case):
	string = input()[::-1]
	if string[0:2] == 'op':
		print('FILIPINO')
	elif string[0:2] == 'us':
		print('JAPANESE')
	else:
		print('KOREAN')


n = int(input())
suffix = {'po': 'FILIPINO', 'desu': 'JAPANESE', 'masu': 'JAPANESE', 'mnida': 'KOREAN'}
for i in range(n):
	word = input().split('_')
	j = word[-1]
	if j[-2:] == 'po':
		print(suffix['po'])
	if j[-4:] == 'desu' or j[-4:] == 'masu':
		print(suffix['desu'])
	if j[-5:] == 'mnida':
		print(suffix['mnida'])


from sys import stdin, setrecursionlimit
import threading
setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 26)

def iin():
	return int(stdin.readline())

def lin():
	return list(map(int, stdin.readline().split()))

def main():
	t = iin()
	ans = {'po': 'FILIPINO', 'desu': 'JAPANESE', 'masu': 'JAPANESE', 'mnida': 'KOREAN'}
	while t:
		t -= 1
		s = input().split('_')
		s = s[-1]
		if s[-2:] in ans:
			print(ans[s[-2:]])
		elif s[-4:] in ans:
			print(ans[s[-4:]])
		else:
			print(ans[s[-5:]])
main()


n = int(input())
while n > 0:
	a = input()
	b = []
	for i in a:
		b.append(i)
	if b[-1] == 'o':
		print('FILIPINO')
	elif b[-1] == 'u':
		print('JAPANESE')
	elif b[-1] == 'a':
		print('KOREAN')
	n = n - 1


x = int(input())
for i in range(x):
	y = input()
	if y.endswith('po'):
		print('Filipino'.upper())
	if y.endswith('desu') or y.endswith('masu'):
		print('Japanese'.upper())
	if y.endswith('mnida'):
		print('Korean'.upper())


n = int(input())
while n:
	a = input()
	if a.endswith('po'):
		print('FILIPINO')
	elif a.endswith('desu') or a.endswith('masu'):
		print('JAPANESE')
	else:
		print('KOREAN')
	n -= 1


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


T = int(input(''))
for v 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')


times = int(input())
for i in range(times):
	word = input()
	if word[-2:] == 'po':
		print('FILIPINO')
	elif word[-4:] in ['desu', 'masu']:
		print('JAPANESE')
	elif word[-5:] == 'mnida':
		print('KOREAN')


t = int(input())
while t:
	t = t - 1
	n = input()
	n = list(n)
	x = n[::-1]
	if x[1] == 'p' and x[0] == 'o':
		print('FILIPINO')
	elif (x[3] == 'd' or x[3] == 'm') and (x[2] == 'e' or x[2] == 'a') and (x[1] == 's') and (x[0] == 'u'):
		print('JAPANESE')
	else:
		print('KOREAN')


import math as mt
import sys, string, bisect
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
t = I()
for _ in range(t):
	s = input().strip()
	if str(s[-2:]) == 'po':
		print('FILIPINO')
	elif s[-4:] == 'desu' or s[-4:] == 'masu':
		print('JAPANESE')
	else:
		print('KOREAN')


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


def filipino(frases):
	try:
		if frases[-2:] == 'po':
			return 1
		else:
			return 0
	except:
		return 0

def japanese(frases):
	try:
		if frases[-4:] == 'desu' or frases[-4:] == 'masu':
			return 2
		else:
			return 0
	except:
		return 0

def korean(frases):
	try:
		if frases[-5:] == 'mnida':
			return 3
		else:
			return 0
	except:
		return 0
qnt = int(input())
dic_resp = {1: 'FILIPINO', 2: 'JAPANESE', 3: 'KOREAN'}
for i in range(qnt):
	frase = input()
	resp = max(filipino(frase), japanese(frase), korean(frase))
	print(dic_resp[resp])


num = int(input())
arr = []
for i in range(num):
	arr.append(input())
for i in range(num):
	if 'po' in arr[i][-2:]:
		print('FILIPINO')
	elif 'su' in arr[i][-2:]:
		print('JAPANESE')
	else:
		print('KOREAN')


t = int(input())
D = {}
D['po'] = 'FILIPINO'
D['desu'] = 'JAPANESE'
D['masu'] = 'JAPANESE'
D['mnida'] = 'KOREAN'
for _ in range(t):
	s = input().split('_')
	t = s[-1]
	if len(t) >= 2 and t[-2:] == 'po':
		print('FILIPINO')
	elif len(t) >= 4 and (t[-4:] == 'desu' or t[-4:] == 'masu'):
		print('JAPANESE')
	else:
		print('KOREAN')


n = int(input())
while n != 0:
	n -= 1
	m = input()
	lg = len(m)
	if m[lg - 1] == 'o':
		print('FILIPINO')
	elif m[lg - 1] == 'u':
		print('JAPANESE')
	else:
		print('KOREAN')


test = int(input())
test_len = [2, 4, 5]
for i in range(test):
	suf_test = input()
	suf_len = len(suf_test)
	output = ''
	for i in test_len:
		dex = suf_len - i
		suf = suf_test[dex:]
		if 'po' in suf:
			output = 'FILIPINO'
		elif 'desu' in suf:
			output = 'JAPANESE'
		elif 'masu' in suf:
			output = 'JAPANESE'
		elif 'mnida' in suf:
			output = 'KOREAN'
	print(output)


n = int(input())
sufix1 = ('desu', 'masu')
for i in range(n):
	sir = input()
	if sir.endswith('po'):
		print('FILIPINO')
	if sir.endswith(sufix1):
		print('JAPANESE')
	if sir.endswith('mnida'):
		print('KOREAN')


t = int(input())
while t > 0:
	t = t - 1
	s = input()
	if s[-1:-3:-1] == 'op':
		print('FILIPINO')
	elif s[-1:-5:-1] == 'usam' or s[-1:-5:-1] == 'used':
		print('JAPANESE')
	else:
		print('KOREAN')


MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
from collections import *
for _ in range(ii()):
	a = si()
	b = []
	c = []
	d = []
	k = 0
	p = 0
	if len(a) < 4:
		print('FILIPINO')
	elif len(a) == 4:
		if a == 'desu' or a == 'masu':
			print('JAPANESE')
		else:
			print('FILIPINO')
	else:
		for i in range(len(a) - 5, len(a)):
			b.append(a[i])
		if ''.join(b) == 'mnida':
			print('KOREAN')
			k = k + 1
		for i in range(len(a) - 4, len(a)):
			c.append(a[i])
		if ''.join(c) == 'desu' or ''.join(c) == 'masu':
			print('JAPANESE')
			p = p + 1
		if p == 0 and k == 0:
			print('FILIPINO')


n = int(input())
ans = []
for i in range(n):
	name = list(input())
	if name[-1] == 'o':
		ans.append('FILIPINO')
	if name[-1] == 'u':
		ans.append('JAPANESE')
	if name[-1] == 'a':
		ans.append('KOREAN')
print('\n'.join(ans))


def suf(s):
	s = s[-5:]
	if s.count('po'):
		return 'FILIPINO'
	elif s.count('desu') or s.count('masu'):
		return 'JAPANESE'
	elif s.count('mnida'):
		return 'KOREAN'
n = int(input())
for i in range(n):
	s = input().strip()
	print(suf(s))


Lang = []
for i in range(int(input())):
	A = input()
	B = A[-5:]
	if 'po' in B:
		Lang.append('FILIPINO')
	elif 'desu' in B or 'masu' in B:
		Lang.append('JAPANESE')
	elif 'mnida' in B:
		Lang.append('KOREAN')
for i in Lang:
	print(i)


t = int(input())
for i in range(t):
	s = input()
	if s[-1] == 'a':
		print('KOREAN')
	elif s[-1] == 'o':
		print('FILIPINO')
	elif s[len(s) - 4:] == 'masu' or s[len(s) - 4:] == 'desu':
		print('JAPANESE')


c = int(input())
i = 0
while i < c:
	s = input()
	if s.endswith('po'):
		print('FILIPINO')
	elif s.endswith('desu') or s.endswith('masu'):
		print('JAPANESE')
	elif s.endswith('mnida'):
		print('KOREAN')
	i = i + 1


length = int(input())
for x in range(length):
	line = input()
	if line[-2:] == 'po':
		print('FILIPINO')
	elif line[-4:] == 'desu' or line[-4:] == 'masu':
		print('JAPANESE')
	elif line[-5:] == 'mnida':
		print('KOREAN')


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


x = int(input())
for i in range(x):
	v = input()
	if v[-2:] == 'po':
		print('FILIPINO')
	elif v[-4:] == 'desu' or v[-4:] == 'masu':
		print('JAPANESE')
	elif v[-5:] == 'mnida':
		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')


num = int(input())
l_ist = []
for x in range(num):
	l_ist.append(input())
for x in l_ist:
	lenght = len(x)
	if x[lenght - 2:] == 'po':
		print('FILIPINO')
	elif x[lenght - 4:] == 'desu' or x[lenght - 4:] == 'masu':
		print('JAPANESE')
	elif x[lenght - 5:] == 'mnida':
		print('KOREAN')


n = int(input())
for i in range(n):
	s = input()
	l = list()
	for i in range(len(s) - 1, len(s)):
		l.append(s[i])
	s1 = ''.join(map(str, l))
	if 'o' in s1:
		print('FILIPINO')
	elif 'u' in s1:
		print('JAPANESE')
	elif 'a' in s1:
		print('KOREAN')


t = int(input())
for val in range(t):
	s = input()
	last = s[len(s) - 1]
	if last == 'o':
		print('FILIPINO')
	elif last == 'u':
		print('JAPANESE')
	elif last == 'a':
		print('KOREAN')


number_of_strings = int(input())
strings = []
strings = [input() for idx in range(number_of_strings)]
d = {'po': 'FILIPINO', 'desu': 'JAPANESE', 'masu': 'JAPANESE', 'mnida': 'KOREAN'}
res = []
for string in strings:
	if string[-2:] in d.keys():
		res.append(d[string[-2:]])
	elif string[-4:] in d.keys():
		res.append(d[string[-4:]])
	elif string[-5:] in d.keys():
		res.append(d[string[-5:]])
for string in res:
	print(string)


t = int(input())
for i in range(t):
	s = input()
	l = len(s)
	sn = s[l - 4:l]
	snn = s[l - 5:l]
	if sn == 'desu' or sn == 'masu':
		print('JAPANESE')
	elif snn == 'mnida':
		print('KOREAN')
	else:
		print('FILIPINO')


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


def Input():
	tem = input().split()
	ans = []
	for it in tem:
		ans.append(int(it))
	return ans
from collections import Counter
T = Input()[0]
for tt in range(T):
	s = input()
	if s[-1] == 'o':
		print('FILIPINO')
	elif s[-1] == 'u':
		print('JAPANESE')
	else:
		print('KOREAN')


for _ in range(int(input())):
	s = input()
	ans = ''
	s2 = s[::-1]
	for i in s2:
		ans = i + ans
		if ans == 'po':
			print('FILIPINO')
			break
		elif ans == 'desu' or ans == 'masu':
			print('JAPANESE')
			break
		elif ans == 'mnida':
			print('KOREAN')
			break


n = int(input())
for x in range(n):
	texto = input()
	if texto[len(texto) - 2:] == 'po':
		print('FILIPINO')
	if texto[len(texto) - 4:] == 'desu' or texto[len(texto) - 4:] == 'masu':
		print('JAPANESE')
	if texto[len(texto) - 5:] == 'mnida':
		print('KOREAN')


def endswith(word, ending):
	return word[-len(ending):] == ending
T = int(input())
for case in range(1, T + 1):
	word = input()
	if endswith(word, 'po'):
		print('FILIPINO')
	elif endswith(word, 'desu') or endswith(word, 'masu'):
		print('JAPANESE')
	elif endswith(word, 'mnida'):
		print('KOREAN')


num = input()
num = eval(num)
while num > 0:
	num -= 1
	prefix = input()
	if prefix.endswith('po'):
		print('FILIPINO')
	elif prefix.endswith('mnida'):
		print('KOREAN')
	else:
		print('JAPANESE')


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


import math
import cmath
from decimal import *
from fractions import *
n = int(input())
for _ in range(n):
	s = input()
	a = len(s)
	if s[a - 2:a] == 'po':
		print('FILIPINO')
	elif s[a - 4:a] == 'desu' or s[a - 4:a] == 'masu':
		print('JAPANESE')
	else:
		print('KOREAN')


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


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


n = int(input())
ltot = []
for k in range(n):
	a = input()
	if a.endswith('po'):
		ltot.append('FILIPINO')
	elif a.endswith('desu') or a.endswith('masu'):
		ltot.append('JAPANESE')
	if a.endswith('mnida'):
		ltot.append('KOREAN')
for i in ltot:
	print(i)


l = int(input())
while l:
	s = input()
	if s[len(s) - 2:] == 'su' or s[len(s) - 2:] == 'po':
		print('JFAIPLAINPEISNEO'[s[len(s) - 2:] == 'po'::2])
	else:
		print('KOREAN')
	(l, s) = (l - 1, '')


def answer():
	a = int(input())
	while a:
		b = input()
		if b[-1] == 'o':
			print('FILIPINO')
		elif b[-1] == 'u':
			print('JAPANESE')
		else:
			print('KOREAN')
		a -= 1
answer()


t = int(input())
string = []
for i in range(t):
	s = str(input())
	if s.endswith('po'):
		print('FILIPINO')
	elif s.endswith('desu') or s.endswith('masu'):
		print('JAPANESE')
	elif s.endswith('mnida'):
		print('KOREAN')


from math import *
from collections import *
from itertools import *
from bisect import *
from heapq import *
from operator import *
from sys import *
setrecursionlimit(1000000)
d = defaultdict(lambda : 0, {})

def io():
	return map(int, input().split())

def op():
	return list(map(int, input().split()))

def o():
	return int(input())

def r(x):
	if type(x) == int:
		return range(x)
	else:
		return range(len(x))

def kl(con, x=0):
	if x == 0:
		print('Yes') if con else print('No')
	elif x == 1:
		print('yes') if con else print('no')
	elif x == 2:
		print('YES') if con else print('NO')
MOD = 1000000007
MAX = float('inf')
MIN = -float('inf')
p = input
for _ in range(o()):
	s = p()
	x = len(s)
	if x - 2 >= 0 and s[x - 2:x] == 'po':
		print('FILIPINO')
	elif x - 4 >= 0 and s[x - 4:x] in ['desu', 'masu']:
		print('JAPANESE')
	else:
		print('KOREAN')


n = int(input())
langs = {'po': 'FILIPINO', 'desu': 'JAPANESE', 'masu': 'JAPANESE', 'mnida': 'KOREAN'}
ans = []
for i in range(n):
	sentence = input().split('_')
	word = sentence[-1].lower()
	for j in range(-5, -1):
		if word[j:] in langs.keys():
			ans.append(langs[word[j:]])
			break
for w in ans:
	print(w)


import sys
import math
d = {'o': 'FILIPINO', 'u': 'JAPANESE', 'a': 'KOREAN'}
count = int(input())
for i in range(count):
	s = input()
	print(d[s[-1]])


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


cases = int(input())
for i in range(cases):
	test = str(input())
	if test.endswith('po'):
		print('FILIPINO')
	if test.endswith('desu') or test.endswith('masu'):
		print('JAPANESE')
	if test.endswith('mnida'):
		print('KOREAN')


from sys import stdin
c = int(stdin.readline())
out = []
for line in stdin:
	if line.endswith('po\n'):
		out.append('FILIPINO')
	elif line.endswith('mnida\n'):
		out.append('KOREAN')
	else:
		out.append('JAPANESE')
print('\n'.join(out))


t = int(input())
for q in range(t):
	a = list(input())
	if a[len(a) - 1] == 'o':
		print('FILIPINO')
	if a[len(a) - 1] == 'u':
		print('JAPANESE')
	if a[len(a) - 1] == 'a':
		print('KOREAN')


import sys
n = int(input())
for i in range(n):
	string = input().split('_')[-1]
	if string[-2:] == 'po':
		print('FILIPINO')
	elif string[-4:] == 'desu' or string[-4:] == 'masu':
		print('JAPANESE')
	else:
		print('KOREAN')


veces = int(input())
for cantidades in range(veces):
	nombres = input()
	if nombres[len(nombres) - 4:] == 'desu' or nombres[len(nombres) - 4:] == 'masu':
		print('JAPANESE')
	elif nombres[len(nombres) - 5:] == 'mnida':
		print('KOREAN')
	elif nombres[len(nombres) - 2:] == 'po':
		print('FILIPINO')


import sys
reader = (line.rstrip() for line in sys.stdin)
t = int(next(reader))
for _ in range(t):
	s = next(reader)
	if s[-4:] == 'desu' or s[-4:] == 'masu':
		print('JAPANESE')
	elif s[-2:] == 'po':
		print('FILIPINO')
	elif s[-5:] == 'mnida':
		print('KOREAN')


import sys, math, queue, collections
MOD = 10 ** 9 + 7
x = {'po', 'desu', 'masu', 'mnida'}
for _ in range(int(input())):
	s = input()
	if s[-2:] in x:
		print('FILIPINO')
	elif s[-4:] in x:
		print('JAPANESE')
	elif s[-5:] in x:
		print('KOREAN')
	else:
		print('UNKNOWN')


n = int(input())
langs = [['po', 'FILIPINO'], ['desu', 'JAPANESE'], ['masu', 'JAPANESE'], ['mnida', 'KOREAN']]
for i in range(n):
	s = input()
	[print(lang[1]) for lang in langs if s.endswith(lang[0])]


from sys import stdin, stdout
import bisect
import math

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

def pr(n):
	stdout.write(str(n) + '\n')

def soe(limit):
	l = [1] * (limit + 1)
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
			n = n - 1
		else:
			a = a * a
			n = n >> 1
	return r

def solve():
	s = input()
	if s.endswith('po'):
		print('FILIPINO')
	elif s.endswith('desu') or s.endswith('masu'):
		print('JAPANESE')
	else:
		print('KOREAN')
for _ in range(inp()):
	solve()


n = int(input())
for i in range(n):
	str = input()
	if str[len(str) - 2:len(str)] == 'po':
		print('Filipino'.upper())
	elif str[len(str) - 4:len(str)] == 'desu' or str[len(str) - 4:len(str)] == 'masu':
		print('Japanese'.upper())
	else:
		print('Korean'.upper())


for _ in range(int(input())):
	a = list(input())
	t = len(a)
	if a[t - 2:] == ['p', 'o']:
		print('FILIPINO')
	elif a[t - 4:] == ['d', 'e', 's', 'u'] or a[t - 4:] == ['m', 'a', 's', 'u']:
		print('JAPANESE')
	elif a[t - 5:] == ['m', 'n', 'i', 'd', 'a']:
		print('KOREAN')


def suffix(n, s):
	for i in range(0, n):
		if s.endswith('po', 0, len(s)):
			x = -1
		elif s.endswith('desu', 0, len(s)) or s.endswith('masu', 0, len(s)):
			x = 0
		else:
			x = 1
	if x == -1:
		print('FILIPINO')
	elif x == 0:
		print('JAPANESE')
	else:
		print('KOREAN')
n = int(input())
for j in range(0, n):
	s = input()
	res = suffix(n, s)


t = int(input())
l = ['FILIPINO', 'JAPANESE', 'KOREAN']
for _ in range(t):
	s = input()
	if s[-1] == 'o':
		print(l[0])
	elif s[-1] == 'u':
		print(l[1])
	elif s[-1] == 'a':
		print(l[2])


t = int(input())
for _ in range(t):
	s = input().strip()
	if len(s) >= 2 and s[-2:] == 'po':
		print('FILIPINO')
	if len(s) >= 4 and (s[-4:] == 'desu' or s[-4:] == 'masu'):
		print('JAPANESE')
	if len(s) >= 5 and s[-5:] == 'mnida':
		print('KOREAN')


def split(word):
	return [char for char in word]
t = int(input())
lst = []
temp = []
for i in range(0, t):
	tmp = input()
	lst.append(tmp)
for i in range(t):
	temp = split(lst[i])
	x = len(temp)
	if temp[x - 2] == 'p' and temp[x - 1] == 'o':
		print('FILIPINO')
	elif temp[x - 5] == 'm' and temp[x - 4] == 'n' and (temp[x - 3] == 'i') and (temp[x - 2] == 'd') and (temp[x - 1] == 'a'):
		print('KOREAN')
	else:
		print('JAPANESE')


import sys
line = sys.stdin.readline().strip()
n = int(line)
for i in range(n):
	line = sys.stdin.readline().strip()
	if line.endswith('po'):
		print('FILIPINO')
	elif line.endswith('desu'):
		print('JAPANESE')
	elif line.endswith('masu'):
		print('JAPANESE')
	elif line.endswith('mnida'):
		print('KOREAN')


n = int(input())
res = []
for i in range(0, n):
	string = input()
	if str(string).endswith('po'):
		res.append('FILIPINO')
	elif str(string).endswith('mnida'):
		res.append('KOREAN')
	else:
		res.append('JAPANESE')
for any in res:
	print(any)


t = int(input())
strings = []
for i in range(t):
	strings.append(input())
answers = []
for i in range(len(strings)):
	string = strings[i]
	length = len(string)
	string2 = ''
	string3 = ''
	string4 = ''
	if length >= 5:
		string2 = string2 + string[length - 2] + string[length - 1]
		string3 = string3 + string[length - 4] + string[length - 3] + string[length - 2] + string[length - 1]
		string4 = string4 + string[length - 5] + string[length - 4] + string[length - 3] + string[length - 2] + string[length - 1]
	elif length <= 4:
		string2 = string2 + string[length - 2] + string[length - 1]
		string3 = string3 + string[length - 4] + string[length - 3] + string[length - 2] + string[length - 1]
	elif length <= 2:
		string2 = string2 + string[length - 2] + string[length - 1]
	if string2 == 'po':
		answers.append('FILIPINO')
	elif string3 == 'desu' or string3 == 'masu':
		answers.append('JAPANESE')
	elif string4 == 'mnida':
		answers.append('KOREAN')
for i in answers:
	print(i)


a = int(input())
for i in range(0, a):
	b = input()
	if b.find('po', len(b) - 2) > -1:
		print('FILIPINO')
	elif b.find('mnida', len(b) - 5) > -1:
		print('KOREAN')
	else:
		print('JAPANESE')


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


q = int(input())
for i in range(q):
	s1 = input()
	s = s1[::-1]
	if s.startswith('op'):
		print('FILIPINO')
	elif s.startswith('used') or s.startswith('usam'):
		print('JAPANESE')
	elif s.startswith('adinm'):
		print('KOREAN')


n = int(input())
sentences = []
for i in range(0, n):
	sentences.append(input())
for i in range(0, len(sentences)):
	suffix = []
	words = sentences[i].split('_')
	word = words[len(words) - 1]
	letters = list(word)
	suffix.insert(0, letters[len(letters) - 1])
	suffix.insert(0, letters[len(letters) - 2])
	if ''.join(suffix) == 'po':
		print('FILIPINO')
	else:
		suffix.insert(0, letters[len(letters) - 3])
		suffix.insert(0, letters[len(letters) - 4])
		if ''.join(suffix) == 'desu' or ''.join(suffix) == 'masu':
			print('JAPANESE')
		else:
			print('KOREAN')


import math
n = int(input())
po = 'po'
jn1 = 'desu'
jn2 = 'masu'
ko = 'mnida'
for i in range(0, n):
	tmp = input()
	if tmp[len(tmp) - 1] == 'o':
		print('FILIPINO')
	elif tmp[len(tmp) - 1] == 'u':
		print('JAPANESE')
	elif tmp[len(tmp) - 1] == 'a':
		print('KOREAN')


n = int(input())
list1 = []
for i in range(n):
	a = input().strip().lower()
	b = a[::-1]
	if b[:2] == 'op':
		list1.append('FILIPINO')
	elif b[:4] == 'used' or b[:4] == 'usam':
		list1.append('JAPANESE')
	elif b[:5] == 'adinm':
		list1.append('KOREAN')
for j in list1:
	print(j)


t = int(input())
while t != 0:
	n = list(input())
	if n[-1] == 'u':
		print('JAPANESE')
	elif n[-1] == 'o':
		print('FILIPINO')
	else:
		print('KOREAN')
	t -= 1


n = int(input())
for i in range(n):
	str1 = input()
	a = str1[-1]
	b = str1[-2]
	if a == 'o':
		print('FILIPINO')
	elif a == 'u':
		print('JAPANESE')
	elif a == 'a':
		print('KOREAN')


def input_func():
	num_query = int(input())
	str_list = []
	for i in range(num_query):
		str_list.append(input())
	return str_list

def rev_last(string, n):
	str_list = list(string)
	rev_list_n = []
	for i in range(n):
		rev_list_n.append(str_list.pop())
	return ''.join(rev_list_n)

def check_func(str_list):
	for item in str_list:
		if rev_last(item, 2) == 'op':
			print('FILIPINO')
		elif rev_last(item, 4) == 'used' or rev_last(item, 4) == 'usam':
			print('JAPANESE')
		else:
			print('KOREAN')
str_list = input_func()
check_func(str_list)


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


t = int(input())
lst = list()
for i in range(t):
	a = input()
	lst.append(a)
for i in lst:
	if i.endswith('po'):
		print('FILIPINO')
	if i.endswith('desu') or i.endswith('masu'):
		print('JAPANESE')
	if i.endswith('mnida'):
		print('KOREAN')


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


T = int(input())
results = []
for case in range(1, T + 1):
	s = input()
	length = len(s)
	if s[length - 2:] == 'po':
		result = 'FILIPINO'
	elif s[length - 5:] == 'mnida':
		result = 'KOREAN'
	else:
		result = 'JAPANESE'
	results.append(result)
for result in results:
	print(result)


n = int(input())
for i in range(0, n):
	x = input()
	ar = []
	for j in x:
		ar.append(j)
	if ar[-1] == 'o' and ar[-2] == 'p':
		print('FILIPINO')
	elif ar[-1] == 'u' and ar[-2] == 's' and (ar[-3] == 'a') and (ar[-4] == 'm') or (ar[-1] == 'u' and ar[-2] == 's' and (ar[-3] == 'e') and (ar[-4] == 'd')):
		print('JAPANESE')
	else:
		print('KOREAN')


l = ['po', 'FILIPINO', 'su', 'JAPANESE', 'da', 'KOREAN']
for i in range(int(input())):
	print(l[l.index(input()[-2:]) + 1])


import sys
t = int(sys.stdin.readline())
for i in range(t):
	n = input()
	if n[-2:] == 'po':
		print('FILIPINO')
	elif n[-4:] == 'desu' or n[-4:] == 'masu':
		print('JAPANESE')
	elif n[-5:] == 'mnida':
		print('KOREAN')


def main():
	S = input()
	if 'po' == S[-2:]:
		print('FILIPINO')
		return
	if 'mnida' == S[-5:]:
		print('KOREAN')
		return
	elif 'desu' == S[-4:] or 'masu' == S[-4:]:
		print('JAPANESE')
t = int(input())
for _ in range(t):
	main()


t = int(input())
for i in range(t):
	s = input()
	if s[-2:-1] == 'p':
		print('FILIPINO')
	elif s[-4:-1] == 'mas':
		print('JAPANESE')
	elif s[-4:-1] == 'des':
		print('JAPANESE')
	elif s[-5:-1] == 'mnid':
		print('KOREAN')


n = int(input())
o = []
suffix2language = {'o': 'FILIPINO', 'u': 'JAPANESE', 'a': 'KOREAN'}
for i in range(n):
	sentence = input().strip()
	for (suffix, lang) in suffix2language.items():
		if sentence[-1:] == suffix:
			o.append(lang)
			break
for l in o:
	print(l)


import sys
import collections
from collections import Counter
import itertools
import math
import timeit

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
t = ii()
for _ in range(t):
	s = input()
	if s.endswith('po'):
		print('FILIPINO')
	elif s.endswith('mnida'):
		print('KOREAN')
	else:
		print('JAPANESE')


t = int(input())
arr = {'a': 'KOREAN', 'u': 'JAPANESE', 'o': 'FILIPINO'}
for i in range(t):
	k = input()
	print(arr[k[-1]])


suffices = {'po': 'FILIPINO', 'desu': 'JAPANESE', 'masu': 'JAPANESE', 'mnida': 'KOREAN'}
n = int(input())
for _ in range(n):
	s = input().split('_')
	word = s[len(s) - 1]
	for k in suffices.keys():
		lang = suffices[k]
		if len(word) >= len(k):
			w_s = word[len(word) - len(k):]
			if w_s == k:
				print(lang)
				break


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


for i in range(int(input())):
	s = input()
	r = ''
	for j in s[::-1]:
		r += j
		if r == 'op':
			print('FILIPINO')
		elif r in ['usam', 'used']:
			print('JAPANESE')
		elif r == 'adinm':
			print('KOREAN')


x = int(input())
aaa = []
co = []
for i in range(x):
	stringg = str(input()).split('_')
	aaa.append(stringg[len(stringg) - 1])
for xxx in range(x):
	co = aaa[xxx]
	if co[len(co) - 2] + co[len(co) - 1] == 'po':
		print('FILIPINO')
	elif co[len(co) - 5] + co[len(co) - 4] + co[len(co) - 3] + co[len(co) - 2] + co[len(co) - 1] == 'mnida':
		print('KOREAN')
	else:
		print('JAPANESE')


t = int(input())
(a, b, c, d) = ('po', 'desu', 'masu', 'mnida')
for _ in range(t):
	s = input()
	if s[-2:] == a:
		print('FILIPINO')
	elif s[-4:] == b or s[-4:] == c:
		print('JAPANESE')
	else:
		print('KOREAN')


for _ in range(int(input())):
	a = input()
	b = len(a)
	if b >= 5:
		if a[-2:-1] + a[-1] == 'po':
			print('FILIPINO')
		elif a[-4:-1] + a[-1] in ['desu', 'masu']:
			print('JAPANESE')
		else:
			print('KOREAN')
	elif b < 4:
		print('FILIPINO')
	elif a[-2:-1] + a[-1] == 'po':
		print('FILIPINO')
	else:
		print('JAPANESE')


suffix = {'o': 'FILIPINO', 'u': 'JAPANESE', 'a': 'KOREAN'}
test_case = int(input(''))
for i in range(test_case):
	if test_case > 30 or test_case < 1:
		break
	else:
		print(suffix[input()[-1]])


t = int(input())
last = str()
vout = str()
for i in range(t):
	vin = str(input())
	last = list(vin[len(vin) - 1])
	if last[0] == 'o':
		vout += 'FILIPINO'
	elif last[0] == 'u':
		vout += 'JAPANESE'
	elif last[0] == 'a':
		vout += 'KOREAN'
	if i + 1 < t:
		vout += '\n'
print(vout)


n = int(input())
result = []
for _ in range(n):
	s = input().split('_')
	s = s[::-1][0]
	if 'po' in s[-2:]:
		result.append('FILIPINO')
	elif 'desu' in s[-4:] or 'masu' in s[-4:]:
		result.append('JAPANESE')
	else:
		result.append('KOREAN')
for x in result:
	print(x)


n = int(input())
count = 0
l = []
while count < n:
	k = input()
	l.append(k)
	count += 1
for x in l:
	if 'po' == x[-2:]:
		print('FILIPINO')
	elif 'desu' == x[-4:] or 'masu' == x[-4:]:
		print('JAPANESE')
	else:
		print('KOREAN')


import sys
l = {'po': 'FILIPINO', 'desu': 'JAPANESE', 'masu': 'JAPANESE', 'mnida': 'KOREAN'}

def loadsuf(word, l):
	a = ''
	i = -1
	while abs(i) <= len(word):
		a = word[i] + a
		i -= 1
		if a in l:
			return a
count = 0
for line in sys.stdin:
	count += 1
	if count == 1:
		continue
	word = line.rstrip()
	suf = loadsuf(word, l)
	print(l[suf])


n = int(input())
for i in range(n):
	word = input()
	last = word[-5:]
	if 'po' in last:
		print('FILIPINO')
	if 'desu' in last or 'masu' in last:
		print('JAPANESE')
	if 'mnida' in last:
		print('KOREAN')


import math
n = int(input())
ans = []
for i in range(0, n):
	s = str(input())
	if s[-2:] == 'po':
		ans.append('FILIPINO')
	elif s[-2:] == 'su':
		ans.append('JAPANESE')
	elif s[-4:] == 'nida':
		ans.append('KOREAN')
for i in range(n):
	print(ans[i])


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


n = int(input())

def suffix(n):
	for x in range(n):
		a = input()
		if a[len(a) - 5:] == 'mnida':
			print('KOREAN')
		elif a[len(a) - 2:] == 'po':
			print('FILIPINO')
		else:
			print('JAPANESE')
suffix(n)


a = int(input())
s = [[] for k in range(a)]
for k in range(a):
	s[k] = str(input())
fil = 'po'
jap = 'desu'
jap2 = 'masu'
kor = 'mnida'

def suffchang(x):
	x = list(x)
	x.reverse()
	return x
fil = suffchang(fil)
jap = suffchang(jap)
jap2 = suffchang(jap2)
kor = suffchang(kor)
for k in range(0, len(s)):
	b = suffchang(s[k])
	if b[0] == fil[0] and b[1] == fil[1]:
		print('FILIPINO')
	elif b[0] == jap[0] and b[1] == jap[1] and (b[2] == jap[2]) and (b[3] == jap[3]):
		print('JAPANESE')
	elif b[0] == jap2[0] and b[1] == jap2[1] and (b[2] == jap2[2]) and (b[3] == jap2[3]):
		print('JAPANESE')
	elif b[0] == kor[0] and b[1] == kor[1] and (b[2] == kor[2]) and (b[3] == kor[3]) and (b[4] == kor[4]):
		print('KOREAN')


a = int(input())
for i in range(a):
	b = input()
	b = b.split('_')
	c = ''.join(b[-1])
	if c[-1] == 'o':
		print('FILIPINO')
	if c[-1] == 'u':
		print('JAPANESE')
	if c[-1] == 'a':
		print('KOREAN')


T = int(input())

def language(sentence):
	if ''.join(sentence[-2:]) == 'po':
		return 'FILIPINO'
	elif ''.join(sentence[-4:]) == 'desu' or ''.join(sentence[-4:]) == 'masu':
		return 'JAPANESE'
	elif ''.join(sentence[-5:]) == 'mnida':
		return 'KOREAN'
for case in range(T):
	print(language(list(input())))


for i in range(int(input())):
	slovo = input()
	bycvi = len(slovo)
	if slovo[bycvi - 2:] == 'po':
		print('FILIPINO')
	elif slovo[bycvi - 5:] == 'mnida':
		print('KOREAN')
	else:
		print('JAPANESE')


for i in range(int(input())):
	arr = input().split('_')[-1]
	if arr[-2:] == 'po':
		print('FILIPINO')
	elif arr[-4:] in ['desu', 'masu']:
		print('JAPANESE')
	else:
		print('KOREAN')


t = int(input())
s = ['po', 'desu', 'masu', 'mnida']
y = []
l = []
for i in range(0, t):
	s1 = str(input())
	y.append(s1.split('_'))
for i in y:
	l.append(i[-1])
for i in l:
	if s[0] in i[-2:]:
		print('FILIPINO')
	elif s[1] in i[-4:]:
		print('JAPANESE')
	elif s[2] in i[-4:]:
		print('JAPANESE')
	elif s[3] in i[-5:]:
		print('KOREAN')


n = int(input())
for a in range(n):
	l = input()
	if l.endswith('po'):
		print('FILIPINO')
	elif l.endswith('desu') or l.endswith('masu'):
		print('JAPANESE')
	else:
		print('KOREAN')


n = int(input())
for i in range(n):
	s = input()
	q1 = s[-2:]
	q2 = s[-4:]
	q3 = s[-5:]
	if q1 == 'po':
		print('FILIPINO')
	if q2 == 'desu' or q2 == 'masu':
		print('JAPANESE')
	if q3 == 'mnida':
		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')


def main():
	n = int(input())
	for i in range(n):
		c = input()
		c = c.lower()
		if c.endswith('po'):
			print('FILIPINO')
		elif c.endswith('masu') | c.endswith('desu'):
			print('JAPANESE')
		else:
			print('KOREAN')
main()


n = int(input())
for i in range(0, n):
	s = str(input())
	s1 = s.split('_')
	kp = -1
	ksd = -1
	ksm = -1
	kd = -1
	if 'po' in s1[len(s1) - 1]:
		kp = s1[len(s1) - 1].index('po')
	if 'desu' in s1[len(s1) - 1]:
		ksd = s1[len(s1) - 1].index('desu')
	if 'masu' in s1[len(s1) - 1]:
		ksm = s1[len(s1) - 1].index('masu')
	if 'mnida' in s1[len(s1) - 1]:
		kd = s1[len(s1) - 1].index('mnida')
	if kp == max(kp, ksd, ksm, kd):
		print('FILIPINO')
	elif ksd == max(kp, ksd, ksm, kd) or ksm == max(kp, ksd, ksm, kd):
		print('JAPANESE')
	elif kd == max(kp, ksd, ksm, kd):
		print('KOREAN')


n = int(input())
languages = {'po': 'FILIPINO', 'desu': 'JAPANESE', 'masu': 'JAPANESE', 'mnida': 'KOREAN'}
for i in range(n):
	t = str(input())[-6:]
	for e in languages:
		if t.endswith(e):
			print(languages[e])
			break


q = int(input(''))
i = 1
while i <= q:
	case = input('')
	if case.endswith('po'):
		print('FILIPINO')
	elif case.endswith('desu') or case.endswith('masu'):
		print('JAPANESE')
	elif case.endswith('mnida'):
		print('KOREAN')
	i += 1


def check():
	dict = {'o': 'FILIPINO', 'u': 'JAPANESE', 'a': 'KOREAN'}
	print(dict[input()[-1]])
for i in range(int(input())):
	check()


def dkwpwn(string):
	if string[len(string) - 2] == 'p':
		return 'FILIPINO'
	elif string[len(string) - 1] == 'u':
		return 'JAPANESE'
	else:
		return 'KOREAN'
T = int(input())
for _ in range(T):
	string = list(input())
	print(dkwpwn(string))


t = int(input())
l = []
i = 0
while i < t:
	s = input()
	s = s[::-1]
	if s[:2] == 'op':
		l.append('FILIPINO')
	elif s[:4] == 'used' or s[:4] == 'usam':
		l.append('JAPANESE')
	else:
		l.append('KOREAN')
	i += 1
for i in l:
	print(i)


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	n = I()
	ans = []
	for _ in range(n):
		s = S()
		if s[-2:] == 'po':
			ans.append('FILIPINO')
		elif s[-4:] == 'desu' or s[-4:] == 'masu':
			ans.append('JAPANESE')
		else:
			ans.append('KOREAN')
	for x in ans:
		print(x)
main()


import sys
input = sys.stdin.readline
t = int(input())
while t > 0:
	s = input().strip()
	if len(s) > 1 and s[-2:] == 'po':
		print('FILIPINO')
	if len(s) > 3 and s[-4:] == 'desu' or s[-4:] == 'masu':
		print('JAPANESE')
	if len(s) > 4 and s[-5:] == 'mnida':
		print('KOREAN')
	t -= 1


def s3(ar):
	for i in ar:
		if i[-2:] == 'po':
			print('FILIPINO')
		elif i[-4:] == 'desu' or i[-4:] == 'masu':
			print('JAPANESE')
		elif i[-5:] == 'mnida':
			print('KOREAN')
	return
count = int(input())
a = []
for _ in range(0, count):
	a.append(input())
s3(a)


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue

class Scanner:

	@staticmethod
	def int():
		return int(sys.stdin.readline().rstrip())

	@staticmethod
	def string():
		return sys.stdin.readline().rstrip()

	@staticmethod
	def map_int():
		return [int(x) for x in Scanner.string().split()]

	@staticmethod
	def string_list(n):
		return [input() for i in range(n)]

	@staticmethod
	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	@staticmethod
	def int_cols_list(n):
		return [int(input()) for i in range(n)]

class Math:

	@staticmethod
	def gcd(a, b):
		if b == 0:
			return a
		return Math.gcd(b, a % b)

	@staticmethod
	def lcm(a, b):
		return a * b // Math.gcd(a, b)

	@staticmethod
	def divisor(n):
		res = []
		i = 1
		for i in range(1, int(n ** 0.5) + 1):
			if n % i == 0:
				res.append(i)
				if i != n // i:
					res.append(n // i)
		return res

	@staticmethod
	def round_up(a, b):
		return -(-a // b)

	@staticmethod
	def is_prime(n):
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		d = int(n ** 0.5) + 1
		for i in range(3, d + 1, 2):
			if n % i == 0:
				return False
		return True

class PriorityQueue:

	def __init__(self, l=[]):
		self.q = l
		heapq.heapify(self.q)
		return

	def push(self, n):
		heapq.heappush(self.q, n)
		return

	def pop(self):
		return heapq.heappop(self.q)
MOD = int(1000000000.0) + 7
INF = int(1000000000000000.0)

def main():
	T = Scanner.int()
	for _ in range(T):
		S = Scanner.string()
		L = {'o': 'FILIPINO', 'u': 'JAPANESE', 'a': 'KOREAN'}
		print(L[S[-1]])
main()


n = int(input())
for i in range(n):
	list = [str(x) for x in input('').split('_')]
	for j in list[::-1]:
		if j.endswith('po'):
			print('FILIPINO')
			break
		elif j.endswith('desu') or j.endswith('masu'):
			print('JAPANESE')
			break
		elif j.endswith('mnida'):
			print('KOREAN')
			break


n = int(input())
lst = []
for _ in range(n):
	lst.append(input())
for i in lst:
	if i[len(i) - 2:] == 'po':
		print('FILIPINO')
	elif i[len(i) - 4:] == 'desu' or i[len(i) - 4:] == 'masu':
		print('JAPANESE')
	else:
		print('KOREAN')


def natlang(x):
	if x[-2:] == 'po':
		print('FILIPINO')
	if x[-4:] == 'desu':
		print('JAPANESE')
	if x[-4:] == 'masu':
		print('JAPANESE')
	if x[-5:] == 'mnida':
		print('KOREAN')
n = int(input())
for i in range(0, n):
	k = input()
	natlang(k)