Жишээ тэстүүд

Оролт
5
1 1 a
2 1 a
1 2 b
2 1 b
2 3 a
Гаралт
1
3
3
4
7

Тэмдэглэл

After the first operation the only good combination was (1, 1, 1). After the second operation new good combinations appeared, (2, 1, 2) and (1, 2, 2). The third operation didn't bring any good combinations. The fourth operation added good combination (1, 3, 3). Finally, the fifth operation resulted in as much as three new good combinations — (1, 4, 4), (2, 3, 4) and (3, 1, 4).