Олимпиадный тренинг

Задача 34819. Puzzle


Peter solves a puzzle, which is arranged as follows. A square table of size  NxN is given, in each cell of which some Latin letter is written. In addition, a list of keywords is given. Petya needs to take another keyword and find it in the table. That is, find all the letters of this word in the table, and they must be arranged so that the cell in which each subsequent letter of the word is located is adjacent to the cell in which the previous letter is written (cells are called neighboring if they have a common side — i.e. side by side vertically or horizontally). For example, the figure below shows how the word  olympiad can be located in the table.
P O L T E
R W Y M S
O A I P T
B D A N R
L E M E S
When Petya finds a word, he crosses it out of the table. Crossed-out letters cannot be used in other keywords.
After all the keywords are found and crossed out, a few more letters remain in the table, from which Petya must form the word encrypted in the puzzle.
Help Petya solve this puzzle by writing a program that, given the table and the list of keywords, writes out which letters Petya should use to form the word, that is, which letters will remain in the table after the keywords are crossed out.

Input
The first line of the input file contains two numbers N (1?N?10) and M (0?M?200). The following N lines of N capital Latin letters describe the rebus. The next M lines contain words. Words consist only of capital Latin letters, each word is not longer than 200 characters. It is guaranteed that all keywords can be found in the table and crossed out according to the rules described above.
Output
In a single line of the output file print in any order the letters that will remain in the table.

Examples
input
5 3
POLTE
RWYMS
OAIPT
BDANR
LEMES
OLYMPIAD
PROBLEM
TEST
output
AENRSW