/*
    Ingus Zemturis
    Gupa: 110
    Compiler: https://www.onlinegdb.com/online_csharp_compiler
*/
using System;
using System.Collections.Generic;
class HelloWorld 
{
    static bool ending = false;
    static List<string> otherReservations = new List<string>();
    static int[][] reservations = new int[][]
            {
                new int [] {0, 0, 0, 0, 0},
                new int [] {0, 0, 0, 0, 0, 0, 0},
                new int [] {0, 0, 0, 0}
            };
            
    static void HandleChoice ()
    {
                     Console.WriteLine("1 – Parādīt zāli   2 – Rezervēt vietu   3 – Parādīt rezervāciju sarakstu  4 – Iziet");
     int choice = Convert.ToInt32(Console.ReadLine());
 
     switch (choice)
     {
         case 1:
            ShowGrass(reservations);
            break;
        case 2:
            ReserveSpace(reservations,otherReservations);
            break;
        case 4:
            ending = true;
            break;
        case 3:
            normalProgram();
            break;
            
     }
    }
    
    static void ShowGrass (int[][] seats)
    {
        Console.Clear();
        for (int i = 0; i < seats.Length; i++)
        {
            for (int why = 0; why < seats[i].Length; why++)
            {
                if (seats[i][why] == 0)
                {
                    Console.Write(" O");
                } else
                {
                    Console.Write(" X");
                }
            }
            Console.WriteLine();
        }
    }
    
    static bool ReserveSpace (int[][] seats, List<string> Rezervated)
    {
                Console.Clear();
        int row;
        int seat;
        Console.WriteLine("ievadi rindas un vietas nummuru");
        row = Convert.ToInt32(Console.ReadLine());
        seat = Convert.ToInt32(Console.ReadLine());
        if (row > reservations.Length || row < 1)
        {
            return true;
        } else if (seat > reservations[row-1].Length || seat < 1)
        {
            return true;
        }
        
        if (reservations[row-1][seat-1] == 0)
        {
            
            reservations[row-1][seat-1] = 1;
            otherReservations.Add($"Rinda {row}, Vieta {seat}");
                           return false;
        }
        return true;
    }
    
    static void normalProgram ()
    {
                Console.Clear();
                foreach (var text in otherReservations)
                {
                    Console.WriteLine(text);
                }
    }
  static void Main() 
  {
        
        
        
        while (ending == false)
           {
 
                HandleChoice();
                          
           };
    }
  
}
