#CCBCHBAHAI0000112. Team Olympiad
Team Olympiad
Team Olympiad
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem
Each student has type . A team needs one student of every type, and no student can be reused. If is the count of type , the maximum team count is . For deterministic judging, list indices of each type in increasing order and make team from the -th index of types 1, 2, and 3, in that order.
Input
The first line contains . The second line contains .
Output
Print , then deterministic triples. If , print only 0.
Subtask
Subtask 1 (20 points): .
Subtask 2 (30 points): .
Subtask 3 (50 points): .
Example
Input
7
1 3 1 3 2 1 2
Output
2
1 5 2
3 7 4
Explanation
The type-index lists are (1,3,6), (5,7), and (2,4), so two teams are produced.