What is time complexity?

What is the time complexity of this problem I am bit confuse . Used dfs and my code:

What I am thinking is we have to check ist charcter of given string with every charcter of 2d grid if it match make dfs call and with every dfs call we can further cover 2d grid again so n2*n2 = n^4 but I am feeling this is wrong .

hi @AtulAggarwal you can refer to this solution