play-with-string

Suppose you have a string S which has length N and is indexed from 0 to N−1. String R is the reverse of the string S. The string S is funny if the condition |Si−Si−1|=|Ri−Ri−1| is true for every i from 1 to N−1.

(Note: Given a string str, stri denotes the ascii value of the ith character (0-indexed) of str. |x| denotes the absolute value of an integer x)

SAMPLE INPUT
2
acxz
bcxz

SAMPLE OUTPUT
Funny
Not Funny

Explanation

Consider the 1st testcase acxz :

c-a
=
x-z
= 2

z-x
=
a-c
= 2

Consider the 2st testcase bcxz

|c-b| != |x-z|

Source: hackerearth | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
n=int(input())
count=0

for i in range(n):
	strings=input()
	f=0
	if len(strings) <2:
		print("Not Funny")
	else:
		reverse_s=strings[::-1]
		for s in range(1,len(strings)):
			check=abs(ord(strings[s])-ord(strings[s-1]))==abs(ord(reverse_s[s])-ord(reverse_s[s-1]))
			if check!=True:
				print("Not Funny")
				f=1	
				break
		if f!=1:
			print("Funny")

	


for _ in range(eval(input())):
	s = input()
	r = s[::-1]
	flg = True
	for i in range(1, len(s)):
		if abs(ord(s[i])-ord(s[i-1]))!=abs(ord(r[i])-ord(r[i-1])):
			flg = False
			break
	if flg:
		print('Funny')
	else:
		print('Not Funny')


t=eval(input())
while t:
	t-=1
	s=input()
	r=s[::-1]
	i=1
	while i<len(s):
		x=ord(s[i])-ord(s[i-1])
		y=ord(r[i])-ord(r[i-1])
		if abs(x)==abs(y):
			i+=1
		else:
			i=len(s)+1
	if i==len(s):
		print("Funny")
	else:
		print("Not Funny")


for _ in range(eval(input())):
	x=input()
	x=list(x)
	r=x[::-1]

	for i in range(len(x)):
		x[i] = ord(x[i])
		r[i] = ord(r[i])

	
	ans=0
	for i in range(0,int(len(x)/2)+1):
		if(abs(x[i]-x[i+1])==abs(r[i]-r[i+1])):
			ans=1
		else:
			ans = 0
	if(ans):
		print("Funny")
	else:
		print("Not Funny")


inp = []
N = int(input())
for i in range(N):
	inp.append(input())
for j in inp:
	count = 0
	S = j
	R = S[::-1]
	for i in range(len(S)-1):
		if abs(ord(S[i]) - ord(S[i+1])) == abs(ord(R[i]) - ord(R[i+1])):
			count += 1
	if count == len(S)-1:
		print('Funny')
	else:
		print('Not Funny')





for _ in range(eval(input())):
	s=input()
	
	l=len(s)
	flag=0
	for i in range(l/2):
		
		if abs(ord(s[i])-ord(s[i+1])) != abs(ord(s[l-i-1])-ord(s[l-i-2])):
			flag=1
			break
	if flag==0:
		print("Funny")
	else:
		print("Not Funny")
			
		


for i in range(eval(input())):
	flag=0
	s=input()
	st=s[::-1]
	for i in range(1,len(st)):
		if abs(ord(s[i])-ord(s[i-1]))!=abs(ord(st[i])-ord(st[i-1])):
			flag+=1
			break
	if(flag):
		print("Not Funny")
	else:
		print("Funny")
		


T=eval(input())
flag=0
for i in range(T):
	s=input()
	r=s[::-1]
	for j in range(1,len(s)):
		if abs(ord(s[j])-ord(s[j-1]))!=abs(ord(r[j])-ord(r[j-1])):
			flag=0
			break
		else:
			flag=1
	if flag==1:
		print("Funny")
	else:
		print("Not Funny")



c = int(input())
for i in range(c):
	ip = input()
	l = len(ip)
	j = 0
	while j < l - 2:
		if abs(ord(ip[j]) - ord(ip[j+1])) != abs(ord(ip[l-1-j]) - ord(ip[l-1-j-1])):
			print("Not Funny")
			break	
		j = j + 1
	if j == l-2 :
		print("Funny")	
	


try :
	N = int(input())
except :
	N = 0

for x in range(0,N):
	S=input()
	R=S[::-1]
	l=len(S)
	for i in range(1,l):
		x1 = abs(ord(S[i])-ord(S[i-1]))
		x2 = abs(ord(R[i])-ord(R[i-1]))
		if x1 != x2 :
			break
	if i+1==l:
		print('Funny')
	else :
		print('Not Funny')


for tc in range(int(eval(input()))):
	s=input()
	r=s[::-1]
	for i in range(1,len(s)):
		if abs(ord(s[i])-ord(s[i-1]))!=abs(ord(r[i])-ord(r[i-1])):
			print('Not Funny')
			break
	else:
		print('Funny')


def stri(s):
	r = s[::-1]
	s = list(map(ord,list(s)))
	r = list(map(ord,list(r)))
	for i in range(1,len(s)):
		if abs(s[i]-s[i-1])!=abs(r[i]-r[i-1]):
			return "Not Funny"
	return "Funny"
	
for t in range(int(input())):
	s = input()
	print(stri(s))


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
import math
t = eval(input())
while(t > 0):
	s = input()
	r = ''.join(reversed(s))
	fun = True
	for i in range(1,len(s)):
		if not abs(ord(s[i]) - ord(s[i-1])) == abs(ord(r[i]) - ord(r[i-1])):
			fun = False
	if fun:
		print("Funny")
	else:
		print("Not Funny")
	t -= 1


import math
t=int(input())
for i in range(t):
	st=input()
	rst="".join(reversed(st))
	l=len(st)
	j=1

	while j<l:
		if abs(ord(st[j])-ord(st[j-1]))!= abs(ord(rst[j])-ord(rst[j-1])):
			print ("Not Funny");
			break
		elif j==l-1:
			print("Funny");
			
		j+=1