play-with-string-1
Source: hackerearth
Difficulty: UNKNOWN_DIFFICULTY

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|


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



for _ in range(eval(input())):
	S=input();	R=S[::-1]; l=len(S);	flag=True;
	for i in range(1,l):
		if abs(ord(S[i])-ord(S[i-1]))!=abs(ord(R[i])-ord(R[i-1])):
			print("Not Funny");	flag=False;	break;
	if flag==True:
		print("Funny")
		
	


import math
for i in range(eval(input(""))):
	s=input("")
	r=s[::-1]
	funny=True
	for i in range(1,len(s)):
		if math.fabs(ord(s[i])-ord(s[i-1]))!=math.fabs(ord(r[i])-ord(r[i-1])):
			funny=False
	if funny==True:
		print("Funny")
	else:
		print("Not Funny")




for i in range(int(input())):
	word = input()
	rev =word[::-1]
	for i in range(1,int(len(rev))):
		rev_ord = abs(ord(rev[i]) -ord(rev[i-1]))
		word_ord= abs(ord(word[i])-ord(word[i-1]))
		if rev_ord != word_ord:
			print("Not Funny")
			break
	else:
		print("Funny")
	



c = int(input())
for i in range(c):
	i1 = input()
	l = len(i1)
	f = 0
	r = l - 1
	t = 0
	for j in range(l-1):
		if abs(ord(i1[f])-ord(i1[f+1])) != abs(ord(i1[r])-ord(i1[r-1])):
			t = 1
			#break
		f = f + 1
		r = r - 1
	if t == 0 :
		print("Funny")
	else:
		print("Not Funny")


y=eval(input())
for i in range(0,y):
	var=1
	x=input()
	length=len(x)
	y=x[::-1]
	for loop in range(1,length):
		
		
		if(abs(ord(x[loop]) - ord(x[loop-1]))==abs(ord(y[loop]) - ord(y[loop-1]))):
			var=var+1
		   
	if(var==length):
		print('Funny')
	else:
		print('Not Funny')
			
		   
		  
	
	

		  
	
	


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


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


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


T=eval(input())
for _ in range(T):
	s=input()
	r=list(reversed(s))
	#print s,r
	lasts=s[0]
	lastr=r[0]
	ok=1
	for i in range(1,len(s)):
		ns=s[i]
		nr=r[i]
		if abs(ord(nr)-ord(lastr))!=abs(ord(ns)-ord(lasts)):
			ok=0
		lasts=ns
		lastr=nr
	if ok: print("Funny")
	else: print("Not Funny")


#!/usr/bin/py
def isStrFunny(s):
	s_len = len(s)
	idx = 0
	while idx < s_len//2:
		left_diff = abs(ord(s[idx]) - ord(s[idx+1]))
		right_diff = abs(ord(s[s_len-idx-1]) - ord(s[s_len-idx-2]))
		if left_diff != right_diff:
			return False
		idx += 1
	 
	return True
	 
 
if __name__ == '__main__':
	t = eval(input())
	for _ in range(t):
		s = input()
		if isStrFunny(s):
			print("Funny")
		else:
			print("Not Funny")


t=eval(input())
while t>0:
	m=input()
	s= m[::-1]
	#print s
	l=len(m)/2
	f=0
	i=0
	#print ord(m[1])-ord(m[0])
	while i<=l:
		if abs(ord(m[i+1])-ord(m[i]))==abs(ord(s[i+1])-ord(s[i])) :
			f=1
		else:
			f=0
			break
		i=i+1
	if f==1:
		print("Funny")
	else:
		print("Not Funny")
	t=t-1


t=eval(input())
while t>0:
	v=0
	str=input()
	rev=str[::-1]
	i=0
	j=0
	while (j<(len(rev)-1)) and (i<(len(str)-1)):
		if(abs((ord(str[i+1])-ord(str[i])))!=abs((ord(rev[j+1])-ord(rev[j])))):
			v=1
			break
		i+=1
		j+=1
	if v==0:
		print("Funny")
	else:
		print("Not Funny")
	
	t-=1


m=int(input())
for j in range(m):
	
	
	s = input()
	n = len(s)
	r=s[::-1]
	flag=0
	for i in range(1,n):
		
		x = abs(ord(s[i])-ord(s[i-1]))
		y = abs(ord(r[i])-ord(r[i-1]))
		if x != y:
			
		    flag=1;
		
	if(flag==0):
		
		print("Funny")
	else:
		
		print("Not Funny")


noc = eval(input())
while noc:
	noc-=1
	ins = input()
	rins= ins[::-1]
	invalid = False
	for x in range(1,len(ins)):
		if abs(ord(ins[x]) - ord(ins[x-1])) ==  abs(ord(rins[x]) - ord(rins[x-1])):
			continue
		else:
			invalid = True
	print("Not Funny" if invalid else "Funny")