mod=10**9+7 h,w=map(int,input().split()) s=[] for i in range(h): s.append(list(input())) def check(x,y): return 0<=x