#include <stdio.h>
#include <stdlib.h>

#define W 8
#define H 6
	char map[H][W]={
	{1,1,1,1,1,1,1,1},
	{1,0,0,0,0,0,0,1},
	{1,0,1,1,1,0,1,1},
	{1,0,0,0,0,1,0,1},
	{1,0,0,1,0,0,2,1},
	{1,1,1,1,1,1,1,1},
	};
	
	char visited[H][W]={0};
	
void maze1(int x,int y,int depth){
	int i;
	if(visited[y][x]==0){
		visited[y][x]=1;
		for(i=0;i<depth*2;i++){
			printf(" ");
		}
		printf("(%d,%d)",x,y);
		if(map[y][x]==0){
			printf("\n");
			maze1(x+1,y,depth+1);
			maze1(x,y+1,depth);
			maze1(x-1,y,depth-1);
			maze1(x,y-1,depth);
		} else if(map[y][x]==1){
			printf("X\n");
		} else {
			printf("OK\n");
			exit(0);
		}
	}
}

int main(void) {
	maze1(1,1,0);
	return 0;
}