Magical Number
Submissions: 1400   Accuracy:

17.05%

  Difficulty: Basic   Marks: 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".

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Arun Tyagi
Author: arun03


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.