play-with-string-2

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:
for _ in range(0, eval(input())):
	case=list(input())
	case2 = list(reversed(case))
	ans=True
	for x in range(1, len(case)):
		a = abs(ord(case[x])-ord(case[x-1]))
	   # print a
		b = abs(ord(case2[x])-ord(case2[x-1]))
	  #  print b
		if(a!=b):
			ans=False
			break
	if(ans):
		print("Funny")
	else:
		print("Not Funny")


if __name__=='__main__':
	T = int(input())
	for i in range(0,T):
		string = input()
		rev = string[::-1]
		flag = 1
		for i in range(1,len(string)):
			a = ord(string[i])-ord(string[i-1])
			if a < 0:
				a = a * (-1)
			b = ord(rev[i])-ord(rev[i-1])
			if b < 0:
				b = b*(-1)
			if a!=b:
				print("Not Funny")
				flag = 0
				break
		if flag ==1:
			print("Funny")


noc = eval(input())
while noc:
	noc -=1
	s = input()
	sl= len(s)
	i = 0
	ans = "Funny"
	while i < sl//2:
		ld = abs((ord(s[i])) - ord(s[i+1]))
		rd = abs((ord(s[sl - i - 1])) - ord(s[sl-i-2]))
		if ld != rd :
			ans =  "Not Funny"
			break
		i+=1
	print(ans)
	


def mod(a):
	if a>0:
		return a;
	else:
		return -a;
t=int(input());
while t!=0:
	t-=1;
	s=input();
	r=s[::-1];
	k=0;
	for i in range(1,len(s)):
		x=ord(s[i])-ord(s[i-1]);
		y=ord(r[i])-ord(r[i-1]);
		if mod(x)==mod(y):
			k+=1;
	if k==(len(s)-1):
		print("Funny")
	else:
		print("Not Funny")



list=[]
k={'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}
s=0
t=int(input(''))
for i in range(0,t):
	list.append(input(''))
for p in list:
	q=p[::-1]
	l=len(p)
	i=1
	while i<l-1:
		if abs(k[p[i]]-k[p[i-1]])==abs(k[q[i]]-k[q[i-1]]):
			i=i+1
		else:
			break
	if i==l-1:
		print('Funny')
	else:
		print('Not Funny')



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

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
n = int(input())
for _ in range(n):
	s = input()
	r = list(s)
	l = len(r)
	r.reverse()
	r = ''.join(r)
	counter = 0
	for i in range(1,l):
		if abs(ord(s[i]) - ord(s[i-1])) == abs(ord(r[i]) - ord(r[i-1])):
			counter = 0
		else:
			counter = 1
			break
	if counter == 0:
		print('Funny')
	else:
		print('Not 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")