H,W = map(int, input().split()) S = [] for _ in range(H): S.append(list(input()+'~')) S.append(list('~'*W)) pos = set() pos.add(0) ANS = [S[0][0]] while len(ANS)