You are given a table of lowercase letters (for example, Table I). The game is played as a sequence of steps. In each step you choose a table cell E that holds a non-blank character ch. Starting from E, you find all of its friends: a friend is any cell that holds the same character ch and is directly adjacent to E (immediately to the left, right, above, or below), together with the friends of those cells, and so on, until no new friend can be found. In other words, the friends of E form the connected region of equal characters that contains E under 4-directional adjacency. You then replace ch in E and in every friend with a blank. Table II shows the result of applying this rule to Table I starting from the cell in row 1, column 2, where ch is a.

Still within the same step, you first slide every non-blank character as far to the left as possible, so that the blanks in each row move to the right (Table III). Next, you slide every non-blank character as far down as possible, so that the blanks in each column move up (Table IV). Finally, any row or column that has become entirely blank is deleted, shrinking the table.

Write a program that, given an initial table and a sequence of chosen cells, applies the rule above to each chosen cell in turn and reports the final table.
The input contains several test cases, one after another, until the end of input.
Each test case begins with the character map, given as m lines of n characters each (1≤m,n≤1000); every character of the initial map is a lowercase letter. Because map lines contain only letters, the map ends at the first line that is an integer: that line holds k, the number of chosen cells. It is followed by k lines, each containing two integers r and c (1≤r≤m, 1≤c≤n), the row and column of a chosen cell. Coordinates refer to the current table (after the deletions caused by previous steps), and each chosen cell is always inside the current table.
For the i-th test case, first print the line:
Test case #i:
Then print the final table row by row, one row per line, in the same character format as the input. Trailing blanks in a row are omitted, so different rows may have different lengths. If the table has become completely empty, print no rows after this header line.