Story
--------
Human genetic information is recorded in DNA with a double helix structure and is represented by a very long string consisting of four characters, `A`, `G`, `C`, and `T`.
Recently, alien cells were found in a meteorite.
As a result of research, it was found that the genetic information of this alien is recorded in a torus-shaped material and is represented as an $N\times N$ matrix consisting of eight characters, `A`, `B`, `C`, `D`, `E`, `F`, `G`, and `H`.
Existing devices have failed to read this matrix directly, but they have succeeded in reading many one-dimensional subsequences that are contiguous vertically or horizontally.
Please estimate the matrix based on this information.
Problem Statement
--------
We define that a one-dimensional sequence $b=(b_0, \ldots, b_{k-1})$ is a **subsequence** of a matrix $a=(a_{i,j})_{0\leq i,j\leq N-1}$ if and only if there exists $(i, j)$ satisfying at least one of the following two conditions:
- For all $p=0,\ldots,k-1$, $b_p=a_{i,(j+p)\bmod N}$ holds. (horizontal match)
- For all $p=0,\ldots,k-1$, $b_p=a_{(i+p)\bmod N,j}$ holds. (vertical match)
Note that if the index is greater than or equal to $N$, we take the remainder divided by $N$ (in other words, $a$ is connected at the left and right ends, and the top and bottom ends).
Given $M$ strings $s_1, \ldots, s_M$ consisting of eight characters, `A`, `B`, $\ldots$, `H`, your goal is to find an $N\times N$ matrix consisting of characters `A`, `B`, $\ldots$, `H`, or `.` which contains as many of the given strings as possible as subsequences.
Here, `.` indicates an empty.
Scoring
--------
Let $c$ ($\leq M$) be the number of $i$'s such that $s_i$ is a subsequence of the output matrix, and let $d$ ($\leq N^2$) be the number of `.` contained in the output.
Then, you will obtain the following score.
- If $cInputs: A set of 100 inputs (seed 0-99) for local testing, including the sample input (seed 0). These inputs are different from the actual test cases.
- Visualizer on the web
- Input generator and visualizer: If you want to use more inputs, or if you want to visualize your output locally, you can use this program. You need a compilation environment of Rust language.
{sample example}