#include <stdio.h>//第2講演習問5
#define W 8
#define H 6
#include <stdlib.h>

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