Crossword question

ye qns bilkul nhi aa rh h pliz help

You have to search in the given MxM grid of characters for the words given initially. You can go in all 8 directions.
For Example -:
4
gitohro qf ejvh i
3
gor
pih
sto

Output should be -:
gitohro i

But For Testcase -:
3
a ab abcd
3
aaa
abc
def
Output should be -:
a ab

Apply dfs

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.