TDP Inc. has decided to sue JCN Inc. for copyright infringement. To build its case, TDP wants to find the infringing segments inside JCN's code base so that it can present them to selected members of the press. Because TDP has let go of all of its technical staff, it plans to hire an outside consultant, paid on a contingency basis only if the lawsuit succeeds. To prove that you are qualified for the job, solve the following problem for a number of test cases.
Each test case begins with a positive integer $k$, the number of infringing segments to find.
After that line come two code bases. The first code base starts with the line BEGIN TDP CODEBASE, contains some number of lines, and ends with the line END TDP CODEBASE. The second code base starts with BEGIN JCN CODEBASE and ends with END JCN CODEBASE. The line END TDP CODEBASE never appears inside the first code base, and the line END JCN CODEBASE never appears inside the second.
A line containing a single 0 follows the last test case.
For every test case, print:
CASE n, where $n$ is the test case number (starting from 1);Each segment must be printed exactly as it appears in the JCN code base, including any spaces and newline characters. Immediately before each segment, print a line
INFRINGING SEGMENT m LENGTH l POSITION p
where $m$ is the index of the segment within the current test case (starting from 1), $l$ is the length of the segment in characters, and $p$ is the position of the segment measured in characters from the start of the JCN code base (the first character is at position 0). Print one empty line between consecutive test cases.
A code base is simply a string of characters. An infringing segment is a non-empty, contiguous run of characters in the JCN code base that is textually identical to some contiguous run of characters in the TDP code base and that is not contained in any longer infringing segment. Every character counts, including spaces and the newline that terminates each line.
Order the segments by decreasing length. Segments of equal length are ordered by the position at which they occur in the JCN code base (earliest first). If there are $k$ or fewer segments, print all of them in this order; if there are more than $k$, print only the first $k$.
You may assume that no code base contains more than 50,000 characters.