The Primes#3191

The Primes

1 second
64 megabytes
Easy

Figure 1.

Figure 1 shows a numerical matrix. Each row, each column, and both diagonals of the matrix are considered 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.

Write a program that, based on the given data, finds such matrices. The following conditions must be met:

Input

The input consists of two lines. The first line contains the required digit sum of the primes, and the second line contains the digit in the top left corner of the matrix. It is guaranteed that at least one solution exists for the given data.

Output

For each solution, output five lines, each containing a five-digit prime number. The solutions should be sorted by the prime in the first row, then the second row, and so on. Separate different solutions with a blank line.

Examples

Example 1

Loading
Loading