#include<stdio.h>
int main() {
int i, j, n, m, a, maxv, t = 1;
while (scanf("%d %d", &n, &m), n || m) {
maxv = -1;
for (i = 0; i<n; i++) {
for (j = 0; j<m; j++) {
scanf("%d", &a);
if (a > maxv) maxv = a;
}
}
if (t != 1) printf("\n");
printf("Case %d:\n", t++);
printf("%d\n", maxv);
}
return 0;
}
#include<iostream>
using namespace std;
int main() {
int n, m, a, maxv, t = 1;
while (cin >> n >> m, n || m) {
maxv = -1;
for (int i = 0; i<n; i++) {
for (int j = 0; j<m; j++) {
cin >> a;
maxv = max(maxv, a);
}
}
if (t != 1) cout << endl;
cout << "Case " << t++ << ":" << endl;
cout << maxv << endl;
}
return 0;
}