Passes sample test case otherwise showing TLE please help

hey @Ramitgoel
dry run your code for
6
app
apple
application
batman
batmobile
cat
7
ap
bat
batcave
bat
cat
appl
appledore

u ll realise ur error.also use tries for this question