#K14496. Organize Aisles
Organize Aisles
Organize Aisles
You are given an integer matrix representing product types arranged in several aisles. Each row of the matrix represents an aisle with a fixed number of shelves, and each element in the row denotes the type of product on that shelf.
Your task is to determine if every aisle contains only unique product types. In other words, for each aisle, no product type is repeated. If all aisles satisfy this condition, print Possible
; otherwise, print Impossible
.
The mathematical condition for an aisle with m shelves is:
[ \forall, \text{row } r,; |{ r_j : 1 \le j \le m }| = m ]
If the above condition holds for every aisle, the arrangement is valid.
inputFormat
The first line of input contains two integers n and m, where n is the number of aisles and m is the number of shelves per aisle. The following n lines each contain m integers separated by spaces, representing the product types for each aisle.
outputFormat
Output a single line: Possible
if every aisle contains distinct product types, or Impossible
otherwise.
2 3
1 2 0
0 1 2
Possible