H,W=map(int, input().split()) A=[] for i in range(H): X=input() A.append(X) from collections import deque D={} D[(0,0)]=[0]*21 D[(0,0)][1]=1 dy,dx=[1,0],[0,1] for i in range(H+W-2): DD={} for d in D: y,x=d for i in range(2): ny,nx=y+dy[i],x+dx[i] if 0<=ny