def I():return int(input()) def MAP():return map(int,input().split()) def MAPs():return map(str,input().split()) def LI(): return list(map(int,input().split())) def TPL(): return tuple(map(int,input().split())) def S():return input() from collections import defaultdict,Counter,deque from copy import deepcopy from heapq import heapify,heappop,heappush from bisect import bisect_left,bisect_right from itertools import accumulate,product,permutations,combinations from math import gcd,ceil,floor,sqrt inf=10**18 h,w=MAP() g=[S() for _ in range(h)] dp=[['']*w for _ in range(h)] dp[0][0]=g[0][0] for i in range(h): for j in range(w): if i==j==0: continue if i==0: dp[i][j]=dp[i][j-1]+g[i][j] elif j==0: dp[i][j]=dp[i-1][j]+g[i][j] else: if dp[i-1][j]