#include <bits/stdtr1c++.h>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef complex<ld> pt;

int a[105][105], n, m;
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};

bool seen[105][105], seen2[105][105];
int ncomp(int w) {
	memset(seen, false, sizeof seen);
	memset(seen2, false, sizeof seen2);
	
	queue<pair<int, int>> q;
	q.push({0, 0});
	while (!q.empty()) {
		int x = q.front().first, y = q.front().second;
		q.pop();
		for (int d = 0; d < 4; d++) {
			int nx = x + dx[d], ny = y + dy[d];
			if (nx < 0 || ny < 0 || nx > n+1 || ny > m+1) continue;
			if (seen2[nx][ny]) continue;
			if (a[nx][ny] > w) continue;
			seen2[nx][ny] = true;
			q.push({nx, ny});
		}
	}
			
	int res = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (seen[i][j] || seen2[i][j]) continue;
			res++;
			seen[i][j] = true;
			q.push({i, j});
			while (!q.empty()) {
				int x = q.front().first, y = q.front().second;
				q.pop();
				for (int d = 0; d < 4; d++) {
					int nx = x + dx[d], ny = y + dy[d];
					if (seen[nx][ny] || seen2[nx][ny]) continue;
					seen[nx][ny] = true;
					q.push({nx, ny});
				}
			}
		}
	}
	return res;
}

int main() {
	ios::sync_with_stdio(0);
	while (cin >> n >> m) {
		if (n+m == 0) break;
		memset(a, 0, sizeof a);
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				cin >> a[i][j];
			}
		}
		
		int l = 0;
		while (l < 1000 && ncomp(l) != 2) l++;
		
		static int ca = 0;
		cout << "Case " << ++ca << ": ";
		if (l == 1000) cout << "Island never splits." << endl;
		else {
			cout << "Island splits when ocean rises " << l << " feet." << endl;
		}
	}
	return 0;
}