/**
 *  The Secret Number (PKU 2030)
 *  by Kenji Inoue, 2007-01-02
 **/

#include <iostream>
#include <string>

using namespace std;

#define isdigit(x) ('0' <= (x) && (x) <= '9')

char f[71][71]; // field
string t[71][71]; // table
int w, h;

string max(string s1, string s2) {
  if (s1.size() > s2.size()) {
    return s1;
  } else if (s1.size() < s2.size()) {
    return s2;
  }

  if (s1 > s2) {
    return s1;
  }
  return s2;
}

string rec(int x, int y) {
  if (x < 0 || y < 0) { return ""; }
  if (!isdigit(f[y][x])) { return ""; }
  if (t[y][x] != "-") { return t[y][x]; }

  t[y][x] = max(rec(x, y-1), rec(x-1, y)) + f[y][x];
  if (t[y][x] == "0") { t[y][x] = ""; }

  return t[y][x];
}

int main() {
  while (cin >> w >> h, (w || h)) {
    for (int y=0; y<h; y++) {
      cin >> f[y];
      for (int x=0; x<w; x++) { t[y][x] = "-"; }
    }

    string ans = "";
    for (int y=0; y<h; y++) {
      for (int x=0; x<w; x++) {
        if ( (y == h-1 || !isdigit(f[y+1][x]) ) &&
             (x == w-1 || !isdigit(f[y][x+1]) ) ) {
          ans = max(ans, rec(x, y));
        }
      }
    }
    cout << ans << endl;
  }

  return 0;
}