#C7104. Theater Reservation Scheduling

    ID: 50939 Type: Default 1000ms 256MiB

Theater Reservation Scheduling

Theater Reservation Scheduling

You are given a theater with \(r\) rows and \(c\) seats per row. There are \(n\) reservation requests. Each reservation is described by three integers: the row number, the starting seat position, and the number of consecutive seats requested. All seats are numbered starting at 1.

A reservation is valid if the block of requested seats lies completely within the row (i.e. if the reservation starts at seat \(s\) and requests \(k\) seats, then it must hold that \(s + k - 1 \le c\)) and if none of the seats in that block have already been reserved. If a reservation request does not satisfy these conditions, then it is not possible to accommodate all requests.

Your task is to determine whether it is possible to fulfill all reservation requests. Output Possible if you can accommodate every reservation, otherwise output Impossible.

inputFormat

The input is given via standard input and consists of:

  • The first line contains three integers \(r\), \(c\), and \(n\) (the number of rows, the number of seats per row, and the number of reservations).
  • The next \(n\) lines each contain three integers: row, start_seat, and num_seats, describing a reservation request.

outputFormat

Output a single line to standard output: Possible if all reservations can be accommodated, or Impossible otherwise.

## sample
3 5 2
1 2 3
2 1 4
Possible

</p>