Every February, 10th-grade students at the school select their optional subjects for the next academic year.
Each of the students (numbered from to ) submits a list of subjects they would like to attend. Students must choose at least one and at most five subjects from a total of available subjects. The subjects are numbered from to (inclusive).
Your task is to help the schedule creator determine which pairs of subjects can be held simultaneously. A pair of subjects can be scheduled at the same time if no student has chosen both subjects. Note that the pair is considered the same as .
Input data
The first line contains two integers and .
Each of the next lines contains an integer , indicating the number of subjects chosen by student , followed by integers , denoting the chosen subjects.
Output data
In the first line you need to write an integer , indicating the number of pairs.
In each of the next lines you should write two integers, denoting a pair of subjects that can be held simultaneously. You can write the pairs in arbitrary order.
Constraints and clarifications
- .
- .
- for each .
- for each and .
# | Points | Constraints |
---|---|---|
1 | 0 | Examples |
2 | 30 | . |
3 | 20 | A subject may be selected by at most student. |
4 | 50 | No additional constraints. |
Example 1
stdin
4 5
4 1 2 3 4
1 2
2 1 5
3 2 3 1
stdout
3
2 5
3 5
5 4
Explanation
In the first sample case:
- Subjects are selected by students: .
- Subjects are selected by students: .
- Subjects is selected by student: .
- Subjects is selected by student: .
- Subjects are selected by students: .
- Subjects is selected by student: .
- Subjects is selected by student: .
Any other pair of subjects can be held at the same time.
Example 2
stdin
5 8
4 1 2 4 6
4 3 5 7 8
5 4 7 8 2 3
4 2 7 1 4
2 3 4
stdout
9
1 5
6 5
1 3
8 1
2 5
3 6
5 4
6 7
6 8