#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int dx[] = {1, 0};
const int dy[] = {0, 1};

vector<string> board(70);
string memo[70][70];
int W, H;

inline bool isDigit(int x, int y)
{
    if ('0' <= board[y][x] && board[y][x] <= '9')
        return true;
    else
        return false;
}

string Rec(int x, int y)
{
    if (memo[y][x].size() != 0)
        return memo[y][x];

    string s, tmp;
    for (int d = 0; d < 2; ++d) {
        int nx = x + dx[d];
        int ny = y + dy[d];

        if (nx < 0 || nx >= W || ny < 0 || ny >= H || !isDigit(nx, ny))
            continue;

        tmp = Rec(nx, ny);
        if (tmp.size() > s.size() || (tmp.size() == s.size() && tmp > s))
            s = tmp;
    }

    return memo[y][x] = board[y][x] + s;
}

int main()
{
    while (cin >> W >> H, W || H) {
        // Input
        for (int i = 0; i < H; ++i) {
            cin >> board[i];
            for (int j = 0; j < W; ++j)
                memo[i][j] = "";
        }

        // Solve
        string tmp, ans;
        for (int i = 0; i < H; ++i)
            for (int j = 0; j < W; ++j)
                if (isDigit(j, i) && memo[i][j].size() == 0) {
                    tmp = Rec(j, i);
                    int index = 0;
                    while (tmp[index] == '0')
                        index++;
                    tmp = tmp.substr(index);

                    if (tmp.size() > ans.size() || (tmp.size() == ans.size() && tmp > ans))
                        ans = tmp;
                }

        // Output
        cout << ans << endl;
    }

    return 0;
}