from random import randint

board = []

for x in range(5):
  board.append(["O"] * 5)

def print_board(board):
  for row in board:
    print " ".join(row)

print "Jouons au Touchay Coulay !"
print

print_board(board)

def random_row(board):
  return randint(0, len(board) - 1)

def random_col(board):
  return randint(0, len(board[0]) - 1)

ship_row = random_row(board)
ship_col = random_col(board)
# print ship_row
# print ship_col

for turn in range(6):
  print
  guess_row = int(raw_input("Quelle ligne ? "))
  guess_col = int(raw_input("Quelle colonne ? "))
  print

  if guess_row == ship_row and guess_col == ship_col:
    print "Touchay, coulay !"
    break
  else:
    if (guess_row < 0 or guess_row > 4) or (guess_col < 0 or guess_col > 4):
      print "C'est hors limite."
      print
    elif(board[guess_row][guess_col] == "X"):
      print "Case visay auparavant."
      print
    else:
      if turn == 5:
        print "TERMINUS LE KRAKEN A GAGNAY"
        print
      else:
        print "Loupay !"
        print
        board[guess_row][guess_col] = "X"
      
  print "Tour - " + str(turn + 1)
  print_board(board)
  