One, Two, Three

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

You are given a sequence of length NN: A_0,A_1,,A_N1A\_0, A\_1, \ldots, A\_{N-1}. It consists of only three kinds of integers: 1,2,31, 2, 3.

A tuple of indices (i,j,k)(i, j, k) is good if 0i<j<k<N0 \le i < j < k < N and it satisfies one of the two following conditions: either A_i=1,,A_j=2,,A_k=3A\_i = 1, \\, A\_j = 2, \\, A\_k = 3 or A_i=3,,A_j=2,,A_k=1A\_i = 3, \\, A\_j = 2, \\, A\_k = 1.

Your goal is find disjoint good tuples, as many of them as possible. A group of tuples is disjoint if no index is present in more than one tuple.

Find the maximum number of disjoint good tuples and print each tuple.

입력

The first line contains an integer NN, the length of the given sequence (1N600,0001 \le N \le 600\\,000).

The next line contains NN integers: A_0,A_1,,A_N1A\_0, A\_1, \ldots, A\_{N-1} (1A_i31 \le A\_i \le 3).

출력

On the first line, print an integer MM, the maximum number of disjoint good tuples.

On the next MM lines, print the tuples themselves. Each of these lines must contains three integers i,j,ki, j, k (0i<j<k<N0 \le i < j < k < N) that describes a good tuple. All the printed tuples must be disjoint. If there are several solutions, print any one of them.