Public submissions
Source code of every submission to this problem in this contest will be visible for everyone since 2015-11-29 19:30:00.
Problem hidden
This problem was hidden by Editorial Board member probably because it has incorrect language version or invalid test data, or description of the problem is not clear.

MNUMBER - Mono Numbers

 

Given a number, find if it is possible to convert it into a mono-number. If all the digits of a number are same, it is a mono-number.
Examples: 666, 7, 11, 55555555555555555555.
Only one operation is allowed: You can replace two adjacent digits of the number by their sum. Digit(s) that are a result of sum of two digits cannot be involed in any further operations. There is no limit on the number of operations.
Example:
123 => (1+2)3 => 33
675 => 6(7+5) => 613 
(Though this is a valid operation, it is useless as we can never get a mono-number this way as the resultant itself has two different digits)

Given a number, find if it is possible to convert it into a mono-number. If all the digits of a number are same, it is a mono-number.

Examples: 666, 7, 11, 55555555555555555555.

Only one operation is allowed: You can replace two adjacent digits of the number by their sum. Digit(s) that are a result of sum of two digits cannot be involed in any further operations. There is no limit on the number of operations.

Example:

123 => (1+2)3 => 33

675 => 6(7+5) => 613 

(Though this is a valid operation, it is useless as we can never get a mono-number this way as the resultant itself has two different digits)

 

Input

First line contains T, the number of test cases.

Next T lines contain N, the number that should be converted to a mono-number.

Output

For each test case a line:

If it is possible, output "YES", else output "NO".

Constraints

T can be as high as 1000.

N can have upto 20 digits.

Example

Input:
4
123
23232323232323
7734716752
12345678

Output:
YES
YES
YES
NO

Explanation

First test case is explained in the problem statement.

In second, all the digits can be made 5, by adding adjacent 2 and 3s.

In third, all digits can be converted to 7.


Added by:Noob
Date:2015-11-28
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 MAWK BC NCSHARP COFFEE DART FORTH GOSU JS-MONKEY JULIA KTLN OCT PROLOG PYPY3 R RACKET SQLITE SWIFT UNLAMBDA
Public source code since: 2015-11-29 19:30:00

hide comments
2016-06-21 08:02:20
What about the case 165 = 1(6+5) = 1(11) .. is it a valid input?
2015-11-29 18:16:38 Krishna Nakkeeran
My submission id is 15737037 can u please check my code?? Coz i tried many cases and mine is working fine but im still gwtting WA
2015-11-29 07:24:11 Manioz3544
Same here my solution seems to be right but WA can u check the test cases pls ..
2015-11-29 00:59:42 Vishwa


Last edit: 2015-11-29 10:12:49
2015-11-28 22:31:37 Noob
Some test cases were wrong. Corrected now and rejudged all the solutions. Regret the inconvenience caused.
2015-11-28 21:18:44 cegprakash


Last edit: 2015-11-28 21:52:19
2015-11-28 21:15:38 cegprakash


Last edit: 2015-11-28 21:20:12
2015-11-28 19:20:34 Teja surya
pls give few more test cases??
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.