Two companies, RBN and HAL, both use a programming language with one statement per line. Every statement has the form
STOREA = STOREB + STOREC
where STOREA, STOREB, and STOREC are variable names. That is, each line consists of a variable name starting in the first column, followed by a space, an equals sign, a space, a second variable name, a space, the addition symbol +, a space, and a third variable name. The same variable name may appear more than once on a single line. Variable names consist of $1$ to $8$ uppercase letters (A–Z).
Suppose HAL copied a consecutive block of lines directly from RBN's source code, making only the following minor modifications:
STOREA = STOREB + STOREC may have become STOREA = STOREC + STOREB.Given RBN's program and HAL's program, find the length of the longest consecutive block of lines in HAL's program that could have been produced from a consecutive block of lines in RBN's program using the modifications above. The two corresponding blocks need not start at the same line number.
The first line contains two space-separated integers $R$ and $H$ ($1 \le R \le 1000$, $1 \le H \le 1000$). $R$ is the number of lines in RBN's program and $H$ is the number of lines in HAL's program.
The next $R$ lines contain RBN's program.
The next $H$ lines contain HAL's program.
Print a single integer on one line: the length of the longest consecutive block of lines HAL could have copied from RBN and transformed. (Print $0$ if there is no such block.)
In the sample, applying the substitutions RA → HM, RB → D, RC → HN, D → HA, RE → HB to RBN's program makes lines 1–2 of RBN identical to lines 2–3 of HAL. No block of three or more lines matches, so the answer is $2$.