Word Search

시간 제한2초메모리 제한1024 MB

문제

Find parts of a 2d grid matching a 2d word.

입력

  • 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.

출력

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.