cho.sh
Notes
Loading...

Self-Replicating Number

Time limit

2s

Memory limit

128 MB

Problem

A positive integer N is called a self-replicating number if, after squaring N, the final decimal digits of N^2 are exactly N.

For example, 5^2 = 25, and the last digit of 25 is 5, so 5 is a self-replicating number. Also, 76^2 = 5776, and the last two digits of 5776 are 76, so 76 is also a self-replicating number.

Given a positive integer N, write a program that determines whether N is a self-replicating number.

Input

The first line contains the number of test cases T (1 <= T <= 20).

Each of the next T lines contains one positive integer N (1 <= N <= 1000).

Output

For each test case, print YES if the given number is a self-replicating number, and NO otherwise.