Problems
The Primes
The Primes
\textit{Figure} \textbf{1}.
Figure \textbf{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. Write a program that constructs such squares:
\begin{itemize}
\item The prime numbers must have the same digit sum (\textbf{11} in the example).
\item The digit in the top left-hand corner of the square is pre-determined (\textbf{1} in the example).
\item A prime number may be used more than once in the same square.
\item If there are several solutions, all must be presented.
\item A five digit prime number cannot begin with zeros, ie \textbf{00003} is \textbf{NOT} a five digit prime number.
\end{itemize}
\InputFile
Your program is to read from standard input. First the digit sum of prime numbers and then the digit in the top left-hand corner of the square. The file contains two lines. There will always be a solution to the given test data.
\OutputFile
Your program is to write to standard output. Output five lines for each solution found, where each line in turn consists of a five digit prime number. The solutions are sorted by the prime in the first row, then by the prime in the second row, etc. Output a blank line after each solution.
Input example #1
11 1
Output example #1
11351 14033 30323 53201 13313 11351 33203 30323 14033 33311 13313 13043 32303 50231 13331