for _ inrange(t): ifnot isFirst: print() isFirst = False emp = input() wList = [] r, c = map(int, input().split()) for _ inrange(r): wList.append(input().lower()) test = int(input()) for _ inrange(test): s = input().lower() found = False for i inrange(r): for j inrange(c): if wList[i][j].lower() == s[0]: for dx, dy in directions: match = True for k inrange(1, len(s)): nx = i + dx * k ny = j + dy * k if nx < 0or nx >= r or ny < 0or ny >= c or wList[nx][ny] != s[k]: match = False break ifmatch: print(f"{i+1}{j+1}") found = True break if found: break if found: break