Task
Given a number and a matrix of dimensions , we define a set as closed if it is non-empty and for any two elements and in the set (not necessarily distinct!), is also in the set. The task is to display all subsets of the set that are closed and do not strictly contain any other closed set.
Input data
The first line contains the number , followed by the matrix on the subsequent lines.
Output data
, the number of such sets, followed by each set on a new line, sorted in ascending order by the minimum element, and in case of a tie, by size. Additionally, the individual sets should also be sorted in increasing order.
Constraints and clarifications
- The values in matrix are natural numbers between and
- A set strictly contains another set if every element of belongs to and
Subtasks
- For points,
- For the remaining points, there are no additional constraints.
- It can be proven that the required sets can be uniquely sorted according to the given criteria.
- It can be proven that, under the given conditions, the sum of the sizes of the required sets does not exceed
Example 1
stdin
5
5 4 1 5 4
5 1 2 4 4
5 3 3 3 2
4 5 5 2 5
2 5 4 4 2
stdout
2
1 2 4 5
3
Explanation
The sets and do not strictly contain any other closed set. Note that we have not displayed the set although it is closed because it contains the closed set .