#include <iostream>
#include <cstring>
#include <queue>
using namespace std;
struct Piont {
int x ,y;
};
int zy[8] = { 1 ,1 ,-1 ,-1 ,2 ,2 ,-2 ,-2 };
int zx[8] = { 2 ,-2 ,2 ,-2 ,1 ,-1 ,1 ,-1 };
int counnt ,bz[1000][1000] ,n ,m ,k;
Piont w ,s;
void BFS () {
queue<Piont>q; q.push ( w );
bz[w.x][w.y] = 1; Piont e ,d;
int i ,size; size = 1; counnt++;
while ( !q.empty () ) {
if ( size == 0 ) { counnt++; size = q.size (); }
if ( counnt > k )return;
e = q.front (); q.pop (); size--;
for ( i = 0; i < 8; i++ ) {
d.x = e.x + zx[i]; d.y = e.y + zy[i];
if ( 0<d.x&&d.x <= n&&d.y > 0 && d.y <= m ) {
if ( s.x - counnt <= d.x && d.x <= s.x + counnt&&d.y >= s.y - counnt && d.y <= s.y + counnt ) {
if ( counnt == 1 && d.x == s.x&&d.y == s.y )counnt++;
return; }
if ( bz[d.x][d.y] == 0 ) { q.push ( d ); bz[d.x][d.y] = 1; }
}
}
}
}
int main () {
int x ,g;
g = 1; cin >> x;
while (x--) {
memset ( bz ,0 ,sizeof( bz ) ); counnt = 0;
cin >> n >> m >> k;
cin >> s.x >> s.y;
cin >> w.x >> w.y;
BFS ();
cout << "Case #" << g++ << ":" << endl;
if ( counnt > 0 && counnt <= k )cout << counnt << endl;
else cout << "OH,NO!" << endl;
}
return 0;
}