You are given a matrix of characters. The matrix has N rows and M columns. Given a string s, you have to tell if it is possible to generate that string from given matrix.
Rules for generating string from matrix are:
You have to print Yes if given string can be generated from matrix using the given rules, else print No.
Input Format:
First line consists of T, denoting the number of test cases.
Each test case consists of:
First line consists of two integers N and M, denoting the matrix dimensions.
Following N lines consist of M characters each.
Last line consists of a string s.
Output Format:
For each test case, print "Yes" if string can be generated else print "No". Answer for each test case should come in a new line.
Input Constraints:
1≤T≤5
1≤N,M≤500
1≤|s|≤N∗M
Matrix consists of lowercase English characters.
String s consists of lowercase English characters.
We pick "a" from row 1. Now, we can only pick one more "a" from row 1 as one "a" is already used.
Similarly, "x" from row 2, "b" from row 3.
Now, we again go back to row 1.
We pick "a" from row 1, "y" from row 2 and so on.