For this Question: 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 pick first character of string from row 1, second character from row 2 and so on. The (N+1)th character of string is to be picked from row 1, that is, you can traverse the rows in a cyclic manner (row 1 comes after row N).
If an occurrence of a character is picked from a row, you cannot pick the same occurrence again from that row.
You have to print Yes if given string can be generated from matrix using the given rules, else print No.First line consists of two integers N and M, denoting the matrix dimensions.
Next N lines consist of M characters each.
Last line consists of a string s.

Constraints:
1 &le; N, M &le; 200
1 &le; S.length() &le; 4*10<sup>4</sup>
S contains only lowercase English letters .
 
Print "Yes" if string can be generated else print "No". Answer for each test case should come in a new line.

Sample Input 1:
3 3
aba
xyz
bdr
axbaydb

Sample Output 1:
Yes

Explanation
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., I have written this Solution Code: N,M = map(int,input().split())
words=[]
for i in range(N):
    words.append(list(input().strip()))
test_word=list(input().strip())
ans="Yes"
for i in range(len(test_word)):
    if test_word[i] not in words[i%N]:
        ans="No"
        break
    else:
        words[i%N].remove(test_word[i])
print(ans), In this Programming Language: Python, Now tell me if this Code is compilable or not?