CF2093C.Simple Repetition

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Simple Repetition

Pasha loves prime numbers^{\text{∗}}! Once again, in his attempts to find a new way to generate prime numbers, he became interested in an algorithm he found on the internet:

  • To obtain a new number yy, repeat kk times the decimal representation of the number xx (without leading zeros).

For example, for x=52x = 52 and k=3k = 3, we get y=525252y = 525252, and for x=6x = 6 and k=7k = 7, we get y=6666666y = 6666666.

Pasha really wants the resulting number yy to be prime, but he doesn't yet know how to check the primality of numbers generated by this algorithm. Help Pasha and tell him whether yy is prime!

^{\text{∗}}An integer xx is considered prime if it has exactly 22 distinct divisors: 11 and xx. For example, 1313 is prime because it has only 22 divisors: 11 and 1313. Note that the number 11 is not prime, as it has only one divisor.

Input

Each test consists of several sets of input data. The first line contains a single integer tt (1t1001 \leq t \leq 100) — the number of sets of input data. The following lines describe the sets of input data.

The first and only line of each data set contains two integers: xx and kk (1x1091 \leq x \leq 10^9, 1k71 \leq k \leq 7).

Output

For each set of input data, output «YES» (without quotes) if the resulting number yy will be prime, and «NO» otherwise.

You may output «Yes» and «No» in any case (for example, the strings «yES», «yes», and «Yes» will be recognized as positive answers).

Samples

4
52 3
6 7
7 1
1 7
NO
NO
YES
NO

在线编程 IDE

建议全屏模式获得最佳体验