P18059 [UKIEPC 2024] Word Search
Description
Find parts of a 2d grid matching a 2d word.
Input Format
- One line containing the number of rows and columns in the search key, $r_k$ and $c_k$ ($1 \le r, c \le 2000$).
- $r_k$ further lines, each containing $c_k$ Latin characters comprising a row of the search key.
- One line containing the number of rows and columns in the haystack, $r_h$ and $c_h$ ($r_k \le r_h \le 2000$, $c_k \le c_h \le 2000$).
- $r_h$ further lines, each containing $c_h$ Latin characters comprising a row of the search key.
Output Format
Illustrate the matching areas of the haystack by printing a grid of the same size. In locations that are part of at least one match, print the original character from the haystack. In other cases, print a full-stop “.” character.