birthday balloons
Problem
Mishka had n children at his birthday party. Each child received m balloons as a gift. The color of the ball is conditionally given by some natural number.
Determine if all children have balls of the same color. If so, print the numbers of these colors in ascending order, otherwise print -1.
Input
The first line contains numbers
n
(
\(0 < n <= 100\)) and
m
(
\(1 <= m <= 50\)). Then there are
n
lines with
m
numbers in each - numbers of colors of balloons of the i-th child. Color is encoded by a natural number not exceeding 20.
Imprint
Print on the screen, in ascending order, the numbers of colors that match all the guys, if there are none, print
-1
.
Examples
# |
Input |
Output |
1 |
5 6
1 4 1 3 5 5
3 5 1 4 4 4
5 2 3 1 1 1
4 2 5 4 1 5
5 1 3 2 3 5
| 1 5 |
2 |
2 2
1 2
3 4 |
-1 |