#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

const int n = 75;
char m[n][n];
string memo[n][n];
string ans;

string big(string a, string b){
    if(a.size() > b.size()){
        return a;
    }else if(a.size() < b.size()){
        return b;
    }else{
        return a > b ? a : b;
    }
}

string dfs(int x, int y){
    string ret;
    if(memo[y][x] != "") return  memo[y][x];

    if(not isdigit(m[y][x])) return ret;
    else ret+=m[y][x];

    return memo[y][x] = ret + big(dfs(x + 1, y), dfs(x, y + 1));
}

int main(){
    int w, h;
    while(cin >> w >> h, w||h){
        ans = "";
        rep(i,n) rep(j,n) memo[i][j] = "";
        rep(i,n) rep(j,n) m[i][j] = '#';
        rep(i,h) rep(j,w) cin >> m[i + 1][j + 1];
        rep(i,h){
            rep(j,w){
                if(isdigit(m[i + 1][j + 1]) && m[i + 1][j + 1] != '0'){
                    ans = big(ans,dfs(j + 1, i + 1));
                }
            }
        }
        cout << ans << endl;
    }
}