/*
AizuOnline A1126
Title The Secret Number
*/
#include <stdio.h>
#include <string.h>
//Global data section
char biggest[71];
int  biggest_len;
char current[71];
int  current_len;
char ban[70][71];
int H,W;
//
regist_biggest()
{
        char*p;
        p=&current[0];
        while(*p=='0' && current_len >1)  // left zero surpress
        {
                p++;
                current_len--;
        }
        //print_number(p,current_len);
        if(current_len > biggest_len ||
           ((current_len == biggest_len)
            && (0<strncmp(p,biggest,current_len))))
        {
                biggest_len=current_len;
                strncpy(biggest,p,current_len);
        }
}


int findtopleft(int * y,int * x)
{
        int i,j;

        i=*y;j=*x;
        goto AAA;

        for(i=0;i<H;i++)
                for(j=0;j<W;j++)
                {
                AAA:
                        if((i==0 ||!isdigit(ban[i-1][j]))&&
                           (j==0 ||!isdigit(ban[i][j-1]))&&
                           isdigit(ban[i][j]))
                        {
                                *y=i;
                                *x=j;
                                return(-1);
                        }
                }
        return(0);
}
void print_number(char * s,int len)
{
        int i;
        for(i=0;i<len;i++)
                printf("%c",s[i]);
        //printf("(%d)",len);
        printf("\n");
}
void connect_number(int y,int x,int d)
{
        current[d]=ban[y][x];
        current_len=d+1;
        if(((x==W-1)||(!isdigit(ban[y][x+1]))) &&
           ((y==H-1)||(!isdigit(ban[y+1][x]))))
        {
                //print_number(current,current_len);
                regist_biggest();
                return;
        }
        if(x<W-1 && isdigit(ban[y][x+1]))
                connect_number(y,x+1,d+1);
        if(y<H-1 && isdigit(ban[y+1][x]))
                connect_number(y+1,x,d+1);
}
void find_biggest_secret()
{
        int y,x;

        x=y=0;
        while(findtopleft(&y,&x))
        {
                //printf("%d %d\n",y,x);

                current_len=0;
                connect_number(y,x,0);
                

                x++;
                if(x>=W)
                        y++;
                if(y>=H)
                        break;
       }
}
main()
{
        int i;

        while(EOF!=scanf("%d %d",&W,&H) && (W||H))
        {
                for(i=0;i<H;i++)
                        scanf("%s",&ban[i][0]);
                
                biggest_len=0;
                find_biggest_secret();
                
                print_number(biggest,biggest_len);
                        
        }
return(0);
}