Given a number N, write a program to check whether given number is Adam Number or not.
Adam number is a number when reversed, the square of the number and the square of the reversed number should be numbers which are reverse of each other.
 
Example 1: 
Input: 
N = 12
Output:
YES
Explanation:
12^{2} = 144 and 21^{2} = 441. 144 reversed 
gives 441, So, it's an Adam Number.
Example 1: 
Input: 
N = 14
Output:
NO
Explanation:
14^{2} = 196. 196 reversed gives 691,
which isn't equal to 41^{2} So,
it's not an Adam Number.
 
Your Task:
You don't need to read input or print anything. Your task is to complete the function checkAdamOrNot() which takes an Integer N as input and returns the answer as "YES" if it is a Adam, number. Otherwise, returns "NO".
 
Expected Time Complexity: O(|N|)
Expected Auxiliary Space: O(1)
 
Constraints:
1 <= N <= 10^{4}

Difficulty: EASY
Tags: Mathematics
Expected Time Complexity: O(|N|)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3



class Solution:

    def checkAdamOrNot(self, N):

        # code here 

Solutions:
class Solution:

	def checkAdamOrNot(self, N):
		(dn, rev) = (N, 0)
		while dn != 0:
			rev = rev * 10 + dn % 10
			dn = dn // 10
		(sn, srn) = (N * N, rev * rev)
		(srev, dr) = (0, srn)
		while dr != 0:
			srev = srev * 10 + dr % 10
			dr = dr // 10
		if srev == sn:
			return 'YES'
		return 'NO'


class Solution:

	def checkAdamOrNot(self, N):
		s = str(N)
		t = str(N ** 2)
		s1 = s[::-1]
		t1 = str(int(s1) ** 2)
		if t1 == t[::-1]:
			return 'YES'
		else:
			return 'NO'


class Solution:

	def checkAdamOrNot(self, N):
		s = N ** 2
		o = int(str(N)[::-1]) ** 2
		if str(s) == str(o)[::-1]:
			return 'YES'
		return 'NO'


class Solution:

	def checkAdamOrNot(self, N):
		a = N * N
		b = int(str(N)[::-1])
		c = b * b
		if str(N) == str(b)[::-1] and str(a) == str(c)[::-1]:
			return 'YES'
		else:
			return 'NO'


class Solution:

	def checkAdamOrNot(self, N):
		s = str(N)[::-1]
		num1 = N ** 2
		num2 = int(s) ** 2
		if str(num1) == str(num2)[::-1]:
			return 'YES'
		else:
			return 'NO'


class Solution:

	def checkAdamOrNot(self, N):
		ans = N ** 2
		ans1 = int(str(N)[::-1]) ** 2
		return 'YES' if str(ans) == str(ans1)[::-1] else 'NO'


class Solution:

	def checkAdamOrNot(self, N):
		a = N ** 2
		b = int(str(N)[::-1]) ** 2
		if str(a) == str(b)[::-1]:
			return 'YES'
		return 'NO'


class Solution:

	def checkAdamOrNot(self, N):
		res = N
		rev = 0
		rev1 = 0
		sq1 = N * N
		while N > 0:
			rem = N % 10
			rev = rev * 10 + rem
			N = N // 10
		sq2 = rev * rev
		tem = sq2
		while sq2 > 0:
			rem1 = sq2 % 10
			rev1 = rev1 * 10 + rem1
			sq2 = sq2 // 10
		if sq1 == rev1:
			return 'YES'
		else:
			return 'NO'


class Solution:

	def checkAdamOrNot(self, N):
		N2 = N ** 2
		a = str(N)
		b = a[::-1]
		c = int(b)
		N3 = c ** 2
		x = str(N3)
		y = x[::-1]
		if str(N2) == str(y):
			return 'YES'
		else:
			return 'NO'


class Solution:

	def checkAdamOrNot(self, N):
		x = str(N)
		y = x[::-1]
		m = str(int(x) ** 2)
		if m[::-1] == str(int(y) ** 2):
			return 'YES'
		return 'NO'


class Solution:

	def checkAdamOrNot(self, N):
		a = list(str(N))
		a.reverse()
		b = int(''.join(a))
		b = str(b ** 2)[::-1]
		if N ** 2 == int(b):
			return 'YES'
		return 'NO'


class Solution:

	def checkAdamOrNot(self, n):
		a = len(str(n))

		def reverse(n):
			k = 0
			while n > 0:
				e = n % 10
				k = k * 10 + e
				n = n // 10
			b = len(str(k))
			k = str(k)
			for i in range(a - b):
				k = '0' + k
			return k
		s1 = n * n
		s2 = reverse(n)
		s3 = int(s2) * int(s2)
		s4 = reverse(s3)
		if int(s1) == int(s4):
			return 'YES'
		else:
			return 'NO'


class Solution:

	def checkAdamOrNot(self, N):
		a = N ** 2
		b = int(str(N)[::-1])
		c = b ** 2
		d = int(str(c)[::-1])
		if a == d:
			return 'YES'
		else:
			return 'NO'
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.checkAdamOrNot(N))


class Solution:

	def checkAdamOrNot(self, N):
		a = N * N
		s = str(N)[::-1]
		b = int(s) * int(s)
		if str(a) == str(b)[::-1]:
			return 'YES'
		return 'NO'
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.checkAdamOrNot(N))


class Solution:

	def checkAdamOrNot(self, N):
		sq1 = N * N
		k = int(str(N)[::-1])
		sq2 = k * k
		if sq1 == int(str(sq2)[::-1]):
			return 'YES'
		return 'NO'
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.checkAdamOrNot(N))


class Solution:

	def checkAdamOrNot(self, N):
		s = N * N
		r = str(N)[::-1]
		p = int(r)
		k = p * p
		if str(s) == str(k)[::-1]:
			return 'YES'
		else:
			return 'NO'
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.checkAdamOrNot(N))


class Solution:

	def checkAdamOrNot(self, N):
		l = N * N
		m = str(N)
		m = m[::-1]
		r = int(m) * int(m)
		r1 = str(l)
		r1 = r1[::-1]
		if str(r) == r1:
			return 'YES'
		else:
			return 'NO'
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.checkAdamOrNot(N))


class Solution:

	def checkAdamOrNot(self, N):
		x = N * N
		y = str(N)[::-1]
		z = int(y) * int(y)
		if str(x) == str(z)[::-1]:
			return 'YES'
		return 'NO'
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.checkAdamOrNot(N))


class Solution:

	def checkAdamOrNot(self, N):
		x = N ** 2
		x1 = int(str(N)[::-1]) ** 2
		if str(x1) == str(x)[::-1]:
			return 'YES'
		else:
			return 'NO'
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.checkAdamOrNot(N))


class Solution:

	def checkAdamOrNot(self, N):
		D = N * N
		e = str(N)
		e = e[::-1]
		e = int(e)
		f = e * e
		f = str(f)
		f = f[::-1]
		f = int(f)
		if D == f:
			return 'YES'
		return 'NO'
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.checkAdamOrNot(N))


class Solution:

	def checkAdamOrNot(self, N):
		x = str(N)
		x = x[::-1]
		x = int(x)
		ans1 = N ** 2
		ans2 = x ** 2
		ans2 = str(ans2)
		ans2 = ans2[::-1]
		ans2 = int(ans2)
		if ans1 == ans2:
			return 'YES'
		else:
			return 'NO'


class Solution:

	def checkAdamOrNot(self, N):
		x = str(N ** 2)
		y = str(N)[::-1]
		z = int(y) ** 2
		z = str(z)
		if z[::-1] == x:
			return 'YES'
		else:
			return 'NO'


class Solution:

	def checkAdamOrNot(self, N):
		A = N * N
		S = str(N)[::-1]
		b = int(S) * int(S)
		if str(A) == str(b)[::-1]:
			return 'YES'
		else:
			return 'NO'


class Solution:

	def reverse(self, N):
		rev_no = 0
		while N > 0:
			rem = N % 10
			rev_no = rev_no * 10 + rem
			N //= 10
		return rev_no

	def checkAdamOrNot(self, N):
		a = N * N
		b = self.reverse(N) * self.reverse(N)
		if a == self.reverse(b):
			return 'YES'
		return 'NO'