The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value t_{i}:  t_{i} = 1, if the i-th child is good at programming,  t_{i} = 2, if the i-th child is good at maths,  t_{i} = 3, if the i-th child is good at PE 

Each child happens to be good at exactly one of these three subjects.

The Team Scientific Decathlon Olympias requires teams of three students. The school teachers decided that the teams will be composed of three children that are good at different subjects. That is, each team must have one mathematician, one programmer and one sportsman. Of course, each child can be a member of no more than one team.

What is the maximum number of teams that the school will be able to present at the Olympiad? How should the teams be formed for that?


-----Input-----

The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t_1, t_2, ..., t_{n} (1 ≤ t_{i} ≤ 3), where t_{i} describes the skill of the i-th child.


-----Output-----

In the first line output integer w — the largest possible number of teams. 

Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in the order of their appearance in the input. Each child must participate in no more than one team. If there are several solutions, print any of them.

If no teams can be compiled, print the only line with value w equal to 0.


-----Examples-----
Input
7
1 3 1 3 2 1 2

Output
2
3 5 2
6 7 4

Input
4
2 1 1 2

Output
0

Difficulty: interview

Starter code:

Solutions:
n = int(input())
m = list(map(int, input().split()))
a = []
b = []
c = []
for i in range(n):
    if m[i] == 1:
        a.append(i + 1)
    if m[i] == 2:
        b.append(i + 1)
    if m[i] == 3:
        c.append(i + 1)
ans = min(len(a), len(b), len(c))
print(ans)
for i in range(ans):
    print(a[i], b[i], c[i])

n = int(input())
a = list(map(int, input().split()))
k1 = []
k2 = []
k3 = []

for i in range(n):
    if a[i] == 1:
        k1.append(i + 1)
    elif a[i] == 2:
        k2.append(i + 1)
    else:
        k3.append(i + 1)
k = min(len(k1), len(k2), len(k3))
print(k)
for i in range(k):
    print(k1[i], k2[i], k3[i])


t = [[], [], []]
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    t[a[i] - 1].append(i + 1)
m = 1e9
for i in t:
    m = min(len(i), m)
print(m)
for i in range(m):
    print(t[0][i], t[1][i], t[2][i])


n = int(input())
ar = list(map(int, input().split()))
a1 = []
a2 = []
a3 = []
for i in range(len(ar)):
    if ar[i] == 1:
        a1.append(i + 1)
    if ar[i] == 2:
        a2.append(i + 1)
    if ar[i] == 3:
        a3.append(i + 1)
print(min(len(a1), len(a2), len(a3)))
for i in range(min(len(a1), len(a2), len(a3))):
    print(a1[i], a2[i], a3[i])


n = int(input())
t = list(map(int, input().split()))
a = []
b = []
c = []
for i, m in enumerate(t):
    if m == 1:
        a.append(i+1)
    elif m == 2:
        b.append(i+1)
    else:
        c.append(i+1)
w = min([len(a), len(b), len(c)])
print(w)
for i in range(w):
    print(a[i], b[i], c[i])


n=int(input())
t=list(map(int,input().split()))
C=[t.count(i) for i in range(1,4)]
print(min(C))
a=b=c=0
for _ in range(0, min(C)):
  while t[a] != 1: a += 1
  while t[b] != 2: b += 1
  while t[c] != 3: c += 1
  a += 1
  b += 1
  c += 1
  print(a, b, c)
  


n = int(input())
students = [[], [], []]
for i, j in enumerate(map(int, input().split())):
    students[j - 1].append(i + 1)
ans = min(len(students[i]) for i in range(3))
print(ans)
if ans:
    for i in range(ans):
        print(*[students[j][i] for j in range(3)])


n=int(input())

a=[10**9,0,0,0]

L=list(map(int,input().split()))
T=[]
for i in range(n):
    if(L[i]==1):
        T.append([i+1])
ind=0
for i in range(n):
    if(L[i]==2 and ind<len(T)):
        T[ind].append(i+1)
        ind+=1
ind = 0
for i in range(n):
    if(L[i]==3 and ind<len(T) and len(T[ind])==2):
        T[ind].append(i+1)
        ind+=1
print(ind)
for i in range(ind):
    item=T[i]
    print(item[0],item[1],item[2])
    


n = int(input())
subject = list(map(int, input().split()))
pupils = [[], [], []]
for i in range(n):
    pupils[subject[i] - 1].append(i + 1)
print(min(len(pupils[0]), len(pupils[1]), len(pupils[2])))
for i in range(min(len(pupils[0]), len(pupils[1]), len(pupils[2]))):
    print(pupils[0][i], pupils[1][i], pupils[2][i])

n = int(input())
t = [int(s) for s in input().split()]

teams = [[0,0,0] for i in range(n)]
n1,n2,n3=0,0,0
for i in range(n):
    if t[i]==1:
        teams[n1][0]=i+1
        n1 += 1
    elif t[i]==2:
        teams[n2][1]=i+1
        n2+= 1        
    else:
        teams[n3][2]=i+1
        n3+= 1
w = min(n1,n2,n3)
print(w)
if w>0:
    for k in range(w):
        print(' '.join(map(str,teams[k])))
        
        



n = int(input())
t = [int(x) for x in input().split()]
count = min(t.count(1), t.count(2), t.count(3))
print(count)
a = b = c = 0
for i in range(count):
    while t[a] != 1:
        a += 1
    while t[b] != 2:
        b += 1
    while t[c] != 3:
        c += 1
    print(a + 1, b + 1, c + 1)
    a += 1
    b += 1
    c += 1


n = int(input())
a = []
a = list(map(int, input().split()))
t = [0, 0, 0, 0]
ans = [[], [], [], []]
k = 1
for i in a:
    t[i] += 1
    ans[i].append(k)
    k += 1
size = min(min(t[3], t[1]), t[2]);
print(size)
for i in range(size):
    print(ans[3][i], ans[1][i], ans[2][i])


n = int(input())
students = list(map(int, input().split()))

subjects = [list() for i in range(3)]

for i in range(len(students)):
    subjects[students[i] - 1].append(i + 1)

if not all(subjects):
    print(0)
else:
    print(min(len(s) for s in subjects))
    for i in range(min(len(s) for s in subjects)):
        for j in range(3):
            print(subjects[j][i], end=' ')
        print()


n = int(input())
A = [[] for i in range(3)]
X = list(map(int, input().split()))
for i in range(n):
	A[X[i] - 1].append(i + 1)
Min = min(len(A[0]), len(A[1]), len(A[2]))
print(Min)
for i in range(Min):
	print(A[0][i], A[1][i], A[2][i])


n = int(input())
b = [[] for i in range(3)]
a = [int(x) for x in input().split(' ')]
for i in range(n):
    b[a[i] - 1].append(i + 1)
m = min(len(b[0]), len(b[1]), len(b[2]))
print(m)
for i in range(m):
    print(b[0][i], b[1][i], b[2][i], sep=' ')

n=int(input())
lis=input().split()
for i in range(n):
    lis[i]=int(lis[i])
count=[0,0,0]
lis1=[]
lis2=[]
lis3=[]
for i in range(n):
    if lis[i]==1:
        count[0]+=1
        lis1.append(i)
    if lis[i]==2:
        count[1]+=1
        lis2.append(i)
    if lis[i]==3:
        count[2]+=1
        lis3.append(i)
if min(count)==0:
    print(0)
else:
    print(min(count))
    for i in range(min(count)):
        print(lis1[i]+1,lis2[i]+1,lis3[i]+1)


n = int(input())
t = [int(x) for x in input().split()]
cnt = [[0], [0], [0], [0]]
for i in range(n):
    if t[i] == 1:
        cnt[1][0] += 1
        cnt[1].append(i + 1)
    elif t[i] == 2:
        cnt[2][0] += 1
        cnt[2].append(i + 1)
    elif t[i] == 3:
        cnt[3][0] += 1
        cnt[3].append(i + 1)
m = 1000000000000
for i in range(1, len(cnt)):
    m = min(cnt[i][0], m)
print(m)
for j in range(1, m + 1):
    for i in range(1, len(cnt)):    
        print(cnt[i][j], end=' ')
    print()

n = int(input())
ti2 = list(map(str,input().split()))
ti = "".join(ti2)
mis = 0
k = 0
ki = [[0] * 3 for i in range(n//3)]

while mis == 0:
    p = ti.find("1")
    m = ti.find("2")
    f = ti.find("3")
    if p!=-1 and m!=-1 and f!=-1:
        ti2[p] = "4"
        ti2[m] = "4"
        ti2[f] = "4"
        ti = "".join(ti2)
        ki[k][0]=p+1
        ki[k][1]=m+1
        ki[k][2]=f+1
        k+=1
    else:
        mis=1
print(k)
for y in range(k):
    for x in range(3):
        print(ki[y][x],end=" ")
    print()


n = int(input())
x = [int(i) for i in input().split()]
t = [0] * 3
k = 0
for i in range(n):
    for j in range(3):
        if x[i] == (j + 1):
            t[j] += 1
print(min(min(t[1], t[0]), t[2]))
i2 = 0
j = 0
z = [[0] * 3 for i in range(min(min(t[1], t[0]), t[2]))]
for j in range(3):
    while k < min(min(t[1], t[0]), t[2]):
        if x[i2] == (j + 1):
            z[k][j] = i2
            k += 1
        i2 += 1
    i2 = 0
    k = 0
for i in range(min(min(t[1], t[0]), t[2])):
    print(z[i][0] + 1, z[i][1] + 1, z[i][2] + 1)

__author__ = 'Rakshak.R.Hegde'
n = int(input())
t = list(map(int, input().split()))
noOfTeams = min(t.count(1), t.count(2), t.count(3))
for i, strength in enumerate(t):
    t[i]=(i, strength)
ans = ''
for i in range(noOfTeams):
    team = []
    kind = 1
    while kind <= 3:
        for index, val in enumerate(t):
            if val[1] == kind:
                team.append(val[0])
                del t[index]
                kind += 1
                break
    for index in team:
        ans += str(index + 1) + ' '
    ans += '\n'
print(noOfTeams)
print(ans)

i2 = input().split()
i1 = input().split()
i=0
#while i<len(i1):
 #   i1[i]=int(i1[i])
  #  i=i+1
aa=i1.count('1')
b=i1.count('2')
c=i1.count('3')
g=min(aa,b,c)
print (g)
t=0
while t<g:
    r=i1.index('1')
    i1[r]=5
    r2=i1.index('2')
    i1[r2]=5
    r3=i1.index('3')
    
    i1[r3]=5
    print (r+1,r2+1,r3+1)
    t=t+1

n = int(input())
t = list(map(int, input().split()))
a = [[] for i in range(3)]
for i, m in enumerate(t):
    a[m-1].append(i+1)
w = min(list(map(len, a)))
print(w)
for i in range(w):
    print(a[0][i], a[1][i], a[2][i])


n=int(input())
ar=list(map(int,input().split()))
k=min(ar.count(1),ar.count(2))
k=min(k,ar.count(3))
if k==0:
    print('0')
    return
z=[]
q=0
for x in range(n):
    if ar[x]==1:
        z.append([x+1])
        q+=1
    if q==k:
        break
q=0
for x in range(n):
    if ar[x]==2:
        z[q].append(x+1)
        q+=1
    if q==k:
        break
q=0
for x in range(n):
    if ar[x]==3:
        z[q].append(x+1)
        q+=1
    if q==k:
        break
print(k)
for x in z:
    print(' '.join(map(str,x)))


a = int(input())
studsx = list(map(int, input().split(' ')))
studs = [(studsx[x], x + 1) for x in range(a)]
i = [x for x in studs if x[0] == 1]
j = [y for y in studs if y[0] == 2]
k = [z for z in studs if z[0] == 3]
pairs = min(len(i), len(j), len(k))
print(pairs)
for l in range(pairs):
    print(str(i[l][1]) + ' ' + str(j[l][1]) + ' ' + str(k[l][1]))


n = input();
t = input().split()
i1 = []
i2 = []
i3 = []
for i in range(len(t)):
   if t[i]=="1":
      i1.append(i)
   if t[i]=="2":
      i2.append(i)
   if t[i]=="3":
      i3.append(i)
num = min(len(i1),len(i2),len(i3))
print(num)
for i in range(num):
   print(str(i1[i]+1)+" "+str(i2[i]+1)+" "+str(i3[i]+1))