eolymp
bolt
Try our new interface for solving problems

Teams

There are \textbf{3·N} same year students studying in two specializations - mathematics (\textbf{M}) and programming (\textbf{P}). Let's call students of the first specialization mathematicians and students of the second specialization programmers. There are several groups of each specialization. The number of groups is the same for both specializations. The number of students in each group is greater than or equal to three. The students are loaded much by the studies, that's why they can meet each other only during classes. They have separate classes for each group except physical education (P. E.). P. E. classes are held for pairs of groups of different specialization and each group share its P. E. classes with only one other group. All groups attend P. E. classes. All the students are very responsible and attend all the classes. When two students meet each other at the same class, they become familiar. There is a head in each group. All the group heads attend head meetings, where all of them meet each other and become familiar. You should form \textbf{N} teams consisting of three students each so that each student is used in exactly one group. There should be at least one mathematician and at least one programmer in each team. All the members of one team should be familiar to each other. \InputFile The first line contains \textbf{2} integers \textbf{K} and \textbf{M} (\textbf{1} ≤ \textbf{K}, \textbf{M} ≤ \textbf{1000}, \textbf{K = 3·N}) - the total number of students and the number of pairs of familiar students correspondingly. The second line contains \textbf{K} characters '\textbf{M}' or '\textbf{P}', \textbf{i}-th character describes \textbf{i}-th student's specialization. The following \textbf{M} lines define pairs of familiar students. It's guaranteed that the input describes student's specializations and relationships that do not contradict the problem statement. \OutputFile The first line should contain \textbf{Yes} or \textbf{No} depending on the possibility to form \textbf{N} teams. If such possibility exists, the following \textbf{N} lines should contain numbers of the students of each team, three numbers in each line. If there are several solutions, output any.
Time limit 2 seconds
Memory limit 256 MiB
Input example #1
12 34
MMPPPMMMMPPP
1 2
1 3
1 4
1 5
1 6
1 7
1 10
2 3
2 4
2 5
2 6
3 4
3 5
3 6
4 5
4 6
4 7
4 10
5 6
7 8
7 9
7 10
7 11
7 12
8 9
8 10
8 11
8 12
9 10
9 11
9 12
10 11
10 12
11 12
Output example #1
Yes
4 5 1
6 2 3
10 12 7
9 8 11