#C12764. Cinema Ticket Booking System

    ID: 42227 Type: Default 1000ms 256MiB

Cinema Ticket Booking System

Cinema Ticket Booking System

You are required to implement a cinema ticket booking system. The cinema is arranged in an \( n \times m \) grid where each cell represents a seat. Each seat can be either available or booked. Initially, all seats are available.

Your program should process several queries:

  • book row seat: If the seat is available, book it and output "Seat booked successfully." If the seat is already booked, output "Seat already booked." If the seat coordinates are out of bounds, output "Invalid seat selection."
  • cancel row seat: If the seat is booked, cancel the booking and output "Booking cancelled successfully." If the seat is not booked, output "Seat not booked yet." If the coordinates are invalid, output "Invalid seat selection."
  • check row seat: If the seat coordinates are valid, output "True" if the seat is available, or "False" if the seat is booked. For invalid coordinates, output "Invalid seat selection."

Note: The rows and seats are zero-indexed. That is, a cinema with dimensions 5 x 5 has valid seat indices from 0 to 4.

inputFormat

The first line contains two integers \( n \) and \( m \) denoting the number of rows and columns respectively.

The second line contains an integer \( q \) representing the number of queries.

Each of the following \( q \) lines contains a query in one of the following formats:

  • book row seat
  • cancel row seat
  • check row seat

outputFormat

For each query, output a single line containing the result of the corresponding operation as described in the problem statement.

## sample
5 5
5
book 2 3
book 2 3
book 5 5
cancel 2 3
check 2 3
Seat booked successfully.

Seat already booked. Invalid seat selection. Booking cancelled successfully. True

</p>