#include<stdio.h>
#include<string.h>
int W,H,i,j;
char dp[71][71][71],g[2],tmp[71],res[71];

void ch(char x[],char y[])
{
	int s,t;
	while(x[0]=='0')
		memmove(x,x+1,strlen(x));
	while(y[0]=='0')
		memmove(y,y+1,strlen(y));
	s=strlen(x),t=strlen(y);
	if(s<t||(s==t&&strcmp(x,y)<0))
		strcpy(x,y);
}
int main()
{
	for(;scanf("%d%d\n",&W,&H),W;)
	{
		memset(dp,0,sizeof(dp));
		memset(res,0,sizeof(res));
		for(i=0;i<H;i++,getchar())
			for(j=0;j<W;j++)
			{
				tmp[0]=0;
				g[0]=getchar();
				if(g[0]<58)
				{
					if(i>0)
						ch(tmp,dp[i-1][j]);
					if(j>0)
						ch(tmp,dp[i][j-1]);
					sprintf(dp[i][j],"%s",strcat(tmp,g));
				}
				ch(res,dp[i][j]);
			}
		puts(res);
	}
	return 0;
}