## The Primes

```|---|---|---|---|---|
| 1 | 1 | 3 | 5 | 1 |
|---|---|---|---|---|
| 3 | 3 | 2 | 0 | 3 |
|---|---|---|---|---|
| 3 | 0 | 3 | 2 | 3 |
|---|---|---|---|---|
| 1 | 4 | 0 | 3 | 3 |
|---|---|---|---|---|
| 3 | 3 | 3 | 1 | 1 |
|---|---|---|---|---|  (Figure 1)
```

Figure 1 shows a square. Each row, each column and the two diagonals can be read as a five digit prime number. The rows are read from left to right. The columns are read from top to bottom. Both diagonals are read from left to right.

• The prime numbers must have the same digit sum (11 in the example).
• The digit in the top left-hand corner of the square is pre-determined (1 in the example).
• A prime number may be used more than once in the same square.
• If there are several solutions, all must be presented (sorted in numerical order as if the 25 digits were all one long number).
• A five digit prime number cannot begin with zeros, ie 00003 is NOT a five digit prime number.

### Input Format

A single line with two space-separated integers: the sum of the digits, and the digit in the upper left hand corner of the square.

### Output Format

Five lines of five characters each for each solution found, where each line in turn consists of a five digit prime number. Print a blank line between solutions. If there are no prime squares for the input data, output a single line containing "`NONE`".

`11 1`

### Sample Output

```11351
14033
30323
53201
13313

11351
33203
30323
14033
33311

13313
13043
32303
50231
13331```

Point Value: 25 (partial)
Time Limit: 1.00s
Memory Limit: 8M

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

• (0/0)
In PEG judge, time limit for this problem is 1 second, whereas in the official contest was of 90. Is that a mistake or is made by design? In the first case, time limit should be readjusted.

• (1/1)
The hardware was also two decades older. I won't be adjusting the time limit.

• (0/0)
My solution was tested with IOI data. It works fine. But PEG judges it WA and the output detail is empty. Any hint?

• (0/0)
The "times++;" line in solve() is never reached, so the last loop when you print the answer goes from 1 to <= 0.
There's probably undefined behaviour in your code somewhere that only works for your compiler version/settings.
IDEone uses gcc-4.8.1 and your code also doesn't print anything when I run it there either. Try debugging there.

• (0/0)
Thanks! I forgot to add space after the modular symbol. It's TLE now.