As we all know, lfq198502 likes to play the LianLian Kan game very much.
During the LianLian Kan game, so long as the same color of the two cards can be linked together with no more than three straight lines,they will be eliminated,the rules simple and easy to use.
Operations: The first use of mouse clicks a pawn in the chessboard, the pawn is "checked" at this moment with a special display;the mouse clicking another pawn again, if the pawn of pattern is the same as the "checked" pawn,and the two pawns can be linked together with no more than three straight lines, this pair of pawns will be eliminated;otherwise the first pawn was not "checked", and the second one was "checked".
Here,we can imagine the LianLian Kan’s interface into a plane with 10 × 10 blocks, each block is a type of pictorial or empty.The sake of simplicity, we use different characters representing different patterns, a space means that there is no pattern. Given the initial interface of game and the records that lfq198502’s mouse clicked the coordinates in the course of the game,your task is to judge whether he can eliminate all the patterns or not after these actions.
The first line of the input contains an integer T(1 <= T <= 50). T refers to the number of the test cases followed.
Each test case contains two parts:
The first part: ten lines of strings and each line contains ten characters (a space character indicates that there is no pattern at this block and each other character stands for one pattern),indicating the initial interface.
The second part: an integer n on the first line,indicating how many times that lfq198502’s mouse clicked; then n lines followed,each line with two integers x,y(1≤x≤10, 1≤y≤10), indicating the row and column postion of a mouse click.
For each test case output one line.If lfq198502 can eliminate all the patterns,output “Yes,all patterns are eliminated!”;otherwise,output “No,m pattern(s) are left!”.Show the exact format as bellow.