|
|||
Circular Matrix MatchingA p × r matrix B = (Bij)0 ≤ i < p, 0 ≤ j < r occurs in m × n matrix A = (Aij)0 ≤ i < m, 0 ≤ j < n starting at position (k, l) if Bij = Ak + i, l + j for 0 ≤ i < p, 0 ≤ j < r, and m, n, p, r > 0, where the indices are considered circularly. For example, let:
B occurs in A beginning at positions: (0, 2), (2, 5), and (3, 6) (positions of underlined elements in the matrix). For given B and A, find all starting positions at which B occurs in A. Input SpecificationThe first line of the input contains the number of test cases. For each test case, the first line contains the number of rows p and the number of columns r for matrix B, separated by a space. Each of the next p lines contains the elements of a row of matrix B, each element being a character, separated by a space. The next line contains the number of rows m and the number of columns n for matrix A, separated by a space. Each of the next n lines contains the elements of a row of matrix A, each element being a character, separated by a space. Input Limits and Constraints
Output Specification
For each test case, print in a line Sample Input
Output for Sample Input
|
|||
University of Debrecen; Faculty of Informatics; v. 09/30/2024 |