Remaining Letters in a Word Search

Time limit1sMemory limit128 MB

Problem

A word search puzzle consists of an N by N table of lowercase letters and a list of words to find.

To solve the puzzle, consider every occurrence of every listed word in the table. A word may start in any cell and continue in any of the eight directions: up, down, left, right, or one of the four diagonals. Whenever an occurrence is found, all letters used by that occurrence are crossed out.

After all words have been processed, read the letters that were not crossed out in row-major order: from top to bottom, and within each row from left to right. That string is the solution of the puzzle.

Write a program that prints this solution.

Input

The first line contains an integer N (1 <= N <= 10), the size of the table.

Each of the next N lines contains exactly N lowercase English letters and represents one row of the table.

The next line contains an integer R (1 <= R <= 100), the number of words in the list.

Each of the next R lines contains one word from the list. Each word has length at most 10.

All table letters and all listed words consist only of lowercase English letters (a through z).

Output

Print one line containing the solution of the puzzle.

The input is guaranteed to leave at least one letter uncrossed.