Magical Number
Basic Accuracy: 17.27% Submissions: 1469 Points: 1

Jane is a very popular magician. But to perform a magic he needs the magical numbers. The magical numbers are the positive integers whose decimal representations contain the magical digits 1 and 2. For example, numbers 11, 2 are magical numbers and 7, 36 are not. But all numbers containing 1 and 2 are not magical. Jane calls a number, magical number, if the count of  magical digits in it contains the magical digits only. Help Jane to find the magical number.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains 1 line contains an integer n.


Output:
Print on the new  line "YES" if n is a magical number. Otherwise, print "NO".


Constraints:
1<=T<=100
1<=n<=1018

 

Example:
Input:
4
12003
46003
31374
300000000

Output:
YES
NO
YES
NO

Explanation:
In the first example there are 2 magic digits, 2 is magic number, so the answer is "YES".
In the second example there is no magic digit, so the answer is "NO".

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.