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

int grid[102][102];
int visited[102][102];
int water[102][102];
int water_visited[102][102];
int n, m;
int dir[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
int case_num;

int dfs(int y, int x, int count) {
  if (y > n || x > m || x <= 0 || y <= 0 || visited[y][x] || (water_visited[y][x])) {
    return 0;
  }
  visited[y][x] = 1;
  int mycount = count + 1;
  for (int i = 0; i < 4; i++) {
    mycount += dfs(y + dir[i][0], x + dir[i][1], count);
  }
  return mycount;
}

int dfs_water(int y, int x, int count) {
   if (y > n + 1 || x > m + 1|| x < 0 || y < 0 || water_visited[y][x] || (grid[y][x] != 0)) {
    return 0;
  }
  water_visited[y][x] = 1;
  int mycount = count + 1;
  for (int i = 0; i < 4; i++) {
    mycount += dfs_water(y + dir[i][0], x + dir[i][1], count);
  }
  return mycount;
}

void print() {
  for (int j = 0; j < n + 2; j++) {
    for (int i = 0; i < m + 2; i++) {
      cout << grid[j][i] << ' ';
    }
    cout << '\n';
  }
}

bool splits() {
  int count_zeros = 0;
  int count_connected = 0;

  count_zeros = dfs_water(0, 0, 0);
  for (int j = 0; j < n; j++) {
    for (int i = 0; i < m; i++) {
      if (grid[j][i] != 0) {
        count_connected = dfs(j, i, 0);
        goto next;
      }     
    }
  }
next:
  return count_zeros + count_connected < m * n + 2 * m + 2 * n + 4;
}

int main() {
  while (cin >> n >> m && (n + m)) {
    int h_max = 0;
    memset(grid, 0, sizeof (grid));
    for (int j = 1; j <= n; j++) {
      for (int i = 1; i <= m; i++) {
        cin >> grid[j][i];
        h_max = max(h_max, grid[j][i]);
      }
    }

    int split_height = h_max;
    for (int i = 0; i <= h_max; i++) {
      memset(visited, 0, sizeof (visited));
      memset(water_visited, 0, sizeof (water_visited));
      for (int y = 1; y <= n; y++) {
        for (int x = 1; x <= m; x++) {
          if (grid[y][x] <= i) {
            grid[y][x] = 0;
          }
        }
      }
      if (splits()) {
        split_height = i;
        break;
      }
    }
    cout << "Case " << ++case_num << ": ";
    if (split_height == h_max) {
      cout << "Island never splits.\n";
    } else {
      cout << "Island splits when ocean rises " << split_height << " feet.\n";
    }
  }
  return 0;
}