Is this problem require trie concept

No idea is comming where and how to start

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.