#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int W,H;
string s[71][71];
char in[71][71];

bool comp2(string s, string r){
	if(s.size() != r.size()) return s.size() > r.size();
	return s > r;
	
}

bool comp(string s, string r){
	while(s[0]=='0' && isdigit(s[1])) s = s.substr(1);
	while(r[0]=='0' && isdigit(r[1])) r = r.substr(1);
	return comp2(s, r);
}
int main(){
	int i,j,k;
	while(cin>>W>>H, W){
		for(i=0;i<H;i++) cin>>in[i];
		string m="0";
		for(int h=H;h>=0;h--)
			for(int w=W;w>=0;w--)
				s[h][w] = "";
		for(int h=H-1;h>=0;h--)
			for(int w=W-1;w>=0;w--){
				if(!isdigit(in[h][w])) continue;
				if(comp(in[h][w]+s[h+1][w],m)) m = (in[h][w]+s[h+1][w]);
				if(comp(in[h][w]+s[h][w+1],m)) m = (in[h][w]+s[h][w+1]);
				s[h][w] = (comp2(in[h][w]+s[h+1][w] , in[h][w]+s[h][w+1])) ? (in[h][w]+s[h+1][w]) : (in[h][w]+s[h][w+1]);
			}
		while(m[0]=='0' && isdigit(m[1])) m = m.substr(1);
		cout<<m<<endl;
	}
	return 0;
}