#include <bits/stdtr1c++.h>
using namespace std;

typedef pair<int,int> pii;

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

int n, m;
int b[102][102];
int h[100][100];
bool c[102][102];

int main() {
  ios::sync_with_stdio(0);
  int T = 1;
  while (cin >> n >> m && n) {
    cout << "Case " << T++ << ": ";
    memset(b, 0, sizeof b);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> h[i][j];
        b[i+1][j+1] = h[i][j];
      }
    }
    int H = 0;
    while (true) {
      memset(c, 0, sizeof c);
      for (int i = 0; i < n+2; i++)
        for (int j = 0; j < m+2; j++)
          if (i == 0 || i == n+1 || j == 0 || j == m+1)
            b[i][j] = H;
      queue<pii> q;
      q.push(make_pair(0,0));
      c[0][0] = true;
      while (q.size()) {
        pii f = q.front();
        q.pop();
        for (int i = 0; i < 4; i++) {
          int x = f.first+dx[i], y = f.second+dy[i];
          if (0 <= x && x < n+2 && 0 <= y && y < m+2 && b[x][y] <= H && !c[x][y]) {
            c[x][y] = true;
            q.push(make_pair(x,y));
          }
        }
      }
      int p = 0;
      for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
          if (!c[i][j]) {
            q.push(make_pair(i,j));
            c[i][j] = true;
            while (q.size()) {
              pii f = q.front();
              q.pop();
              for (int k = 0; k < 4; k++) {
                int x = f.first+dx[k], y = f.second+dy[k];
                if (0 <= x && x < n+2 && 0 <= y && y < m+2 && !c[x][y]) {
                  c[x][y] = true;
                  q.push(make_pair(x,y));
                }
              }
            }
            p++;
          }
        }
      }
      if (p == 0) {
        cout << "Island never splits.\n";
        break;
      }
      else if (p > 1) {
        cout << "Island splits when ocean rises " << H << " feet.\n";
        break;
      }
      H++;
    }
  }
  return 0;
}