For each of N numbers decide whether no digit repeats four times in a row and every divisor greater than 1 exceeds K.
Medium4MathNumber theoryStringBrute forceNo attempts yetTime limit1sMemory limit64 MBMr. Random supplies random numbers to the people who come to him. Producing a large amount of random numbers by hand is hard, so he decided to use a random number generator.
The generator produces a few million numbers per second. Some of the numbers it produces do not look random to Mr. Random, so he has to filter every generated number.
A number is random when it satisfies both of the following conditions.
For example, when K is 2, the numbers 1112233445, 111333555 and 111 are random. The number 122221 is not random because the digit 2 appears 4 times in a row, and 1234 is not random because 2 divides 1234 and 2 is not greater than K.
The number 1 has no divisor other than 1, so it satisfies the second condition.
Write a program that decides whether a number is random.
The first line contains two integers N and K. (1≤N≤10000, 1<K<231)
Each of the next N lines contains one positive integer. Every given positive integer is smaller than 232.
Print N lines. On each line print YES if the corresponding number is random, and NO otherwise.
In the sample, K is 5.