LogiQuest

357. Cinema Seat Booking

MediumSimulation

A hall has r rows of c seats. Each request asks for k adjacent seats in one row: allocate the first such block scanning rows from 1 and seats from the left, and print row startSeat, or FULL if impossible.

Input format

Line 1: r c q Next q lines: k

Output format

One line per request.

Example 1

Input

2 5 4
3
3
2
4

Output

1 1
2 1
1 4
FULL

Example 2

Input

1 3 2
4
3

Output

FULL
1 1

Constraints

1 ≤ r, c ≤ 100 1 ≤ q ≤ 1000

Read input from standard input and print the answer to standard output. Your code is judged against 3 test cases, most of them hidden.

Loading the MyLoginn IDE…