mirror-of-mahatma-gandhi
Source: hackerearth
Difficulty: EASY

On the way to Dandi March, Gandhijee carried a mirror with himself. When he reached Dandi, he decided to play a game with the tired people to give them some strength. At each turn of the game he pointed out a person and told him to say a number N(possibly huge) of his choice. The number was called lucky if that equals it's mirror image.

Input: 
First line contains number of test cases T. Each test case contains a single integer N.

Output: 
For each test case print "YES" if the number was lucky else print "NO" (quotes for clarity) in one line.

Constraints:
1 ≤ T ≤ 100
0 ≤ N ≤ 10^100Image for Sample Test Cases :SAMPLE INPUT
2
101
020

SAMPLE OUTPUT
YES
NO

Explanation

For 1st case, as clear from the image "101" and it's mirror image are identical. Hence, output "YES".
For 2nd case, "020" and it's mirror image are not identical. Hence output "NO".


t = int(input())
for x in range(t):
	num = input()
	flag = 0 
	for i in num:
		if int(i) == 1 or int(i) == 0 or int(i) == 8:
			flag = 0
		else:
			flag = 1
			break
	if flag == 1:
		print("NO")
	else:
		if num == num[::-1]:
		    print("YES")
		else:
			print("NO")


t = int(input())
for x in range(t):
	num = input()
	flag = 0 
	for i in num:
		if int(i) == 1 or int(i) == 0 or int(i) == 8:
			flag = 0
		else:
			flag = 1
			break
	if flag == 1:
		print("NO")
	else:
		if num == num[::-1]:
		    print("YES")
		else:
			print("NO")


T = int(input().strip())
for x in range(0,T):
	a = input().strip()
	flag = 0
	for x in a:
		if int(x) == 0 or int(x) == 1 or int(x) == 8:
			flag = 0
		else:
			flag = 1
			break
	if flag == 1:
		print("NO")
	else:
		if a == a[::-1]:
			print("YES")
		else:
			print("NO")



t = eval(input(''))
sym = ['1', '8', '0']
res = []
while t > 0:
	t -= 1
	n = list(input(''))
	if n == n[::-1]:
		r = 'YES'
		for elem in n:
			if elem not in sym:
				r = 'NO'
				break
	else:
		r = 'NO'
	res.append(r)
for elem in res:
	print(elem)


t = int(input().strip())
d0 = {}
for i in range(2, 10):
	if i==8: continue
	d0[i] = 1
for i in range(t):
	n1 = input().strip()
	flag = 1
	for num in n1:
		 if d0.get(int(num), 0):
		 	flag = 0
		 	break
 
	if flag and n1 == n1[::-1]:
		print("YES")
	else:
		print("NO")


T = eval(input())
non_identical = ['2','3','4','5','6','7','9']
res = ''
for i in range(T):
	a = input()
	check = True
	for i in a:
		if(i in non_identical):
			check = False
			break
	if(check == True) and a == a[::-1]:
		print("YES")
	else:
		print("NO")

		


listing=[]
listing2=[]
resultlisting=[]
countlisting=[]
t=int(eval(input()))
for i in range(0,t):
	x=input()
	listing.insert(i,x)
for i in range(0,t):
	count=0
	y=listing[i][::-1]
	listing2.insert(i,y)
	if (listing[i]==listing2[i]):
		for j in range(0,len(listing[i])):
			if listing[i][j]=='0' or listing[i][j]=='1' or listing[i][j]=='8':
				count+=1;
	
	if count==len(listing[i]):
		resultlisting.insert(i,"YES")
	else:
		resultlisting.insert(i,"NO")
		
for i in range(0,t):
	print((resultlisting[i]))
		
			
			


t=int(input())
while t:
	s=input()
	l=len(s)
	flag=0
	a=s[::-1]
   # print a
	for i in range (l):
		if s[i]=='1' or s[i]=='8' or s[i]=='0':
			#print s[i]
			#print a[i]
			if s[i]!=a[i]:
				flag=1
				break
		else:
			flag=1
			break
	if flag==1:
		print ("NO")
	else:
		print("YES")
	t-=1
	


#mirror images psbl are 1 8 0
lines = eval(input())
for i in range(lines):
	n=input()
	m=n.replace('1','').replace('8','').replace('0','')
	if len(m)>0:
		print("NO")
	else:
		if n == n[::-1]:
			print("YES")
		else:
			print("NO")


t = eval(input())
for i in range(t):
	N = input()
	l = 0
	is_mirror = True
	r = len(N)-1
	while(l<=r):
		if(l<r):
			if(N[l]!=N[r] or N[l] not in ['0','1','8'] or N[r] not in ['0','1','8']):
				print("NO")
				is_mirror=False
				break
			else:
				l+=1
				r-=1
		else:
			if(N[l] not in ['0','1','8']):
				print("NO")
				is_mirror=False
				break
			else:
				l+=1
				r-=1
	if(is_mirror):
		print("YES")


t = eval(input())
for i in range(t):
	N = input()
	l = 0
	is_mirror = True
	r = len(N)-1
	while(l<=r):
		if(l<r):
			if(N[l]!=N[r] or N[l] not in ['0','1','8'] or N[r] not in ['0','1','8']):
				print("NO")
				is_mirror=False
				break
			else:
				l+=1
				r-=1
		else:
			if(N[l] not in ['0','1','8']):
				print("NO")
				is_mirror=False
				break
			else:
				l+=1
				r-=1
	if(is_mirror):
		print("YES")
	


t=eval(input())
while t:
	n=input()
	if n!=n[::-1]:
		print('NO')
	elif '2' in n or '3' in n or '4' in n or '5' in n or '6' in n or '7' in n or '9' in n:
		print('NO')
	else:
		print('YES')
	t-=1
			
	


t=int(input())
for i in range(t):
	a=input()
	if(a[::-1]!=a):
		print("NO")
	elif(('2'in a)or('3'in a)or('4'in a)or('5'in a)or('6'in a)or('7'in a)or('9'in a)):
			print("NO")
	else:
		print("YES")
	
	
		


N=eval(input())
for i in range(N):
	k=input().split()
	m=list()
	for j in k[0]:
		m.append(j)
	h=['2','3','4','5','6','7','9']
	f=0
	for q in m:
		for y in h:
			if q==y:
				f=1
	if f==1:
		print('NO')
		continue
	l=list(m)
	m.reverse()
	if l==m:
		print('YES')
	else:
		print('NO')

	
		


import string
n=eval(input())
for i in range(n):
	flag=1
	a=input()
	l=len(a)
	for j in range(l):
		if a[j]!='1' and a[j]!='0' and a[j]!='8':
			flag=0
			continue
	m=l/2
	for j in range(m-1):
		if a[j]!=a[l-1-j]:
			flag=0
			continue
	if flag==1:
		print("YES")
	if flag==0:
		print("NO")


t=eval(input())
while t>0:
	t=t-1
	a=input()
	a=list(a)
	c=a.count('0')+a.count('1')+a.count('8')
	if c==len(a):
		a="".join(a)
		if a==a[::-1]:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t=eval(input())
while t>0:
	t=t-1
	a=input()
	a=list(a)
	c=a.count('0')+a.count('1')+a.count('8')
	if c==len(a):
		a="".join(a)
		if a==a[::-1]:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


def ispal(num):
	p=0
	st = str(num)
	for i in range(len(st)//2):
		if(st[i]==st[len(st)-1-i]):
			p+=1
	if(p==len(st)//2):
		return 1
	else:
		return 0

def checkval(num):
	st = str(num)
	p=0
	for i in range(len(st)//2):
		if(st[i]!='0' and st[i]!='1' and st[i]!='8'):
			p+=1
	return p

T=int(input())
for i in range(T):
	N=int(input())
	if(checkval(N)==0 and ispal(N)==1):
		print('YES')
	else:
		print('NO')
	


'''
# 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())
mirrors = {'0', '1', '8'}

for i in range(n):
	inp =  input()
	is_mirror = True
	for char in range((len(inp)/2)+1):
		if inp[char] in mirrors and inp[char] == inp[len(inp)-char - 1]:
			continue
		else:
			is_mirror = False
			break
	if is_mirror:
		print('YES')
	else:
		print('NO')


t = int(input().strip())
d0 = {}
for i in range(2, 10):
	if i==8: continue
	d0[i] = 1
for i in range(t):
	n1 = input().strip()
	flag = 1
	for num in n1:
		 if d0.get(int(num), 0):
		 	flag = 0
		 	break
 
	if flag and n1 == n1[::-1]:
		print("YES")
	else:
		print("NO")


from collections import Counter

for _ in range(int(input())):
	arr = input()
	n = len(arr)
	r_arr = arr[::-1]
	arr1 = Counter(arr)
	res = arr1['0'] + arr1['1'] + arr1['8'] 
	if res == n and arr == r_arr:
		print("YES")
	else:
		print("NO")


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

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
for _ in range(eval(input())):
	s=input()
	for i in s:
		if i!='0' and i!='1'and i!='8':
			print("NO")
			break
	else:
		if s==s[::-1]:
			print("YES")
		else:
			print("NO")


def Reverse(y):
	s=''
	for i in range(len(y),0,-1):
		s=s+y[i-1]
	if s==y:
		return True
	else:
		return False

t= input()
li='108'
b=False
for i in range(int(t)):
	x=input()
	for y in x:
		z=x
		if y in li:
			b=True
		else:
			b=False
			break
		b=Reverse(x)
	if b==True:
		print('YES')
	else:
		print('NO')



T = int(input().strip())
for x in range(0,T):
	a = input().strip()
	flag = 0
	for x in a:
		if int(x) == 0 or int(x) == 1 or int(x) == 8:
			flag = 0
		else:
			flag = 1
			break
	if flag == 1:
		print("NO")
	else:
		if a == a[::-1]:
			print("YES")
		else:
			print("NO")



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

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
T = eval(input())

for i in range(T):
	N = input()
	if N.find("2") != -1 or N.find("3") != -1 or N.find("4") != -1 or N.find("5") != -1 or N.find("6") != -1 or N.find("7") != -1 or N.find("9") != -1:
		print("NO")
	else:
		if N[::-1] == N:
			print("YES")
		else:
			print("NO")


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

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
T=int(input())
s=set(['0','1','8'])
for i in range(0,T):
	M=(input())
	N = set(str(M))
         
	if len(N)<=3:
		if N.issubset(s) and M == M[::-1]:
			print("YES")
		else:
			print("NO")
			
	else:
		print("NO")
	



e = list(str(2345679))
t = int(input())
for i in range(t):
	n = input()
	s = str(n)
	flag = True
	if s != s[::-1]:
		flag = False
	else:
		for c in e:
			if c in s:
				flag = False
	if flag:
		print("YES")
	else:
		print("NO")