from collections import defaultdict mod=10**9+7 h,w=map(int,input().split()) s=[] for i in range(h): s.append(list(input())) dp=defaultdict(int) if (h+w)%2==0: for i1 in range(h): j1=(h+w-2)//2-i1 if 0<=j1