#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
//#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
//#define EXIST(s, e) ((s).find(e)!=(s).end())
//#define SORT(c) sort(begin(c),end(c))
//#define pb emplace_back
//#define MP make_pair
//#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する
int W, H;
vector<string> vv;
string dp[70][70];

bool integer(char c) {
    return c >= '0' && c <= '9';
}

string parse(string str) {
    int start = 0;
    for (start = 0; str[start] == '0' && start < str.size(); start++) {

    }
    return str.substr(start);
}

bool lt(string left, string right) {
//    left = parse(left);
//    right = parse(right);
    if (left.size() < right.size()) {
        return true;
    } else if (left.size() > right.size()) {
        return false;
    } else {
        rep(i, 0, left.size()) {
            if (left[i] != right[i]) {
                return left[i] < right[i];
            }
        }
    }
    return false;
}

string dfs(int sh, int sw) {
    if (dp[sh][sw] != ".") return dp[sh][sw];
    if (!integer(vv[sh][sw])) {
        return "";
    }
    if (sh < H - 1 && sw < W - 1) {
        string right;
        right += vv[sh][sw];
        right += dfs(sh, sw + 1);

        string down;
        down += vv[sh][sw];
        down += dfs(sh + 1, sw);
        if (lt(right, down)) {
            return dp[sh][sw] = down;
        } else {
            return dp[sh][sw] = right;
        }
    } else if (sh < H - 1 && sw == W - 1) {
        string down;
        down += vv[sh][sw];
        down += dfs(sh + 1, sw);
        return dp[sh][sw] = down;

    } else if (sh == H - 1 && sw < W - 1) {
        string right;
        right += vv[sh][sw];
        right += dfs(sh, sw + 1);
        return dp[sh][sw] = right;

    } else if (sh == H - 1 && sw == W - 1) {
        string ret = "";
        ret += vv[sh][sw];
        return dp[sh][sw] = ret;
    }
    return "";
}

bool solve() {
    cin >> W >> H;
    if (W == 0 && H == 0) {
        return false;
    }
    vv.resize(H);
    rep(i, 0, 70) {
        rep(j, 0, 70) {
            dp[i][j] = ".";
        }
    }

    rep(i, 0, H) {
        cin >> vv[i];
    }

    string ans = "";
    rep(sh, 0, H) {
        rep(sw, 0, W) {
            string tmp = parse(dfs(sh, sw));
            if (lt(ans, tmp)) {
                ans = tmp;
            }
        }
    }
    cout << ans << endl;

    return true;


}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    while (solve()) {

    }

    return 0;
}



Measured memory_bytes: 3460