you are given a board of size n*m, containing an English alphabet in each cell.
You are also given a word, find if the word exists on the board.
The word can be constructed from letters of sequentially adjacent cells. Cells which have a common edge are considered adjacent. The same cell may not be used more than once.
The first line contains an integer âTâ denoting the number of test cases.
For each test case the input has the following lines:
For each test case, the output has a line with 1 or 0, denoting whether the word exists on the board or not.
2
3 4
WORKAT
A W O R
T E R K
T A K A
3 4
ATTECH
A W O R
T E R K
T E T A
1
0
1 <= T <= 10
1 <= n, m <= 100
1 <= word.length <= 200
boardij = 'A' to 'Z'