#include <stdio.h>
#include <string.h>

char max[72];
char matrix[72][72];

void secret(int x, int y, char *num, int len)
{
	char c;

	

	num[len] = matrix[y][x];
	num[len + 1] = '\0';


	if (strlen(max) < len + 1){
		strcpy(max, num);
	}
	else if (strlen(max) == len + 1){
		if (strcmp(max, num) < 0){
			strcpy(max, num);
		}
	}
//printf("<%s, %s>", num, max);
	
	c = matrix[y + 1][x];
	if ('0' <= c && c <= '9'){
		secret(x, y + 1, num, len + 1);
		num[len + 1] = '\0';
	}

	c = matrix[y][x + 1];
	if ('0' <= c && c <= '9'){
		secret(x + 1, y, num, len + 1);
		num[len + 1] = '\0';
	}
}


int main(void)
{
	int W, H, C;
	int i, j;
	int x, y;
	char c, c1, c2;
	char num[72];
	
	
	while (1){
		scanf("%d%d", &W, &H);
		if (W == 0 && H == 0){
			break;
		}
		
		memset(matrix, 0, sizeof(matrix));
		for (y = 1; y <= H; y++){
			scanf("%s", &matrix[y][1]);
		}
		

		max[0] = '\0';
		for (y = 1; y <= H; y++){
			for (x = 1; x <= W; x++){
				c = matrix[y][x];
				c1 = matrix[y - 1][x];
				c2 = matrix[y][x - 1];
				if (('0' <= c && c <= '9') &&
				    (c1 < '0' || '9' < c1) &&
				    (c2 < '0' || '9' < c2)){
					
					num[0] = '\0';
//printf("[%c]", matrix[y][x]);
					secret(x, y, num, 0);
				 
				}
			}
		}
		
		for (x = 0; max[x] == '0'; x++);
		printf("%s\n", &max[x]);
	}
	return (0);
}