#C10903. Table Placement in a Garden
Table Placement in a Garden
Table Placement in a Garden
You are given a rectangular garden of dimensions \(H \times W\). In this garden, you need to place \(N\) rectangular tables. Each table has specified dimensions \(h_i \times w_i\) for \(i=1,2,...,N\). The tables must be placed with their sides parallel to the sides of the garden, and they cannot overlap or extend outside the garden boundaries.
Formally, given a garden of height \(H\) and width \(W\), and \(N\) tables with dimensions \(h_i\) and \(w_i\), determine whether it is possible to place all the tables in the garden without overlapping. Output possible
if there exists an arrangement that satisfies these conditions; otherwise, output impossible
.
inputFormat
The input is read from standard input and has the following format:
H W N h_1 w_1 h_2 w_2 ... h_N w_N
Where:
- H (\(1 \le H \le 100\)) is the height of the garden.
- W (\(1 \le W \le 100\)) is the width of the garden.
- N (\(1 \le N \le 10\)) is the number of tables.
- Each of the next \(N\) lines contains two integers \(h_i\) and \(w_i\), the height and width of the \(i\)-th table.
outputFormat
Output a single string to standard output: possible
if it is possible to place all tables in the garden without overlapping; otherwise, output impossible
.
3 3 1
2 2
possible