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

Source: codeforces | Difficulty: EASY
Tags: Sorting

Implementation

Greedy algorithms


Solutions:
n = int(input())
R = list(map(int, input().split()))
a = R.count(1)
b = R.count(2)
c = R.count(3)
if a * b * c > 0:
	print(min(a, b, c))
	while a > 0 and b > 0 and (c > 0):
		m = R.index(1)
		print(m + 1, end=' ')
		R[m] = 0
		a -= 1
		m = R.index(2)
		print(m + 1, end=' ')
		R[m] = 0
		b -= 1
		m = R.index(3)
		print(m + 1, end=' ')
		R[m] = 0
		c -= 1
		print()
else:
	print(0)


n = int(input())
s = [int(x) for x in input().split()]
pr = s.count(1)
pe = s.count(2)
ma = s.count(3)
w = min(pr, pe, ma)
print(w)
if w != 0:
	for i in range(w):
		for j in range(1, 4):
			p = s.index(j)
			print(p + 1)
			s[p] = 0


import sys
import io

def run(test, res):
	x = io.StringIO()
	with io.StringIO(test) as sys.stdin:
		with x as sys.stdout:
			work()
			z = x.getvalue().strip()
	sys.stdout = sys.__stdout__
	print(z == test)
	print(res)
	print(z)

def work():
	n = int(input())
	l = list(map(int, input().split()))
	a = [[], [], [], []]
	for (i, x) in enumerate(l):
		a[x].append(i + 1)
	z = min(len(a[1]), len(a[2]), len(a[3]))
	print(z)
	if z > 0:
		for i in range(0, z):
			print(a[1][i], a[2][i], a[3][i])

def test():
	run('7\n1 3 1 3 2 1 2\n', '-1')
	run('4\n2 1 1 2', '0')
if len(sys.argv) > 1:
	test()
else:
	work()


import operator as op
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import reduce
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, gcd, hypot, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def def_value():
	return []
n = inp()
a = inlist()
count = defaultdict(def_value)
mp = defaultdict(def_value)
for i in range(n):
	count[a[i]] += [i + 1]
if len(count) < 3:
	print(0)
	sys.exit()
mn = min(count.values(), key=lambda d: len(d))
mn = len(mn)
print(mn)
for i in range(mn):
	for k in count.values():
		print(k[i], end=' ')
	print()


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))


import sys
inp = sys.stdin.readline
n = int(inp())
a = list(map(int, inp().split()))
pos = dict()
pos[1] = list()
pos[2] = list()
pos[3] = list()
for (i, x) in enumerate(a):
	pos[x].append(i + 1)
print(min(len(pos[1]), len(pos[2]), len(pos[3])))
for (x, y, z) in zip(pos[1], pos[2], pos[3]):
	print(x, y, z)


n = int(input())
x = list(map(int, input().split(' ')))
a = [[], [], []]
aa = [0, 0, 0]
for i in range(n):
	a[x[i] - 1].append(i + 1)
	aa[x[i] - 1] += 1
mini = min(aa)
print(mini)
if mini:
	for i in range(mini):
		print(a[0][i], a[1][i], a[2][i])


x = int(input())
f = []
mat = []
v = []
a = list(map(str, input().split()))
hg = 0
for i in range(1, x + 1):
	if a[i - 1] == '1':
		f.append(i)
	elif a[i - 1] == '2':
		mat.append(i)
	else:
		v.append(i)
if len(f) == 0 or len(mat) == 0 or len(v) == 0:
	print(0)
	hg = 5
if hg == 0:
	min = 100000
	if len(f) < min:
		min = len(f)
	if len(mat) < min:
		min = len(mat)
	if len(v) < min:
		min = len(v)
	print(min)
	for k in range(min):
		print(f[k], mat[k], v[k])


y = int(input())
x = list(map(int, input().split()))
a = min(x.count(3), x.count(2), x.count(1))
print(a)
for i in range(a):
	p = 0
	q = 0
	r = 0
	for j in range(y):
		if x[j] == 1:
			x[j] = 0
			p = j + 1
			break
	for j in range(y):
		if x[j] == 2:
			x[j] = 0
			q = j + 1
			break
	for j in range(y):
		if x[j] == 3:
			x[j] = 0
			r = j + 1
			break
	print(p, q, r)


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])


n = int(input())
l = list(map(int, input().split()))
(a, b, c, d, e, f) = (0, 0, 0, [], [], [])
for i in range(n):
	if l[i] == 1:
		a += 1
		d.append(i + 1)
	elif l[i] == 2:
		b += 1
		e.append(i + 1)
	else:
		c += 1
		f.append(i + 1)
m = min(a, b, c)
print(m)
for i in range(m):
	print(d[i], e[i], f[i])


n = int(input())
A = []
B = []
C = []
s = input()
f = list(map(int, s.split()))
for i in range(len(f)):
	if f[i] == 1:
		A.append(i + 1)
	elif f[i] == 2:
		B.append(i + 1)
	elif f[i] == 3:
		C.append(i + 1)
h = [len(A), len(B), len(C)]
h.sort()
print(h[0])
if h[0] == len(A) and h[0] > 0:
	for i in range(len(A)):
		print(A[i], B[i], C[i])
elif h[0] == len(B) and h[0] > 0:
	for i in range(len(B)):
		print(A[i], B[i], C[i])
elif h[0] == len(C) and h[0] > 0:
	for i in range(len(C)):
		print(A[i], B[i], C[i])


from collections import deque

def main():
	n = int(input())
	children = list(map(int, input().split()))
	q1 = deque()
	q2 = deque()
	q3 = deque()
	for i in range(n):
		skill = children[i]
		child_idx = i + 1
		if skill == 1:
			q1.append(child_idx)
		elif skill == 2:
			q2.append(child_idx)
		else:
			q3.append(child_idx)
	min_q_len = min(len(q1), len(q2), len(q3))
	if min_q_len > 0:
		print(min_q_len)
		for i in range(min_q_len):
			print(str(q1.pop()) + ' ' + str(q2.pop()) + ' ' + str(q3.pop()))
	else:
		print(0)
main()


n = int(input())
s = list(map(int, input().split()))
l3 = []
l2 = []
l1 = []
for i in range(n):
	if s[i] == 3:
		l3.append(i + 1)
	elif s[i] == 2:
		l2.append(i + 1)
	elif s[i] == 1:
		l1.append(i + 1)
w = min(len(l1), len(l2), len(l3))
print(w)
for i in range(w):
	print(l1[i], l2[i], l3[i])


n = int(input())
a = list(map(int, input().split()))
x = min(a.count(1), a.count(2), a.count(3))
print(x)
while x > 0:
	l = [a.index(1) + 1, a.index(2) + 1, a.index(3) + 1]
	a[a.index(1)] = -1
	a[a.index(2)] = -1
	a[a.index(3)] = -1
	x -= 1
	print(*l)


n = int(input())
l = [int(i) for i in input().split()]
d = {1: [], 2: [], 3: []}
for i in range(n):
	d[l[i]].append(i + 1)
w = min([len(i) for i in d.values()])
print(w)
for i in range(w):
	print(d[1][i], d[2][i], d[3][i])


n = int(input())
stud = list(map(int, input().split()))
n1 = stud.count(1)
n2 = stud.count(2)
n3 = stud.count(3)
if n1 > 0 and n2 > 0 and (n3 > 0):
	value = min(n1, n2, n3)
	nx = [[i + 1 for (i, x) in enumerate(stud) if x == 1], [i + 1 for (i, x) in enumerate(stud) if x == 2], [i + 1 for (i, x) in enumerate(stud) if x == 3]]
	print(value)
	for k in range(value):
		tmp = []
		for j in range(3):
			tmp.append(nx[j][k])
		print(*tmp)
else:
	print(0)


n = int(input())
oset = []
tset = []
thset = []
lst = list(map(int, input().split()))
for i in range(len(lst)):
	if lst[i] == 1:
		oset.append(i + 1)
	elif lst[i] == 2:
		tset.append(i + 1)
	else:
		thset.append(i + 1)
l = min(len(oset), len(thset), len(tset))
print(l)
for i in range(l):
	f = oset[i]
	s = tset[i]
	th = thset[i]
	print(f, s, th)


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()


import sys
n = int(input())
students = list(map(int, sys.stdin.readline().split()))
arr = [[] for i in range(4)]
for i in range(n):
	arr[students[i]].append(i + 1)
g = n
for i in range(1, 4):
	if g > len(arr[i]):
		g = len(arr[i])
print(g)
for i in range(g):
	for j in range(1, 4):
		print(arr[j][i], end=' ')
	print('')


n = input()
t = list(map(int, input().split()))
b = [0] + t
team = 0
num1 = t.count(1)
num2 = t.count(2)
num3 = t.count(3)
t1 = []
t2 = []
t3 = []
if num1 != 0 and num2 != 0 and (num3 != 0):
	team = min(num1, num2, num3)
for i in range(len(b)):
	if b[i] == 1:
		t1.append(i)
	elif b[i] == 2:
		t2.append(i)
	elif b[i] == 3:
		t3.append(i)
if team >= 1:
	teams = [[] for i in range(team)]
	for i in range(len(teams)):
		teams[i].append(t1[i])
		teams[i].append(t2[i])
		teams[i].append(t3[i])
	print(team)
	for i in teams:
		print(i[0], i[1], i[2])
elif team < 1:
	print(0)


n = int(input())
lis = [int(i) for i in input().split()]
(d1, d2, d3, m) = (0, 0, 0, 0)
(index1, index2, index3) = ([], [], [])
for j in lis:
	m += 1
	if j == 1:
		d1 += 1
		index1.append(m)
	if j == 2:
		d2 += 1
		index2.append(m)
	if j == 3:
		d3 += 1
		index3.append(m)
print(min(d1, d2, d3))
for k in range(min(d1, d2, d3)):
	print(index1[k], index2[k], index3[k])


n = int(input())
x = [[], [], []]
index = 1
for i in map(int, input().split()):
	x[i - 1].append(index)
	index += 1
ans = min((len(l) for l in x))
print(ans)
for i in range(ans):
	print(x[0][i], x[1][i], x[2][i])


n = int(input())
t = map(int, input().split())
t = list(t)
p1 = t.count(1)
m2 = t.count(2)
s3 = t.count(3)
w = [p1, m2, s3]
if min(w) == 0:
	print(0)
else:
	print(min(w))
for i in range(min(w)):
	a = t.index(1)
	b = t.index(2)
	c = t.index(3)
	print(a + 1, b + 1, c + 1)
	t.remove(1)
	t.insert(a, 0)
	t.remove(2)
	t.insert(b, 0)
	t.remove(3)
	t.insert(c, 0)


student = int(input())
subjects = [int(i) for i in input().split()]
progammers = 0
maths = 0
Pe = 0
position_programmers = []
position_maths = []
position_pe = []
for i in range(len(subjects)):
	if subjects[i] == 1:
		progammers += 1
		position_programmers.append(i + 1)
	if subjects[i] == 2:
		maths += 1
		position_maths.append(i + 1)
	if subjects[i] == 3:
		Pe += 1
		position_pe.append(i + 1)
output = 0
output = min(len(position_programmers), len(position_maths), len(position_pe))
print(output)
for i in range(output):
	print(position_programmers[i], position_maths[i], position_pe[i])


value = int(input())
values = input()
values = values.split()
values = [int(i) for i in values]
a = min(values.count(1), values.count(2), values.count(3))
print(a)
one = list()
two = list()
three = list()
for i in range(len(values)):
	if values[i] == 1:
		one.append(i + 1)
	if values[i] == 2:
		two.append(i + 1)
	if values[i] == 3:
		three.append(i + 1)
for i in range(a):
	print(one[i], two[i], three[i], end=' ')
	print()


w = int(input())
skills = [int(x) for x in input().split()]
(teams, p, m, P) = (0, [], [], [])
for i in range(w):
	if skills[i] == 1:
		p.append(i + 1)
	if skills[i] == 2:
		m.append(i + 1)
	if skills[i] == 3:
		P.append(i + 1)
teams = min(len(p), len(m), len(P))
print(teams)
for i in range(teams):
	print(str(p[i]) + ' ' + str(m[i]) + ' ' + str(P[i]))


n = int(input())
a = list(map(int, input().split()))
num = [0] * 3
for x in a:
	num[x - 1] += 1
print(min(num))
for x in range(min(num)):
	for y in range(3):
		temp = a.index(y + 1)
		print(temp + 1, end=' ')
		a[temp] = None


def min(a, b):
	if a > b:
		return b
	else:
		return a

def minn(a, b, c):
	return min(a, min(b, c))
n = input()
t = [eval(i) for i in input().split()]
a = []
b = []
c = []
for i in range(len(t)):
	if t[i] == 1:
		a.append(i + 1)
	elif t[i] == 2:
		b.append(i + 1)
	elif t[i] == 3:
		c.append(i + 1)
ans = minn(len(a), len(b), len(c))
print(ans)
for i in range(ans):
	print(a[i], b[i], c[i], sep=' ')


n = int(input())
s = (int, input().split())
s = list(s)
s[0] = s[1]
sp = s[0]
a = b = c = 0
team = []
od = []
dv = []
tr = []
for i in range(len(sp)):
	if sp[i] == '1':
		a += 1
	elif sp[i] == '2':
		b += 1
	else:
		c += 1
if a != 0 and b != 0 and (c != 0):
	w = min(a, b, c)
else:
	w = 0
for j in range(len(sp)):
	if sp[j] == '1':
		od.append(j + 1)
	elif sp[j] == '2':
		dv.append(j + 1)
	else:
		tr.append(j + 1)
print(w)
for k in range(w):
	team.append(od[k])
	team.append(dv[k])
	team.append(tr[k])
	print(*team)
	team = []


t = int(input())
stud = input()
stud = stud.split(' ')
typ = []
f = len([x for x in stud if x == '1'])
s = len([x for x in stud if x == '2'])
th = len([x for x in stud if x == '3'])
typ.append(f)
typ.append(s)
typ.append(th)
teams = min(typ)
print(teams)
f_place = []
s_place = []
th_place = []
for x in range(0, t):
	if stud[x] == '1':
		if len(f_place) != teams:
			f_place.append(x)
	elif stud[x] == '2':
		if len(s_place) != teams:
			s_place.append(x)
	elif len(th_place) != teams:
		th_place.append(x)
for i in range(0, teams):
	print(f_place[i] + 1, s_place[i] + 1, th_place[i] + 1)


n = input()
n = int(n)
ability = [int(x) for x in input().split()]
s1 = []
s2 = []
s3 = []
for i in range(len(ability)):
	if ability[i] == 1:
		s1.append(i + 1)
	elif ability[i] == 2:
		s2.append(i + 1)
	else:
		s3.append(i + 1)
teamnum = min(len(s1), len(s2), len(s3))
print(teamnum)
for i in range(teamnum):
	comb = str(s1[i]) + ' ' + str(s2[i]) + ' ' + str(s3[i])
	print(comb)


from collections import Counter
n = int(input())
a = [int(x) for x in input().split()]
c = [0] * 3
for x in a:
	c[x - 1] += 1
w = min(c)
if w == 0:
	print(0)
else:
	h = [[] for _ in range(3)]
	for (i, x) in enumerate(a):
		h[x - 1].append(i + 1)
	print(w)
	for i in range(w):
		for j in range(3):
			print(f'{h[j][i]} ', end='')
		print()


n = int(input())
tab = []
s = input()
tab = s.split()
sh = ''
for i in range(0, len(tab)):
	sh = sh + tab[i]

def calculate(sh, s):
	return sh.count(s)
nb1 = 0
nb2 = 0
nb3 = 0
nb1 = calculate(sh, '1')
nb2 = calculate(sh, '2')
nb3 = calculate(sh, '3')
minu = min([nb1, nb2, nb3])

def find(number):
	global sh
	ind = sh.find(number)
	sh = sh.replace(number, '*', 1)
	return ind + 1
if minu != 0:
	print(minu)
	for i in range(minu):
		ind1 = find('1')
		print(ind1, end=' ')
		ind2 = find('2')
		print(ind2, end=' ')
		ind3 = find('3')
		print(ind3)
else:
	print(0)


input()
t = list(input().split())
n = min(t.count('1'), t.count('2'), t.count('3'))
print(n)
one = [i + 1 for (i, a) in enumerate(t) if a == '1']
two = [i + 1 for (i, a) in enumerate(t) if a == '2']
three = [i + 1 for (i, a) in enumerate(t) if a == '3']
for (i, j, k) in zip(one, two, three):
	print(i, j, k)


import sys
import math

def main():
	n = int(sys.stdin.readline().strip())
	arr = list(map(int, sys.stdin.readline().strip().split()))
	t1 = arr.count(1)
	t2 = arr.count(2)
	t3 = arr.count(3)
	tm = min(t1, t2, t3)
	print(tm)
	if tm == 0:
		return 0
	for i in range(tm):
		team = ''
		k = arr.index(1)
		arr[k] = 0
		team = team + str(k + 1) + ' '
		k = arr.index(2)
		arr[k] = 0
		team = team + str(k + 1) + ' '
		k = arr.index(3)
		team = team + str(k + 1)
		arr[k] = 0
		print(team)
main()


t = int(input())
s = input().split()
d = {1: [], 2: [], 3: []}
for i in range(t):
	x = int(s[i])
	d[x].append(i + 1)
m = len(min(d.values(), key=len))
print(m)
for i in range(m):
	print('{} {} {}'.format(d[1][i], d[2][i], d[3][i]))


n = int(input())
skills = list(map(int, input().split()))
subjects = [list() for i in range(3)]
for i in range(len(skills)):
	subjects[skills[i] - 1].append(i + 1)
teams = min((len(i) for i in subjects))
if teams == 0:
	print(0)
else:
	print(teams)
	for i in range(teams):
		print(subjects[0][i], subjects[1][i], subjects[2][i])


_ = input()
list_in = input().strip().split(' ')
(list_1, list_2, list_3) = ([], [], [])
for x in range(len(list_in)):
	if list_in[x] == '1':
		list_1.append(x)
	elif list_in[x] == '2':
		list_2.append(x)
	else:
		list_3.append(x)
cnt = min(len(list_1), len(list_2), len(list_3))
print(cnt)
for x in range(cnt):
	print(list_1[x] + 1, list_2[x] + 1, list_3[x] + 1)


n = int(input())
array = list(map(int, input().rstrip().split()))
array = list(enumerate(array, 1))
num1 = [p for p in array if p[1] == 1]
num2 = [p for p in array if p[1] == 2]
num3 = [p for p in array if p[1] == 3]
res = min(len(num1), len(num2), len(num3))
if res == 0:
	print(res)
	exit()
else:
	print(res)
	for i in range(res):
		print(num1[i][0], num2[i][0], num3[i][0])


n = int(input())
li = list(map(int, input().split()))
(m, p, pe) = (li.count(1), li.count(2), li.count(3))
print(min(m, p, pe))
for i in range(min(m, p, pe)):
	print(li.index(1) + 1, li.index(2) + 1, li.index(3) + 1)
	li[li.index(1)] = 0
	li[li.index(2)] = 0
	li[li.index(3)] = 0


import random
n = int(input(''))
index1 = []
index2 = []
index3 = []
no = input('')
c1 = 0
c2 = 0
c3 = 0
list1 = no.split(' ')
s = 0
for i in list1:
	s += 1
	if i == '1':
		index1.append(s)
		c1 += 1
	elif i == '2':
		index2.append(s)
		c2 += 1
	else:
		index3.append(s)
		c3 += 1
d = min(c1, c2, c3)
l1 = len(index1)
l2 = len(index2)
l3 = len(index3)
if d > 0:
	print(d)
	for j in range(d):
		data1 = index1[l1 - d + j]
		data2 = index2[l2 - d + j]
		data3 = index3[l3 - d + j]
		print(data1, data2, data3)
else:
	print('0')


n = int(input())
str1 = input().split()
lst1 = list()
lst2 = list()
lst3 = list()
for i in range(n):
	if str1[i] == '1':
		lst1.append(int(i) + 1)
	if str1[i] == '2':
		lst2.append(int(i) + 1)
	if str1[i] == '3':
		lst3.append(int(i) + 1)
lst4 = [len(lst1), len(lst2), len(lst3)]
m = min(lst4)
lst5 = list()
for i in range(m):
	lst5.append(str(lst1[i]))
	lst5.append(str(lst2[i]))
	lst5.append(str(lst3[i]))
print(m)
for i in range(m):
	print(' '.join(lst5[i * 3:(i + 1) * 3]))


n = int(input())
arr1 = []
arr2 = []
arr3 = []
b = list(map(int, input().split()))
for i in range(len(b)):
	if b[i] == 1:
		arr1.append(i + 1)
	if b[i] == 2:
		arr2.append(i + 1)
	if b[i] == 3:
		arr3.append(i + 1)
ans = min(len(arr1), len(arr2), len(arr3))
if ans == 0:
	print(0)
else:
	print(ans)
	for i in range(ans):
		print(arr1.pop(), ' ', arr2.pop(), ' ', arr3.pop())


l = [[], [], []]
q = int(input())
for (i, t) in zip(range(1, q + 1), map(int, input().split())):
	l[t - 1].append(i)
print(min([len(t) for t in l]))
for (a, b, c) in zip((n for n in l[0]), (n for n in l[1]), (n for n in l[2])):
	print(a, b, c)


n = int(input())
t = list(map(int, input().rstrip().split()))
a1 = [[], [], []]
for i in range(n):
	if t[i] == 1:
		a1[0].append(i + 1)
	elif t[i] == 2:
		a1[1].append(i + 1)
	else:
		a1[2].append(i + 1)
c = min(len(a1[0]), len(a1[1]), len(a1[2]))
print(c)
if c > 0:
	for j in range(c):
		print(a1[0][j], a1[1][j], a1[2][j])


n = int(input())
l = list(map(lambda x: int(x) - 1, input().split()))
freq = [list() for _ in range(3)]
possible = [False] * 3
for (index, val) in enumerate(l):
	freq[val].append(index + 1)
	possible[val] = True
if sum(possible) != 3:
	print(0)
else:
	min_val = 10 ** 9
	for i in range(3):
		if len(freq[i]) < min_val:
			min_val = len(freq[i])
	print(min_val)
	for i in range(min_val):
		print(freq[0][i], freq[1][i], freq[2][i])


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())
arr = list(map(int, input().split()))
one = []
two = []
three = []
o = 0
t = 0
th = 0
for i in range(n):
	if arr[i] == 1:
		one.append(i)
		o = o + 1
	elif arr[i] == 2:
		two.append(i)
		t = t + 1
	elif arr[i] == 3:
		three.append(i)
		th = th + 1
val = min(len(one), len(two), len(three))
print(val)
if val > 0:
	for i in range(val):
		print(one[i] + 1, two[i] + 1, three[i] + 1)


n = int(input())
List = [int(j) for j in input().split(' ')]
count_1 = 0
count_2 = 0
count_3 = 0
List_1 = []
List_2 = []
List_3 = []
for i in range(n):
	if List[i] == 1:
		count_1 += 1
	elif List[i] == 2:
		count_2 += 1
	elif List[i] == 3:
		count_3 += 1
print(min(count_1, count_2, count_3))
m = min(count_1, count_2, count_3) > 0
if m > 0:
	for k in range(m):
		for i in range(n):
			if List[i] == 1:
				List_1.append(i + 1)
			elif List[i] == 2:
				List_2.append(i + 1)
			elif List[i] == 3:
				List_3.append(i + 1)
g = min(len(List_1), len(List_2), len(List_3))
for i in range(g):
	print(List_1[i], end=' ')
	print(List_2[i], end=' ')
	print(List_3[i])


n = int(input())
v = [int(x) for x in input().split()]
a = []
b = []
c = []
for i in range(len(v)):
	if v[i] == 1:
		a.append(i + 1)
	if v[i] == 2:
		b.append(i + 1)
	if v[i] == 3:
		c.append(i + 1)
d = min(len(a), len(b), len(c))
print(d)
for i in range(d):
	print(str(a[i]) + ' ' + str(b[i]) + ' ' + str(c[i]))


n = int(input())
students = list(map(int, input().split()))
a_1 = [0] * n
a_1_index = 0
a_2 = [0] * n
a_2_index = 0
a_3 = [0] * n
a_3_index = 0
for i in range(n):
	if students[i] == 1:
		a_1[a_1_index] = i
		a_1_index += 1
	if students[i] == 2:
		a_2[a_2_index] = i
		a_2_index += 1
	if students[i] == 3:
		a_3[a_3_index] = i
		a_3_index += 1
max_pairs = min(a_1_index, a_2_index, a_3_index)
print(max_pairs)
for i in range(max_pairs):
	print(a_1[i] + 1, a_2[i] + 1, a_3[i] + 1)


n = int(input())
skill_list = list(map(int, input().split(' ')))
skill_1 = [i + 1 for (i, skill) in enumerate(skill_list) if skill == 1]
skill_2 = [i + 1 for (i, skill) in enumerate(skill_list) if skill == 2]
skill_3 = [i + 1 for (i, skill) in enumerate(skill_list) if skill == 3]
teams = list(zip(skill_1, skill_2, skill_3))
w = len(teams)
print(w)
for team in teams:
	print('{} {} {}'.format(team[0], team[1], team[2]))


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


n = int(input())
s = list(map(int, input().split()))
(t1, t2, t3) = ([], [], [])
for i in range(n):
	if s[i] == 1:
		t1.append(i + 1)
	elif s[i] == 2:
		t2.append(i + 1)
	else:
		t3.append(i + 1)
w = min(len(t1), len(t2), len(t3))
print(w)
for i in range(w):
	print(t1[i], t2[i], t3[i])


n = int(input())
lst = list(map(int, input().split()))
lst1 = []
lst2 = []
lst3 = []
l1 = l2 = l3 = 0
for i in range(n):
	if lst[i] == 1:
		l1 += 1
		lst1.append(i + 1)
	elif lst[i] == 2:
		l2 += 1
		lst2.append(i + 1)
	else:
		l3 += 1
		lst3.append(i + 1)
t = min(l1, l2, l3)
print(t)
for i in range(t):
	print(lst1[i], lst2[i], lst3[i])


a = int(input())
b = list(input().split()[:a])
one = 0
one1 = []
two = 0
two1 = []
three = 0
three1 = []
for i in range(a):
	if b[i] == '1':
		one += 1
		one1.append(i + 1)
	elif b[i] == '2':
		two += 1
		two1.append(i + 1)
	elif b[i] == '3':
		three += 1
		three1.append(i + 1)
n = min(one, two, three)
one1 = one1[-n:]
two1 = two1[-n:]
three1 = three1[-n:]
if n == 0:
	print(0)
else:
	print(n)
	for i in range(n):
		print(one1[i], ' ', two1[i], ' ', three1[i])


n = int(input())
t = [int(x) for x in input().split()]
a = []
b = []
c = []
for i in range(n):
	if t[i] == 1:
		a.append(i)
	elif t[i] == 2:
		b.append(i)
	elif t[i] == 3:
		c.append(i)
print(min(len(a), len(b), len(c)))
while len(a) > 0 and len(b) > 0 and (len(c) > 0):
	print(a.pop() + 1, b.pop() + 1, c.pop() + 1)


n = int(input())
studentList = input().split()
(prog, math, pe) = (studentList.count('1'), studentList.count('2'), studentList.count('3'))
maxTeams = min(prog, math, pe)
studentList = [(j, i) for (i, j) in zip(range(1, n + 1), studentList)]
studentList = sorted(studentList)
print(maxTeams)
for i in range(0, maxTeams):
	print(f'{studentList[i][1]:d} {studentList[i + prog][1]:d} {studentList[i + math + prog][1]:d}')


n = int(input())
t = [int(x) for x in input().split()]
programming = [i + 1 for i in range(0, len(t)) if t[i] == 1]
maths = [i + 1 for i in range(0, len(t)) if t[i] == 2]
pe = [i + 1 for i in range(0, len(t)) if t[i] == 3]
m = min(len(programming), len(maths), len(pe))
print(m)
for i in range(0, m):
	print(programming[i], maths[i], pe[i])


import sys
size = int(input())
arr = list(map(int, input().split()))
count = [0] * 4
count[0] = sys.maxsize
for i in range(size):
	count[arr[i]] += 1
print(min(count))
arr1 = []
arr2 = []
arr3 = []
if i != 0:
	for i in range(size):
		if arr[i] == 1:
			arr1.append(i + 1)
		elif arr[i] == 2:
			arr2.append(i + 1)
		else:
			arr3.append(i + 1)
	for i in range(min(count)):
		print(arr1[i], end=' ')
		print(arr2[i], end=' ')
		print(arr3[i])


n = int(input())
l = list(map(int, input().split()))
ones = l.count(1)
twos = l.count(2)
three = l.count(3)
m = min(ones, twos, three)
print(m)
(o, t, th) = ([], [], [])
for i in range(len(l)):
	if l[i] == 1:
		o.append(i + 1)
	elif l[i] == 2:
		t.append(i + 1)
	elif l[i] == 3:
		th.append(i + 1)
j = 0
for _ in range(m):
	print(str(o[j]) + ' ' + str(t[j]) + ' ' + str(th[j]))
	j += 1


(n, A) = (int(input()), list(map(int, input().split(' '))))
(ans, ones, twos, threes) = (0, [], [], [])
for i in range(n):
	if A[i] == 1:
		ones.append(i + 1)
	elif A[i] == 2:
		twos.append(i + 1)
	elif A[i] == 3:
		threes.append(i + 1)
siz = min(len(ones), len(twos), len(threes))
print(siz)
for i in range(siz):
	print(*[ones[i], twos[i], threes[i]])


n = int(input())
m = map(int, input().split())
m = list(m)
one = []
two = []
three = []
for i in range(n):
	if m[i] == 1:
		one.append(i + 1)
	elif m[i] == 2:
		two.append(i + 1)
	else:
		three.append(i + 1)
print(min(len(one), len(two), len(three)))
for i in range(min(len(one), len(two), len(three))):
	print(one[i], two[i], three[i])


n = int(input())
s = input().split()
s = [int(i) for i in s]
s = list(s)
one = []
two = []
thr = []
for i in range(n):
	if s[i] == 1:
		one.append(i + 1)
	if s[i] == 2:
		two.append(i + 1)
	if s[i] == 3:
		thr.append(i + 1)
m = min(len(one), len(two), len(thr))
print(m)
for i in range(m):
	print(one[i], two[i], thr[i])


n = int(input())
l = list(map(int, input().split()))
d = {1: [], 2: [], 3: []}
for i in range(len(l)):
	elem = l[i]
	d[elem].append(i + 1)
zippd = list(zip(d[1], d[2], d[3]))
print(len(zippd))
for i in zippd:
	print(*i)


global s
n = int(input())
z = list(input().split())
one = z.count('1')
two = z.count('2')
three = z.count('3')
if one > 0 and two > 0 and (three > 0):
	q = [one, two, three]
	q.sort()
	s = int(q[0])
	print(q[0])
	for w in range(s):
		print(z.index('1') + 1, z.index('2') + 1, z.index('3') + 1)
		z[z.index('1')] = 'e'
		z[z.index('2')] = 'e'
		z[z.index('3')] = 'e'
else:
	print('0')


n = int(input())
l = list(map(int, input().split()))
l2 = []
l3 = []
l4 = []
for i in range(len(l)):
	if l[i] == 1:
		l2.append(i + 1)
	elif l[i] == 2:
		l3.append(i + 1)
	else:
		l4.append(i + 1)
mn = min(len(l2), len(l3), len(l4))
print(mn)
for i in range(mn):
	print(l2[i], l3[i], l4[i])


n = int(input())
a = []
b = []
c = []
s = input().split(' ')
for i in range(n):
	if s[i] == '1':
		a.append(i)
	elif s[i] == '2':
		b.append(i)
	else:
		c.append(i)
mn = min(len(a), len(b))
mn = min(len(c), mn)
print(mn)
for i in range(mn):
	print(str(a[i] + 1) + ' ' + str(b[i] + 1) + ' ' + str(c[i] + 1))


a = int(input())
l1 = []
l2 = []
l3 = []
x = input()
x = x.split()
for i in range(len(x)):
	if x[i] == '1':
		l1.append(i + 1)
	elif x[i] == '2':
		l2.append(i + 1)
	else:
		l3.append(i + 1)
mn = min(len(l1), len(l3), len(l2))
print(mn)
for i in range(mn):
	print(l1.pop(), end=' ')
	print(l2.pop(), end=' ')
	print(l3.pop())


n = int(input())
a = list(map(int, input().split()))
(t1, t2, t3) = ([], [], [])
for i in range(n):
	if a[i] == 1:
		t1.append(i + 1)
	elif a[i] == 2:
		t2.append(i + 1)
	else:
		t3.append(i + 1)
nt = 0
(x, y, z) = (len(t1), len(t2), len(t3))
if x * y * z != 0:
	m = min(x, y, z)
	print(m)
	for i in range(m):
		print(t1[i], t2[i], t3[i])
else:
	print(0)


n = int(input())
num = input()
arr = []
counting = 0
for m in range(0, len(num)):
	if num[m] == ' ':
		arr.append(int(num[counting:m]))
		counting = m + 1
	elif m == len(num) - 1:
		arr.append(int(num[counting:len(num)]))
count = 1
check = 10000000
element = 1
data = arr[0:len(arr)]
data.sort()
for i in range(n - 1):
	if data[i + 1] != data[i]:
		element += 1
		if count < check:
			check = count
			count = 0
	count += 1
result = []
storing = [False] * len(arr)
numbering = 0
if element != 3:
	print(0)
else:
	while check > 0:
		res = ''
		counting = 0
		checking = [False] * 4
		for k in range(0, len(arr)):
			if counting == 3:
				break
			if storing[k] == False and checking[arr[k]] == False:
				if arr[k] == 1 or arr[k] == 2 or arr[k] == 3:
					storing[k] = True
					checking[arr[k]] = True
					counting += 1
					res += str(k + 1) + ' '
		if counting == 3:
			numbering += 1
			result.append(res)
		check -= 1
	print(numbering)
	for i in result:
		print(i)


n = int(input().strip())
ll = list(map(int, input().split()))
a3 = [0]
a2 = [0]
a1 = [0]
for i in range(n):
	if ll[i] == 3:
		a3[0] += 1
		a3.append(str(i + 1))
	elif ll[i] == 2:
		a2[0] += 1
		a2.append(str(i + 1))
	else:
		a1[0] += 1
		a1.append(str(i + 1))
print(min(a1[0], a2[0], a3[0]))
for i in range(1, min(a1[0], a2[0], a3[0]) + 1):
	print(a1[i], a2[i], a3[i])


n = int(input())
studs = list(input().split())
a = studs.count('1')
b = studs.count('2')
c = n - a - b
teams = min(min(a, b), c)
print(teams)
aa = 0
ab = 0
ac = 0
for i in range(teams):
	i1 = studs.index('1', aa) + 1
	print(i1, end=' ')
	aa = i1
	i2 = studs.index('2', ab) + 1
	print(i2, end=' ')
	ab = i2
	i3 = studs.index('3', ac) + 1
	print(i3)
	ac = i3


n = int(input())
listt = [int(i) for i in input().split()]
k = 0
k = min(listt.count(1), listt.count(2), listt.count(3))
print(k)
for i in range(k):
	print(listt.index(1) + 1, listt.index(2) + 1, listt.index(3) + 1)
	listt[listt.index(1)] = 0
	listt[listt.index(2)] = 0
	listt[listt.index(3)] = 0


n = int(input())
a = list(map(int, input().strip().split()))
c = []
for i in range(len(a)):
	if a[i] == 1:
		if 2 in a and 3 in a:
			c.append([a.index(1) + 1, a.index(2) + 1, a.index(3) + 1])
			a[a.index(1)] = 0
			a[a.index(2)] = 0
			a[a.index(3)] = 0
		elif a[i] == 0:
			continue
		else:
			break
print(len(c))
for i in c:
	print(*i)


import sys

def main():
	_count = 0
	command_1 = []
	command_2 = []
	command_3 = []
	n = int(input())
	a = list(map(int, input().split()))
	for i in range(n):
		if a[i] == 1:
			command_1.append(i + 1)
		elif a[i] == 2:
			command_2.append(i + 1)
		elif a[i] == 3:
			command_3.append(i + 1)
	_len = min(len(command_1), len(command_2), len(command_3))
	if _len != 0:
		print(_len, end='\n')
		for i in range(_len):
			print(command_1[i], ' ', command_2[i], ' ', command_3[i], end='\n')
	else:
		print(0)
	return
sys.exit(main())


n = int(input())
l = [str(x) for x in input().split()]
w = min(l.count('1'), l.count('2'), l.count('3'))
if w == 0:
	print(0)
else:
	a = [['0', '0', '0'] for x in range(w)]
	s = 0
	for i in range(n):
		if l[i] == '1' and s < w:
			a[s][0] = str(i + 1)
			s += 1
	s = 0
	for i in range(n):
		if l[i] == '2' and s < w:
			a[s][1] = str(i + 1)
			s += 1
	s = 0
	for i in range(n):
		if l[i] == '3' and s < w:
			a[s][2] = str(i + 1)
			s += 1
	print(w)
	for j in range(w):
		print(' '.join(a[j]))


n = int(input())
t = input().split()
count1 = 0
count2 = 0
count3 = 0
team = []
b = 0
for i in range(n):
	if int(t[i]) == 1:
		count1 += 1
	if int(t[i]) == 2:
		count2 += 1
	if int(t[i]) == 3:
		count3 += 1
print(min(count1, count2, count3))
for i in range(min(count1, count2, count3)):
	team.append(t.index('1') + 1)
	t.insert(t.index('1'), 'x')
	t.remove('1')
	team.append(t.index('2') + 1)
	t.insert(t.index('2'), 'x')
	t.remove('2')
	team.append(t.index('3') + 1)
	t.insert(t.index('3'), 'x')
	t.remove('3')
for i in range(min(count1, count2, count3)):
	print(team[i + b], team[i + b + 1], team[i + b + 2])
	b = b + 2


from sys import stdin
N = int(stdin.readline())
array = list(map(int, stdin.readline().split()))
math = []
coding = []
chads = []
for i in range(N):
	if array[i] == 1:
		math.append(i + 1)
	elif array[i] == 2:
		coding.append(i + 1)
	elif array[i] == 3:
		chads.append(i + 1)
print(min(len(math), len(coding), len(chads)))
for i in range(min(len(math), len(coding), len(chads))):
	print(math[i], coding[i], chads[i])


n = int(input())
m = list(map(int, input().split()))
z = [[] for i in range(n)]
x = [[] for i in range(n)]
ans = 0
for i in range(n):
	for j in range(n):
		if not m[i] in z[j]:
			z[j].append(m[i])
			x[j].append(i + 1)
			break
for i in range(len(z)):
	if len(z[i]) > 2:
		ans += 1
	else:
		q = i
		break
for i in range(len(x) - q):
	x.pop(q)
print(ans)
for i in x:
	print(*i)


a = input
a()
_1 = []
_2 = []
_3 = []
c = 0
for i in a().split():
	c += 1
	if i == '1':
		_1 += [c]
	elif i == '2':
		_2 += [c]
	else:
		_3 += [c]
print(min(len(_1), len(_2), len(_3)))
[print(x, y, z) for (x, y, z) in zip(_1, _2, _3)]


n = int(input())
z = list(map(int, input().split()))
satu = 0
dua = 0
tiga = 0
one = []
two = []
three = []
for i in range(n):
	if z[i] % 3 == 0:
		three.append(i + 1)
		tiga += 1
	elif z[i] % 2 == 0:
		two.append(i + 1)
		dua += 1
	else:
		one.append(i + 1)
		satu += 1
kevin = min(satu, dua, tiga)
one.sort()
two.sort()
three.sort()
print(kevin)
for i in range(kevin):
	print(one[i], two[i], three[i])


n = int(input())
l = input().split()
l1 = []
l2 = []
l3 = []
for i in range(n):
	if l[i] == '1':
		l1.append(i + 1)
	elif l[i] == '2':
		l2.append(i + 1)
	else:
		l3.append(i + 1)
d = min(len(l1), len(l2), len(l3))
print(d)
for i in range(d):
	print(l1[i], l2[i], l3[i])


x = int(input())
ar = list(map(int, input().split()))
l = [0, 0, 0]
for i in ar:
	l[i - 1] += 1
print(min(l))
if min(l) > 0:
	for i in range(min(l)):
		p = ar.index(1)
		print(p + 1, end=' ')
		ar[p] = 0
		q = ar.index(2)
		print(q + 1, end=' ')
		ar[q] = 0
		r = ar.index(3)
		print(r + 1, end=' ')
		ar[r] = 0
		print()


childrens = int(input())
skills = list(map(int, input().split()))
teams = []
programming = 0
math = 0
pe = 0
progNum = []
mathNum = []
peNum = []
for m in range(len(skills)):
	if skills[m] == 1:
		programming = programming + 1
		progNum.append(m + 1)
for k in range(len(skills)):
	if skills[k] == 2:
		math = math + 1
		mathNum.append(k + 1)
for l in range(len(skills)):
	if skills[l] == 3:
		pe = pe + 1
		peNum.append(l + 1)
teams.append(programming)
teams.append(math)
teams.append(pe)
teams.sort()
finalTeam = teams[0]
print(finalTeam)
for j in range(int(finalTeam)):
	print(progNum[j], mathNum[j], peNum[j])


n = int(input())
values = list(map(int, input().split()))
ones = []
twos = []
threes = []
for i in range(len(values)):
	if values[i] == 1:
		ones.append(i)
	elif values[i] == 2:
		twos.append(i)
	else:
		threes.append(i)
triples = []
for i in range(min(len(ones), len(twos), len(threes))):
	triples.append([ones[i] + 1, twos[i] + 1, threes[i] + 1])
print(len(triples))
for (a, b, c) in triples:
	print('{} {} {}'.format(a, b, c))


n = int(input())
a = [int(a) for a in input().split()]
c = a[:]
c.insert(0, 0)
d = []
count = 0
e = d[:]
if len(a) < 3 or (1 and 2 and (3 not in a)):
	print(0)
else:
	while 1 in a and 2 in a and (3 in a):
		b = a.pop(a.index(1))
		d.append(b)
		b = a.pop(a.index(2))
		d.append(b)
		b = a.pop(a.index(3))
		d.append(b)
		count += 1
	print(count)
if count > 0:
	for i in range(count):
		d = c.index(1)
		e.append(d)
		c.insert(c.index(1), 0)
		c.remove(1)
		d = c.index(2)
		e.append(d)
		c.insert(c.index(2), 0)
		c.remove(2)
		d = c.index(3)
		e.append(d)
		c.insert(c.index(3), 0)
		c.remove(3)
		for i in range(3):
			e[i] = str(e[i])
		print(' '.join(e))
		e = []


n = int(input())
lis = input().split()
one = []
two = []
three = []
for i in range(len(lis)):
	if lis[i] == '1':
		one.append(i)
	elif lis[i] == '2':
		two.append(i)
	else:
		three.append(i)
teams = []
w = 0
while len(one) != 0 and len(two) != 0 and (len(three) != 0):
	teams.append(int(one.pop()) + 1)
	teams.append(int(two.pop()) + 1)
	teams.append(int(three.pop()) + 1)
	w += 1
print(w)
j = 0
for i in range(w):
	print(teams[j], teams[j + 1], teams[j + 2], sep=' ')
	j = j + 3


def which(x, item):
	y = []
	x = list(x)
	if type(item) != list:
		item = [item]
	for i in range(len(x)):
		if x[i] in item:
			y.append(i)
	if y == []:
		y = False
	return y
n = int(input())
m = [int(x) for x in input().split()]
pro = m.count(1)
mat = m.count(2)
pe = m.count(3)
num = [pro, mat, pe]
if pro == 0 or mat == 0 or pe == 0:
	print(0)
else:
	print(min(num))
pro_list = which(m, 1)
mat_list = which(m, 2)
pe_list = which(m, 3)
for i in range(min(num)):
	print(pro_list[i] + 1, mat_list[i] + 1, pe_list[i] + 1)


n = int(input())
stud = [int(x) for x in input().split()]
p = []
m = []
e = []
for i in range(len(stud)):
	if stud[i] == 1:
		p.append(i + 1)
	elif stud[i] == 2:
		m.append(i + 1)
	else:
		e.append(i + 1)
x = min(len(p), len(m), len(e))
print(x)
for i in range(x):
	print(str(p[i]) + ' ' + str(m[i]) + ' ' + str(e[i]))


n = int(input())
l = list(map(int, input().split()))
(a1, a2, a3) = (l.count(1), l.count(2), l.count(3))
w = min(a1, a2, a3)
print(w)
for i in range(w):
	print(l.index(1) + 1, l.index(2) + 1, l.index(3) + 1)
	l[l.index(1)] = 0
	l[l.index(2)] = 0
	l[l.index(3)] = 0


n = int(input())
c = [[], [], []]
t = list(map(int, input().split()))
for i in range(n):
	c[t[i] - 1].append(str(i + 1))
m = min(len(c[0]), min(len(c[1]), len(c[2])))
print(m)
if m > 0:
	for _ in range(m):
		print(c[0].pop() + ' ' + c[1].pop() + ' ' + c[2].pop())


stud = int(input())
l4 = [0, 0, 0]
l2 = []
l3 = []
l1 = []
z = 1
for x in map(int, input().split()):
	if x == 1:
		l1.append(z)
		l4[0] += 1
	elif x == 2:
		l2.append(z)
		l4[1] += 1
	elif x == 3:
		l3.append(z)
		l4[2] += 1
	z += 1
if min(l4) == 0:
	print(0)
	exit()
print(min(l4))
h = min(l4) - 1
while h >= 0:
	print(l1[h], l2[h], l3[h])
	h -= 1


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


n = int(input())
t = [int(x) for x in input().split()]
list_1 = []
list_2 = []
list_3 = []
for i in range(len(t)):
	if t[i] == 1:
		list_1.append(i + 1)
	elif t[i] == 2:
		list_2.append(i + 1)
	elif t[i] == 3:
		list_3.append(i + 1)
z = min(len(list_1), len(list_2), len(list_3))
if z > 0:
	print(z)
	for i in range(z):
		print(list_1[i], list_2[i], list_3[i])
else:
	print(0)


n = int(input())
L = input()
L = L.split(' ')
L = list(map(int, L))
P = []
M = []
E = []
for j in range(n):
	if L[j] == 1:
		P += [j]
	elif L[j] == 2:
		M += [j]
	else:
		E += [j]
(p, m, e) = (len(P), len(M), len(E))
if p == 0 or m == 0 or e == 0:
	print(int(0))
else:
	a = min(p, m, e)
	print(a)
	for i in range(a):
		print('{} {} {}'.format(P[i] + 1, M[i] + 1, E[i] + 1))


n = int(input())
s = list(map(int, input().split()))
cnt = [[], [], []]
for i in range(0, n):
	cnt[s[i] - 1].append(i)
mn = min(map(len, cnt))
print(mn)
for i in range(0, mn):
	for L in cnt:
		print(L[i] + 1, end=' ')
	print()


from collections import Counter
n = int(input())
t = [int(i) for i in input().split()]
counter = Counter(t)
c = min(counter.values())
if len(counter) < 3:
	print(0)
else:
	print(c)
	skills = [1, 2, 3]
	grp_by_skill = []
	for s in skills:
		grp_by_skill.append([i + 1 for i in range(n) if t[i] == s])
	for i in range(c):
		print(f'{grp_by_skill[0][i]} {grp_by_skill[1][i]} {grp_by_skill[2][i]}')


import sys
from collections import defaultdict
n = int(input())
c = list(map(int, input().split()))
v1 = c.count(1)
v2 = c.count(2)
v3 = c.count(3)
if v1 == 0 or v2 == 0 or v3 == 0:
	print(0)
	sys.exit()
r1 = min(v1, v2, v3)
d = defaultdict(list)
for i in range(len(c)):
	d[c[i]].append(i + 1)
print(r1)
for i in range(r1):
	print(' '.join([str(d[j][i]) for j in range(1, 4)]))


x = input()
y = input().split()
k = []
li = list(y)
k.append(li.count('1'))
k.append(li.count('2'))
k.append(li.count('3'))
m = min(k)
print(m)
for i in range(m):
	a = li.index('1')
	b = li.index('2')
	c = li.index('3')
	print(a + 1, b + 1, c + 1)
	li[a] = 5
	li[b] = 5
	li[c] = 5


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())
arr = list(map(int, input().split()))
a = [[], [], []]
for i in range(n):
	a[arr[i] - 1].append(i + 1)
print(min(len(a[0]), len(a[1]), len(a[2])))
for i in range(min(len(a[0]), len(a[1]), len(a[2]))):
	print(a[0][i], a[1][i], a[2][i])


n = int(input())
a = [int(i) for i in input().split()[:n]]
x = []
b = []
f = 0
while 1 in a and 2 in a and (3 in a):
	i1 = a.index(1)
	i2 = a.index(2)
	i3 = a.index(3)
	c = [i1 + 1, i2 + 1, i3 + 1]
	b.append(c)
	f += 1
	a[i1] = 5
	a[i2] = 5
	a[i3] = 5
if f > 0:
	print(f)
	for i in range(len(b)):
		for j in range(3):
			print(b[i][j], end=' ')
		print()
else:
	print(0)


n = int(input())
a = map(int, input().split())
s = [set(), set(), set()]
for (i, x) in enumerate(a, 1):
	s[x - 1].add(i)
print(min(map(len, s)))
for x in zip(*s):
	print(*x)


n = int(input())
a = list(map(int, input().split()))
c = min(a.count(1), a.count(2), a.count(3))
print(c)
for i in range(c):
	for j in range(1, 4):
		print(a.index(j) + 1, end=' ')
		a[a.index(j)] = 0
	print()


n = int(input())
t = list(map(int, input().split()))
one = []
two = []
three = []
for i in range(len(t)):
	if t[i] == 1:
		one.append(i + 1)
	elif t[i] == 2:
		two.append(i + 1)
	elif t[i] == 3:
		three.append(i + 1)
mini = min(len(one), len(two), len(three))
print(mini)
for i in range(mini):
	print(one[i], two[i], three[i], end=' ')
	print()


import sys
import math
import bisect

def main():
	n = int(input())
	A = list(map(int, input().split()))
	B = [[], [], []]
	for i in range(n):
		B[A[i] - 1].append(i)
	ans = []
	while len(B[0]) and len(B[1]) and len(B[2]):
		ans.append([B[0][-1], B[1][-1], B[2][-1]])
		B[0].pop()
		B[1].pop()
		B[2].pop()
	print(len(ans))
	for v in ans:
		print(' '.join(list((str(a + 1) for a in v))))
main()


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


n = int(input())
l = list(map(int, input().split()))
s1 = []
s2 = []
s3 = []
for i in range(n):
	if l[i] == 1:
		s1.append(i + 1)
	elif l[i] == 2:
		s2.append(i + 1)
	else:
		s3.append(i + 1)
print(min([len(s1), len(s2), len(s3)]))
while s1 and s2 and s3:
	print(s1.pop(), s2.pop(), s3.pop())


n = int(input())
t = list(map(int, input().split()))
x = 0
y = 0
z = 0
b = []
c = []
for i in range(n):
	if t[i] == 1:
		x += 1
		c.append(1)
		c.append(i + 1)
	elif t[i] == 2:
		y += 1
		c.append(2)
		c.append(i + 1)
	else:
		c.append(3)
		c.append(i + 1)
		z += 1
b.append(x)
b.append(y)
b.append(z)
if x == 0 or y == 0 or z == 0:
	print(0)
else:
	print(min(b))
	f = []
	g = []
	h = []
	for q in range(1, len(c), 2):
		if c[q - 1] == 1:
			f.append(c[q])
		elif c[q - 1] == 2:
			g.append(c[q])
		else:
			h.append(c[q])
	for w in range(min(b)):
		print(f[w], end=' ')
		print(g[w], end=' ')
		print(h[w])


n = int(input())
a = list(map(int, input().split()))
x = []
y = []
z = []
for i in range(n):
	if a[i] == 1:
		x.append(i)
	elif a[i] == 2:
		y.append(i)
	else:
		z.append(i)
if x == [] or y == [] or z == []:
	print(0)
else:
	m = min(len(x), len(y), len(z))
	print(m)
	for i in range(m):
		print(x[i] + 1, y[i] + 1, z[i] + 1)
	print()


input()
(one, two, three, result) = ([], [], [], [])
for (n, i) in enumerate(input().split(), 1):
	if i == '1':
		one.append(str(n))
	elif i == '2':
		two.append(str(n))
	else:
		three.append(str(n))
	if one and two and three:
		result.append(one.pop() + ' ' + two.pop() + ' ' + three.pop())
print(len(result))
for r in result:
	print(r)


n = int(input())
skill = [int(x) for x in input().split()]
pro = skill.count(1)
math = skill.count(2)
PE = skill.count(3)
w = min(pro, math, PE)
print(w)
if w != 0:
	for i in range(w):
		for j in range(1, 4):
			p = skill.index(j)
			print(p + 1)
			skill[p] = 0


n = int(input())
skills = [int(s) for s in input().split()]
a = []
b = []
c = []
for x in range(n):
	if skills[x] == 1:
		a.append(x + 1)
	elif skills[x] == 2:
		b.append(x + 1)
	else:
		c.append(x + 1)
m = min(len(a), len(b), len(c))
print(m)
for i in range(m):
	print(f'{a[i]} {b[i]} {c[i]}')


n = int(input())
list_of_numbers = list(map(int, input().split(' ')))
dict = {}
dict[1] = []
dict[2] = []
dict[3] = []
for i in range(n):
	dict[list_of_numbers[i]].append(i + 1)
min = len(dict[1])
for i in dict.keys():
	length = len(dict[i])
	if length < min:
		min = length
print(min)
for i in range(min):
	for j in dict.keys():
		print(dict[j][i], end=' ')
	print('')


n = int(input())
lst = list(map(int, input().split()))
on = 0
tw = 0
th = 0
one = []
two = []
three = []
for i in range(n):
	if lst[i] == 1:
		on += 1
		one.append(i)
	elif lst[i] == 2:
		tw += 1
		two.append(i)
	else:
		th += 1
		three.append(i)
print(min(on, tw, th))
for j in range(min(on, tw, th)):
	print(one[j] + 1, end=' ')
	print(two[j] + 1, end=' ')
	print(three[j] + 1)


input()
X = [[], [], []]
a = []
for (i, u) in enumerate(map(int, input().split()), 1):
	X[u - 1] += [i]
for i in X:
	a.append(len(i))
print(sorted(a)[0])
for i in zip(*X):
	print(*i)


n = int(input())
t = [int(x) for x in input().split()]
a = [0, 0, 0]
for x in t:
	a[x - 1] += 1
m = min(a)
a = []
for i in range(m):
	b = t.index(1)
	c = t.index(2)
	d = t.index(3)
	t[b] = 0
	t[c] = 0
	t[d] = 0
	a.append([b + 1, c + 1, d + 1])
print(m)
for i in a:
	print(*i)


n = input()
l = list(map(int, input().split()))
a = [l.count(1), l.count(2), l.count(3)]
p = []
m = []
pe = []
if min(a) != 0:
	for i in range(len(l)):
		if l[i] == 1:
			p += [i + 1]
		elif l[i] == 2:
			m += [i + 1]
		elif l[i] == 3:
			pe += [i + 1]
	o = ''
	print(min(a))
	for i in range(min(a)):
		o = str(p[i]) + ' ' + str(m[i]) + ' ' + str(pe[i])
		print(o)
else:
	print(0)


def teamolympiad():
	students = int(input())
	a = [int(i) for i in input().split()]
	if a.count(1) == 0 or a.count(2) == 0 or a.count(3) == 0:
		print(0)
		return 0
	arr = []
	print(min(a.count(1), a.count(2), a.count(3)))
	for num in range(min(a.count(1), a.count(2), a.count(3))):
		print(a.index(1) + 1, a.index(2) + 1, a.index(3) + 1)
		arr.append(a.index(1))
		arr.append(a.index(2))
		arr.append(a.index(3))
		(a[a.index(1)], a[a.index(2)], a[a.index(3)]) = (0, 0, 0)
teamolympiad()


n = int(input())
li = list(map(int, input().split()))
list_m = []
list_p = []
list_pe = []
for i in range(len(li)):
	if li[i] == 1:
		list_p.append(i + 1)
	elif li[i] == 2:
		list_m.append(i + 1)
	elif li[i] == 3:
		list_pe.append(i + 1)
teams = min(len(list_p), len(list_m), len(list_pe))
print(teams)
for i in range(teams):
	print(list_p[i], list_pe[i], list_m[i])


a = int(input())
k = list(map(int, input().split()))
h = k
pos = {1: [], 2: [], 3: []}
for i in range(len(h)):
	pos[h[i]].append(i + 1)
l = {1: 0, 2: 0, 3: 0}
for i in k:
	l[i] += 1
g = min(l.values())
print(g)
for i in range(g):
	print(pos[1][-1], pos[2][-1], pos[3][-1])
	pos[1].pop()
	pos[2].pop()
	pos[3].pop()


n = int(input())
lst = list(map(int, input().strip().split()))[:n]
(o, t, th) = (0, 0, 0)
l1 = []
l2 = []
l3 = []
j = 0
for i in range(len(lst)):
	if lst[i] == 1:
		o += 1
		l1.append(i + 1)
	elif lst[i] == 2:
		t += 1
		l2.append(i + 1)
	elif lst[i] == 3:
		th += 1
		l3.append(i + 1)
val = min(o, t, th)
print(val)
while val > 0:
	print(l1[j], l2[j], l3[j])
	j += 1
	val -= 1


a = int(input())
b = input().split()
l = []
for i in range(a):
	l.append(int(b[i]))
p1 = l.count(1)
p2 = l.count(2)
p3 = l.count(3)
p = []
p.append(p1)
p.append(p2)
p.append(p3)
s = min(p)
k = []
for i in range(s):
	ind1 = l.index(1)
	ind2 = l.index(2)
	ind3 = l.index(3)
	h = str(ind1 + 1) + ' ' + str(ind2 + 1) + ' ' + str(ind3 + 1)
	k.append(h)
	(l[ind1], l[ind2], l[ind3]) = (0, 0, 0)
print(s)
for i in range(s):
	print(k[i])


m = int(input())
x = list(map(int, input().split()))
n = min(x.count(3), x.count(2), x.count(1))
print(n)
for i in range(n):
	(i1, i2, i3) = (x.index(1), x.index(2), x.index(3))
	print(i1 + 1, i2 + 1, i3 + 1)
	x[i1] = 0
	x[i2] = 0
	x[i3] = 0


def main():
	n_students = int(input())
	skills = [int(_) for _ in input().split()]
	hashed_skills = [[], [], []]
	for i in range(n_students):
		hashed_skills[skills[i] - 1] += [i + 1]
	n_teams = min([len(hashed_skills[i]) for i in range(3)])
	print(n_teams)
	for i in range(n_teams):
		print(hashed_skills[0][i], hashed_skills[1][i], hashed_skills[2][i])
main()


def duplicates(lst, item):
	return [i for (i, x) in enumerate(lst) if x == item]
n = int(input())
a = list(map(int, input().split()))
c = min(a.count(1), a.count(3), a.count(2))
print(c)
q = duplicates(a, 1)
w = duplicates(a, 2)
e = duplicates(a, 3)
for i in range(c):
	print(str(q[i] + 1) + ' ' + str(w[i] + 1) + ' ' + str(e[i] + 1))


input()
buckets = {1: [], 2: [], 3: []}
for (i, k) in enumerate(map(int, input().split())):
	buckets[k].append(i + 1)
max_num_teams = min([len(b) for b in buckets.values()])
print(max_num_teams)
for k in range(max_num_teams):
	print('{} {} {}'.format(buckets[1][k], buckets[2][k], buckets[3][k]))


n = int(input())
nums = [int(x) for x in input().split()]
gifted = [[] for i in range(3)]
for (i, v) in enumerate(nums):
	gifted[v - 1].append(i + 1)
res = list(zip(*gifted))
print(len(res))
for row in res:
	print(*row)


numb = int(input())
word = str(input())
word = word.split(' ')
if word.count('1') < 1 or word.count('2') < 1 or word.count('3') < 1:
	print('0')
else:
	pr = word.count('1')
	ma = word.count('2')
	pe = word.count('3')
	vals = [int(pr), int(ma), int(pe)]
	print(min(vals))
	for n in range(min(vals)):
		a = []
		b = word.index('1')
		c = word.index('2')
		d = word.index('3')
		a.append(str(b + 1))
		a.append(str(c + 1))
		a.append(str(d + 1))
		word[b] = '0'
		word[c] = '0'
		word[d] = '0'
		print(' '.join(a))


n = int(input())
students = input().split()
one = []
two = []
three = []
op_team = []
for i in range(n):
	if students[i] == '1':
		one.append(i + 1)
	elif students[i] == '2':
		two.append(i + 1)
	else:
		three.append(i + 1)
while 0 <= n:
	if len(one) > 0 and len(two) > 0 and (len(three) > 0):
		op_team.append(str(one.pop()) + ' ' + str(two.pop()) + ' ' + str(three.pop()))
	else:
		break
print(len(op_team))
for i in op_team:
	print(i)


n = int(input())
t = list(map(lambda x: int(x) - 1, input().split()))
student = [[] for _ in range(3)]
for (i, e) in enumerate(t, 1):
	student[e].append(i)
print(min(map(len, student)))
for t in zip(*student):
	print(' '.join(map(str, list(t))))


def solve():
	n = int(input())
	t = list(map(int, input().split()))
	ans = []
	count = 0
	while True:
		lst = []
		try:
			lst.append(t.index(1) + 1)
			lst.append(t.index(2) + 1)
			lst.append(t.index(3) + 1)
			count += 1
			t[t.index(1)] = 0
			t[t.index(2)] = 0
			t[t.index(3)] = 0
		except:
			break
		ans.append(lst)
	print(count)
	if count != 0:
		for i in ans:
			print(*i)
solve()


n = int(input())
lst = list(map(int, input().split()))
lst1 = []
lst2 = []
lst3 = []
j = 1
for i in lst:
	if i == 1:
		lst1.append(j)
	elif i == 2:
		lst2.append(j)
	else:
		lst3.append(j)
	j = j + 1
w = min(len(lst1), len(lst2), len(lst3))
print(w)
for i in range(w):
	print(lst1[i], '', lst2[i], '', lst3[i])


n = int(input())
t = [int(i) for i in input().split()]
num = min(min(t.count(1), t.count(2)), t.count(3))
print(num)
for i in range(num):
	one = t.index(1)
	two = t.index(2)
	thr = t.index(3)
	print(one + 1, two + 1, thr + 1)
	t[one] = 0
	t[two] = 0
	t[thr] = 0


n = int(input())
a = [int(x) for x in input().split()]
c = min([a.count(1), a.count(2), a.count(3)])
if c == 0:
	print(c)
else:
	print(c)
	for i in range(c):
		print(a.index(1) + 1, a.index(2) + 1, a.index(3) + 1)
		a[a.index(1)] = -1
		a[a.index(2)] = -1
		a[a.index(3)] = -1


n = int(input())
arr = list(map(int, input().split()))
d = {}
for i in range(n):
	if arr[i] not in d:
		d[arr[i]] = [i + 1]
	else:
		d[arr[i]].append(i + 1)
if len(d) != 3:
	print(0)
else:
	min_val = min([len(d[key]) for key in d])
	print(min_val)
	while min_val > 0:
		print(' '.join(map(str, [d[key].pop() for key in d])))
		min_val -= 1


n = int(input())
a = list(map(int, input().split()))
one = a.count(1)
two = a.count(2)
three = a.count(3)
s = min(one, min(two, three))
o = []
t = []
th = []
if s == 0:
	print(0)
else:
	for i in range(0, n):
		if a[i] == 1:
			o.append(i + 1)
		elif a[i] == 2:
			t.append(i + 1)
		elif a[i] == 3:
			th.append(i + 1)
	print(s)
	for i in range(s):
		print(o[i], t[i], th[i])


n = int(input())
l = [int(x) for x in input().split(' ')]
(p, m, s) = ([], [], [])
for x in range(len(l)):
	if l[x] == 1:
		p.append(x + 1)
	elif l[x] == 2:
		m.append(x + 1)
	else:
		s.append(x + 1)
k = min(len(p), len(m), len(s))
print(k)
for i in range(k):
	print(p[i], m[i], s[i], end='\n', sep=' ')


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


n = int(input())
s = list(map(int, input().split()))
o = []
t = []
th = []
for i in range(n):
	if s[i] == 1:
		o.append(i + 1)
	elif s[i] == 2:
		t.append(i + 1)
	elif s[i] == 3:
		th.append(i + 1)
	else:
		pass
mn = min(len(o), len(t), len(th))
print(mn)
for i in range(mn):
	print(o[i], t[i], th[i])


n = int(input())
li = list(map(int, input().split()))
s = str(li)
number_of_teams = min(s.count('1'), s.count('2'), s.count('3'))
print(number_of_teams)
while number_of_teams != 0:
	x = li.index(1)
	y = li.index(2)
	z = li.index(3)
	print(x + 1, y + 1, z + 1)
	li[x] = 0
	li[y] = 0
	li[z] = 0
	number_of_teams = number_of_teams - 1


n = int(input())
kids = [int(x) for x in input().split()]
v = {'1': [], '2': [], '3': []}
for i in range(len(kids)):
	k = kids[i]
	v[str(k)].append(str(i + 1))
l = min(len(v['1']), len(v['2']), len(v['3']))
print(l)
for i in range(l):
	print(v['1'].pop(), v['2'].pop(), v['3'].pop())


input()
kids = list(map(int, input().split()))
if len(set(kids)) < 3:
	print(0)
else:
	data = dict()
	for i in range(len(kids)):
		if kids[i] not in data.keys():
			data[kids[i]] = [1, i + 1]
		else:
			data[kids[i]][0] += 1
			data[kids[i]].append(i + 1)
	teams = []
	i = 1
	while 1:
		try:
			teams.append([data[1][i], data[2][i], data[3][i]])
			i += 1
		except IndexError:
			break
	print(len(teams))
	for t in teams:
		print(' '.join(map(str, t)))


n = int(input())
a = input()
A = []
(q1, q2, q3) = (0, 0, 0)
for i in a.split():
	A.append(int(i))
	if int(i) == 1:
		q1 = q1 + 1
	elif int(i) == 2:
		q2 = q2 + 1
	elif int(i) == 3:
		q3 = q3 + 1
min = q1
if q2 < min:
	min = q2
	if q3 < min:
		min = q3
elif q3 < min:
	min = q3
(s1, s2, s3) = (0, 0, 0)
C = []
for k in range(0, min):
	B = []
	for h in range(0, 3):
		B.append(0)
	C.append(B)
for j in range(0, n):
	if A[j] == 1 and s1 < min:
		C[s1][0] = j
		s1 = s1 + 1
	elif A[j] == 2 and s2 < min:
		C[s2][1] = j
		s2 = s2 + 1
	elif A[j] == 3 and s3 < min:
		C[s3][2] = j
		s3 = s3 + 1
if min == 0:
	print(min)
else:
	print(min)
	for p in range(0, min):
		print(str(C[p][0] + 1) + ' ' + str(C[p][1] + 1) + ' ' + str(C[p][2] + 1))


n = int(input())
a = list(map(int, input().split()))
one = []
two = []
three = []
count_1 = 0
count_2 = 0
count_3 = 0
for (i, ele) in enumerate(a):
	if ele == 1:
		count_1 = count_1 + 1
		one.append(i + 1)
	if ele == 2:
		count_2 = count_2 + 1
		two.append(i + 1)
	if ele == 3:
		count_3 = count_3 + 1
		three.append(i + 1)
res = 0
res = min(count_1, count_2)
res = min(res, count_3)
st = ''
print(res)
for i in range(res):
	st = st + str(one[i]) + ' ' + str(two[i]) + ' ' + str(three[i])
	print(st)
	st = ''


a = int(input())
b = input().split()
k = min(b.count('1'), b.count('2'), b.count('3'))
print(k)
list1 = []
list2 = []
list3 = []
i = 0
while i < a:
	if b[i] == '1':
		list1.append(i)
	elif b[i] == '2':
		list2.append(i)
	else:
		list3.append(i)
	i += 1
while k > 0:
	team = [str(list1[0] + 1), str(list2[0] + 1), str(list3[0] + 1)]
	del list1[0]
	del list2[0]
	del list3[0]
	print(' '.join(team))
	k -= 1


n = int(input())
arr = [int(x) for x in input().split()]
a = []
b = []
c = []
for i in range(n):
	if arr[i] == 1:
		a.append(i + 1)
	elif arr[i] == 2:
		b.append(i + 1)
	else:
		c.append(i + 1)
cnt = min(len(a), len(b), len(c))
print(cnt)
for i in range(min(len(a), len(b), len(c))):
	print(a[i], b[i], c[i])


def getmember(n):
	member = data.index(n)
	if n != 3:
		print(member + 1, end=' ')
	else:
		print(member + 1)
	data[member] = 0
amount = int(input())
data = [int(i) for i in input().split()]
answer = min(data.count(1), data.count(2), data.count(3))
print(answer)
for i in range(answer):
	for n in range(1, 4):
		getmember(n)


t = int(input())
a = list(map(int, input().split()))
one = a.count(1)
two = a.count(2)
three = a.count(3)
o = []
tw = []
th = []
x = min(one, two, three)
for i in range(len(a)):
	if a[i] == 1:
		o.append(i + 1)
	elif a[i] == 2:
		tw.append(i + 1)
	else:
		th.append(i + 1)
print(x)
for i in range(x):
	print(o[i], tw[i], th[i], end=' ')
	print()


n = int(input())
s = input().split()
(c1, c2, c3) = (0, 0, 0)
for i in range(len(s)):
	s[i] = int(s[i])
	if s[i] == 1:
		c1 = c1 + 1
	if s[i] == 2:
		c2 = c2 + 1
	if s[i] == 3:
		c3 = c3 + 1
k = min(c1, c2, c3)
print(k)
for i in range(k):
	print(s.index(1) + 1, s.index(2) + 1, s.index(3) + 1)
	s[s.index(1)] = 0
	s[s.index(2)] = 0
	s[s.index(3)] = 0


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


n = int(input())
x = list(map(int, input().split()))
y = x.copy()
x.sort()
(cur_min, cur_max) = (n + 1, 1)
for i in range(1, n):
	if x[i] == x[i - 1]:
		cur_max += 1
	else:
		if cur_max < cur_min:
			cur_min = cur_max
		cur_max = 1
	if i == n - 1:
		cur_min = min(cur_max, cur_min)
if len(set(x)) == 3:
	print(cur_min)
	for j in range(cur_min):
		print(y.index(1) + 1, y.index(2) + 1, y.index(3) + 1)
		y[y.index(1)] = 0
		y[y.index(2)] = 0
		y[y.index(3)] = 0
else:
	print(0)


x = int(input())
l = [[0, []], [0, []], [0, []]]
y = [int(i) for i in input().split()]
j = 0
while j < x:
	l[y[j] - 1][0] += 1
	l[y[j] - 1][1].append(j + 1)
	j += 1
ans = min(l, key=lambda x: x[0])[0]
print(ans)
j = 0
while j < ans:
	print(l[0][1][j], l[1][1][j], l[2][1][j])
	j += 1


n = int(input())
students = [int(a) for a in input().split()]
if 1 not in students or 2 not in students or 3 not in students:
	print(0)
else:
	talentOne = []
	talentTwo = []
	talentThree = []
	for index in range(n):
		if students[index] == 1:
			talentOne.append(index)
		elif students[index] == 2:
			talentTwo.append(index)
		else:
			talentThree.append(index)
	teams = min(len(talentOne), len(talentTwo), len(talentThree))
	print(teams)
	for x in range(teams):
		print(talentOne[x] + 1, talentTwo[x] + 1, talentThree[x] + 1)


n = int(input())
lis = list(map(int, input().split()))
a = []
b = []
c = []
for i in range(n):
	(a, b, c)[lis[i] - 1].append(i + 1)
l = min(len(a), len(b), len(c))
print(l)
for j in range(l):
	print('%d %d %d' % (a[j], b[j], c[j]))


n = int(input())
num_lt = [int(i) for i in input().split()]
ind_1 = ind_2 = ind_3 = 0
lt1 = []
lt2 = []
lt3 = []
while ind_1 != n and ind_2 != n and (ind_3 != n):
	if ind_1 < n:
		while num_lt[ind_1] != 1 and ind_1 < n:
			if ind_1 == n - 1:
				break
			ind_1 += 1
	if ind_2 < n:
		while num_lt[ind_2] != 2 and ind_2 < n:
			if ind_2 == n - 1:
				break
			ind_2 += 1
	if ind_3 < n:
		while num_lt[ind_3] != 3 and ind_3 < n:
			if ind_3 == n - 1:
				break
			ind_3 += 1
	if ind_1 < n:
		if num_lt[ind_1] == 1:
			lt1.append(ind_1 + 1)
	if ind_2 < n:
		if num_lt[ind_2] == 2:
			lt2.append(ind_2 + 1)
	if ind_3 < n:
		if num_lt[ind_3] == 3:
			lt3.append(ind_3 + 1)
	if ind_1 <= n - 1:
		ind_1 += 1
	if ind_2 <= n - 1:
		ind_2 += 1
	if ind_3 <= n - 1:
		ind_3 += 1
teams = min(len(lt1), len(lt2), len(lt3))
print(teams)
for i in range(teams):
	print(lt1[i], lt2[i], lt3[i])


a = []
b = []
c = []
(cnt1, cnt2, cnt3) = (0, 0, 0)
n = int(input())
lst = [int(x) for x in input().split()]
for i in range(n):
	if lst[i] == 1:
		a.append(i + 1)
		cnt1 += 1
	elif lst[i] == 2:
		b.append(i + 1)
		cnt2 += 1
	else:
		c.append(i + 1)
		cnt3 += 1
if cnt1 == 0 or cnt2 == 0 or cnt3 == 0:
	print(0)
	exit()
res = min(cnt1, cnt2, cnt3)
print(res)
for i in range(res):
	print(a[i], b[i], c[i])


n = int(input())
l = list(map(int, input().split()))
k = min(l.count(1), l.count(2), l.count(3))
print(k)
m = l.copy()
x = []
y = []
z = []
for i in range(len(l)):
	if l[i] == 1:
		x.append(i + 1)
	elif l[i] == 2:
		y.append(i + 1)
	else:
		z.append(i + 1)
for i in range(k):
	print(x[i], y[i], z[i])


n = int(input())
arr = [int(x) for x in input().split()]
cnt1 = arr.count(1)
cnt2 = arr.count(2)
cnt3 = arr.count(3)
_min = min(cnt1, cnt2, cnt3)
_list = [tup for tup in zip(range(1, n + 1), arr)]
_list.sort(key=lambda tup: tup[1])
print(str(_min))
for i in range(_min):
	print(str(_list[i][0]) + ' ' + str(_list[i + cnt1][0]) + ' ' + str(_list[i + cnt1 + cnt2][0]))


n = int(input())
l = [int(i) for i in input().split()]
a = l.count(1)
b = l.count(2)
c = l.count(3)
m = min(a, b, c)
if m == 0:
	print(m)
else:
	print(m)
	x = []
	y = []
	z = []
	for j in range(n):
		if l[j] == 1:
			x.append(j + 1)
		elif l[j] == 2:
			y.append(j + 1)
		else:
			z.append(j + 1)
	for i in range(m):
		print(x[i], y[i], z[i])


n = int(input())
slist = list(map(int, input().split()))
one = []
two = []
three = []
for x in range(n):
	if slist[x] == 1:
		one.append(x + 1)
	elif slist[x] == 2:
		two.append(x + 1)
	else:
		three.append(x + 1)
num = min(len(one), len(two), len(three))
print(num)
for x in range(num):
	print(one[x], two[x], three[x])


from typing import List, Tuple

def parse_input() -> Tuple[int, List[int]]:
	return (int(input()), [int(x) for x in input().split()])

def solve(n: int, t: List[int]) -> Tuple[int, List[List[int]]]:
	groups = [[], [], []]
	for (idx, elem) in enumerate(t):
		groups[elem - 1].append(idx + 1)
	size = min(len(groups[0]), len(groups[1]), len(groups[2]))
	answer = []
	for n in range(size):
		answer.append([groups[0].pop(), groups[1].pop(), groups[2].pop()])
	return (size, answer)
(n, t) = parse_input()
(size, answer) = solve(n, t)
print(size)
for row in answer:
	print(' '.join([str(x) for x in row]))


l_p = list()
l_m = list()
l_e = list()
_ = input()
l_s = list(map(int, input().split()))
for i in range(len(l_s)):
	if l_s[i] == 1:
		l_p.append(i + 1)
	elif l_s[i] == 2:
		l_m.append(i + 1)
	else:
		l_e.append(i + 1)
n = min(len(l_p), len(l_m), len(l_e))
print(n)
for i in range(n):
	print('%d %d %d' % (l_p[i], l_m[i], l_e[i]))


from collections import defaultdict
n = int(input())
a = list(map(int, input().strip().split()))[:n]
dict1 = defaultdict(list)
count_1 = 0
count_2 = 0
count_3 = 0
for i in range(n):
	if a[i] == 1:
		count_1 += 1
		dict1[count_1].append(i + 1)
	elif a[i] == 2:
		count_2 += 1
		dict1[count_2].append(i + 1)
	else:
		count_3 += 1
		dict1[count_3].append(i + 1)
print(min(count_1, count_2, count_3))
for v in dict1.values():
	if len(v) == 3:
		print(' '.join((str(i) for i in v)))


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


n = int(input())
a = list(map(int, input().split()))
cnt = min(a.count(1), a.count(2), a.count(3))
print(cnt)
if cnt:
	s = 0
	d = 0
	f = 0
	for i in range(cnt):
		s = a.index(1, s) + 1
		d = a.index(2, d) + 1
		f = a.index(3, f) + 1
		print(str(s) + ' ' + str(d) + ' ' + str(f))


s = int(input())
r = list(map(int, input().split()))
noOfTeams = min(r.count(1), r.count(2), r.count(3))
e = []
if noOfTeams > 0:
	for i in range(noOfTeams):
		oneIndex = r.index(1) + 1
		twoIndex = r.index(2) + 1
		threeIndex = r.index(3) + 1
		r[oneIndex - 1] = r[twoIndex - 1] = r[threeIndex - 1] = 0
		e.append((oneIndex, twoIndex, threeIndex))
	print(noOfTeams)
	for j in e:
		print(j[0], j[1], j[2])
else:
	print(noOfTeams)


n = int(input())
students = input().split()
(it_1, it_2, it_3) = (students.count('1'), students.count('2'), students.count('3'))
groups = min([it_1, it_2, it_3])
print(groups)
x = []
if groups > 0:
	for i in range(groups):
		(a, b, c) = (students.index('1'), students.index('2'), students.index('3'))
		print(a + 1, b + 1, c + 1)
		students[a] = 0
		students[b] = 0
		students[c] = 0


import sys
n = int(input())
list1 = [int(x) for x in input().split()]
ek = []
do = []
teen = []
for i in range(n):
	if list1[i] == 1:
		ek.append(i + 1)
	elif list1[i] == 2:
		do.append(i + 1)
	elif list1[i] == 3:
		teen.append(i + 1)
y = min([len(teen), len(ek), len(do)])
if y == 0:
	print(y)
	sys.exit(0)
else:
	print(y)
	for i in range(y):
		print(ek[i], end=' ')
		print(do[i], end=' ')
		print(teen[i], end=' ')
		print()


n = int(input())
arr = list(map(int, input().split()))
(a, b, c) = ([], [], [])
for i in range(n):
	if arr[i] == 1:
		a.append(i + 1)
	elif arr[i] == 2:
		b.append(i + 1)
	else:
		c.append(i + 1)
x = min(len(a), len(b), len(c))
if x > 0:
	print(x)
	for i in range(x):
		print(a[i], b[i], c[i])
else:
	print(0)


n = int(input())
l = [int(x) for x in input().split()]
print(min(l.count(1), l.count(2), l.count(3)))
d = {}
for (i, x) in enumerate(l):
	if x not in d.keys():
		d[x] = [i]
	else:
		d[x].append(i)
for i in range(min(l.count(1), l.count(2), l.count(3))):
	print(d[1][i] + 1, d[2][i] + 1, d[3][i] + 1)


n = int(input())
arr = list(map(int, input().split()))
p = []
m = []
pe = []
for i in range(len(arr)):
	if arr[i] == 1:
		p.append(i)
	elif arr[i] == 2:
		m.append(i)
	else:
		pe.append(i)
if len(p) == 0 or len(m) == 0 or len(pe) == 0:
	print(0)
else:
	mini = min(len(p), len(m), len(pe))
	print(mini)
	for i in range(mini):
		print(p[i] + 1, m[i] + 1, pe[i] + 1)


import pdb
_ = int(input())
n = list(map(int, input().split()))
x = n.count(1)
y = n.count(2)
z = n.count(3)
s = min(x, y, z)
print(s)
for i in range(s):
	a = n.index(1)
	b = n.index(2)
	c = n.index(3)
	print(a + 1, b + 1, c + 1)
	(n[a], n[b], n[c]) = (0, 0, 0)


n = int(input())
l = list(map(int, input().split()))
d = {}
for i in l:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
v = list(d.values())
teams = min(v)
a = l.count(1)
b = l.count(2)
c = l.count(3)
if not a or not b or (not c):
	print(0)
else:
	print(teams)
	while teams:
		one = l.index(1)
		print(one + 1, end=' ')
		l[one] = -1
		two = l.index(2)
		print(two + 1, end=' ')
		l[two] = -1
		three = l.index(3)
		print(three + 1, end=' ')
		l[three] = -1
		print()
		teams -= 1


x = int(input())
s = list(map(int, input().split()))
t = min(s)
k = 0
l = 0
m = 0
j1 = []
j2 = []
j3 = []
for i in range(len(s)):
	if s[i] == 1:
		j1.append(i + 1)
		k = k + 1
	elif s[i] == 2:
		j2.append(i + 1)
		l = l + 1
	else:
		j3.append(i + 1)
		m = m + 1
t = min(k, l, m)
print(t)
for i in range(t):
	print(j1[i], j2[i], j3[i])


t = int(input())
l = [int(x) for x in input().split()]
p = l
if 3 not in l or 2 not in l or 1 not in l:
	print('0')
else:
	s = ''
	count = 0
	while 1:
		if 1 not in l:
			break
		else:
			x = l.index(1)
		if 2 not in l:
			break
		else:
			y = l.index(2)
		if 3 not in l:
			break
		else:
			z = l.index(3)
		l[z] = -1
		l[y] = -1
		l[x] = -1
		count = count + 1
		s = s + str(x + 1) + ' ' + str(y + 1) + ' ' + str(z + 1) + '\n'
	print(count)
	print(s)


a = int(input())
x = list(map(int, input().split()))
satu = x.count(1)
dua = x.count(2)
tiga = x.count(3)
minimal = min(satu, dua, tiga)
if minimal == 0:
	print(minimal)
else:
	print(minimal)
	for z in range(minimal):
		print(x.index(1) + 1, end=' ')
		x[x.index(1)] = 5
		print(x.index(2) + 1, end=' ')
		x[x.index(2)] = 5
		print(x.index(3) + 1)
		x[x.index(3)] = 5


noOfChildrens = int(input())
childrensSpecialization = [int(x) for x in input().split(' ')]
noOfTeams = 0
listOfTeams = []
dictOfSpecialization = {1: [], 2: [], 3: []}
for (index, val) in enumerate(childrensSpecialization):
	dictOfSpecialization[val].append(index + 1)
noOfTeams = min([len(x) for x in dictOfSpecialization.values()])
for i in range(noOfTeams):
	listOfTeams.append(' '.join([str(x) for x in [dictOfSpecialization[1][0], dictOfSpecialization[2][0], dictOfSpecialization[3][0]]]))
	dictOfSpecialization[1].pop(0)
	dictOfSpecialization[2].pop(0)
	dictOfSpecialization[3].pop(0)
print(noOfTeams)
print('\n'.join(listOfTeams))


l = int(input())
lt = list(input().split())
D = {}
D[1] = [0, []]
D[2] = [0, []]
D[3] = [0, []]
for i in range(l):
	D[int(lt[i])][0] += 1
	D[int(lt[i])][1].append(i + 1)
k = D[1][0]
for i in range(2, 4):
	if D[i][0] < k:
		k = D[i][0]
print(k)
for i in range(k):
	print(D[1][1][i], D[2][1][i], D[3][1][i])


def team_olympiad():
	n = int(input())
	members = [int(x) for x in input().split(' ')]
	programming = []
	maths = []
	pe = []
	for (i, member) in enumerate(members):
		if member == 1:
			programming.append(i + 1)
		if member == 2:
			maths.append(i + 1)
		if member == 3:
			pe.append(i + 1)
	min_number_of_possible_teams = min(len(programming), len(maths), len(pe))
	if min_number_of_possible_teams:
		print(min_number_of_possible_teams)
		for i in range(min_number_of_possible_teams):
			print(f'{programming[i]} {maths[i]} {pe[i]}')
	else:
		print(0)
team_olympiad()


a = int(input())
b = list(map(int, input().split()))
c = b.count(1)
d = b.count(2)
e = b.count(3)
if c == 0 or d == 0 or e == 0:
	print(0)
elif c <= d and c <= e:
	print(c)
	while c != 0:
		f = b.index(1)
		g = b.index(2)
		h = b.index(3)
		print('{} {} {}'.format(f + 1, g + 1, h + 1))
		b[f] = 'n'
		b[g] = 'n'
		b[h] = 'n'
		c -= 1
elif d <= c and d <= e:
	print(d)
	while d != 0:
		f = b.index(1)
		g = b.index(2)
		h = b.index(3)
		print('{} {} {}'.format(f + 1, g + 1, h + 1))
		b[f] = 'n'
		b[g] = 'n'
		b[h] = 'n'
		d -= 1
else:
	print(e)
	while e != 0:
		f = b.index(1)
		g = b.index(2)
		h = b.index(3)
		print('{} {} {}'.format(f + 1, g + 1, h + 1))
		b[f] = 'n'
		b[g] = 'n'
		b[h] = 'n'
		e -= 1


n = int(input())
ar = [int(i) for i in input().split()]
one = []
two = []
three = []
(a, b, c) = (0, 0, 0)
for i in range(n):
	if ar[i] == 1:
		one.append(i)
		a += 1
	elif ar[i] == 2:
		two.append(i)
		b += 1
	else:
		three.append(i)
		c += 1
minm = min(min(a, b), c)
print(minm)
for j in range(minm):
	print(one[j] + 1, two[j] + 1, three[j] + 1)


n = int(input())
s = input().split()
(ones, twos, threes) = (0, 0, 0)
(l1, l2, l3) = (set(), set(), set())
for i in range(n):
	if s[i] == '1':
		ones += 1
		l1.add(i)
	elif s[i] == '2':
		twos += 1
		l2.add(i)
	else:
		threes += 1
		l3.add(i)
ans = min(ones, twos, threes)
print(ans)
for i in range(ans):
	print(l1.pop() + 1, l2.pop() + 1, l3.pop() + 1)


n = int(input())
x = list(map(int, input().split()))
a = 0
b = 0
c = 0
index = 1
a_1 = []
a_2 = []
a_3 = []
posicion = 0
aaa = []
cambio = 0
for i in x:
	if i == 1:
		a = a + 1
		a_1.append(index)
	elif i == 2:
		b = b + 1
		a_2.append(index)
	elif i == 3:
		c = c + 1
		a_3.append(index)
	index = index + 1
	if a >= 1 and b >= 1 and (c >= 1):
		a = a - 1
		b = b - 1
		c = c - 1
		posicion = posicion + 1
		cambio = 0
		bbb = [a_1[0], a_2[0], a_3[0]]
		a_1.pop(0)
		a_2.pop(0)
		a_3.pop(0)
		aaa.append(bbb)
print(posicion)
for h in aaa:
	final = h
	for r in final:
		print(r, end=' ')
	print()


n = int(input())
a = [int(x) for x in input().split(' ')[:n]]
on = []
tw = []
thre = []
if 1 in a and 2 in a and (3 in a):
	for i in range(n):
		if a[i] == 1:
			on.append(i + 1)
		elif a[i] == 2:
			tw.append(i + 1)
		else:
			thre.append(i + 1)
	m = min(len(on), len(tw), len(thre))
	print(m)
	for i in range(m):
		print(on[i], tw[i], thre[i], end=' ')
		print()
else:
	print(0)


a = int(input())
t = list(map(int, input().split()))
p = []
m = []
pe = []
for k in range(a):
	if t[k] == 1:
		p.append(k + 1)
	elif t[k] == 2:
		m.append(k + 1)
	elif t[k] == 3:
		pe.append(k + 1)
f = [len(p), len(m), len(pe)]
df = min(f)
print(df)
for c in range(df):
	print(p[c], m[c], pe[c])


n = int(input())
lst = list(map(int, input().split()))
t = 0
s = 0
f = 0
ff = [0]
ss = [0]
tt = [0]
for i in range(n):
	if lst[i] == 1:
		f += 1
		ff.append(i + 1)
	elif lst[i] == 2:
		s += 1
		ss.append(i + 1)
	else:
		t += 1
		tt.append(i + 1)
mini = min(f, s, t)
print(mini)
for i in range(1, mini + 1):
	print(ff[i], ss[i], tt[i])


n = int(input())
m = list(map(int, input().split()))
a = m.count(1)
b = m.count(2)
c = m.count(3)
if a == 0 or b == 0 or c == 0:
	print(0)
	exit()
w = min(a, b, c)
print(w)
for i in range(w):
	d = m.index(1)
	e = m.index(2)
	f = m.index(3)
	print(d + 1, e + 1, f + 1)
	m[d] = 0
	m[e] = 0
	m[f] = 0


inp = int(input())
inp1 = input().split()
list1 = []
list2 = []
list3 = []
one_counter = 0
two_counter = 0
three_counter = 0
(no_of_1, no_of_2, no_of_3) = (0, 0, 0)
for num in inp1:
	if num == '3':
		no_of_3 += 1
	elif num == '2':
		no_of_2 += 1
	else:
		no_of_1 += 1
l = [no_of_3, no_of_2, no_of_1]
l = sorted(l)
if l[0] == 0:
	print(0)
else:
	print(l[0])
	for num in range(len(inp1)):
		if one_counter > l[0] and two_counter > l[0] and (three_counter > l[0]):
			break
		if inp1[num] == '1' and one_counter <= l[0]:
			list1.append(num + 1)
			one_counter += 1
		elif inp1[num] == '2' and two_counter <= l[0]:
			list2.append(num + 1)
			two_counter += 1
		elif inp1[num] == '3' and three_counter <= l[0]:
			list3.append(num + 1)
			three_counter += 1
for x in range(l[0]):
	print(str(list1[x]) + ' ' + str(list2[x]) + ' ' + str(list3[x]))


n = int(input())
A = input().split()
B = list(set(A))
if len(B) < 3:
	print(0)
else:
	t = min((A.count(i) for i in B))
	print(t)
	for i in range(t):
		for j in range(3):
			print(A.index(B[j]) + 1, end=' ')
			A[A.index(B[j])] = 'z'
		print()


n = int(input())
a = list(map(int, input().split()))
b = list()
x1 = 0
a1 = list()
x2 = 0
a2 = list()
x3 = 0
a3 = list()
for i in range(n):
	c = a[i]
	if c == 1:
		x1 += 1
		a1.append(i + 1)
	elif c == 2:
		x2 += 1
		a2.append(i + 1)
	else:
		x3 += 1
		a3.append(i + 1)
c = min(x1, x2, x3)
print(c)
for i in range(c):
	print('{} {} {}'.format(a1[i], a2[i], a3[i]))


def main():
	n = int(input())
	a = list(map(int, input().split()))
	k = min(a.count(1), a.count(2), a.count(3))
	print(k)
	q = {1: [], 2: [], 3: []}
	for i in range(len(a)):
		q[a[i]].append(i + 1)
	for i in range(k):
		print(q[1][i], q[2][i], q[3][i])
main()


n = int(input())
l = list(map(int, input().split()))
a = l.count(1)
b = l.count(2)
c = l.count(3)
if a == 0 or b == 0 or c == 0:
	print('0')
else:
	mn = min([a, b, c])
	print(mn)
	for i in range(mn):
		s = ''
		id = l.index(1)
		l[id] = -1
		s += str(id + 1) + ' '
		id = l.index(2)
		l[id] = -1
		s += str(id + 1) + ' '
		id = l.index(3)
		l[id] = -1
		s += str(id + 1)
		print(s)


def teams(values):
	dict1 = {}
	for i in range(len(values)):
		if values[i] not in dict1:
			dict1[values[i]] = [i + 1]
		else:
			dict1[values[i]].append(i + 1)
	minimum = [len(value) for value in dict1.values()]
	minimum = min(minimum)
	i = 0
	final = []
	while i < minimum:
		if 1 in dict1 and 2 in dict1 and (3 in dict1):
			v = []
			v.append(dict1[1][i])
			v.append(dict1[2][i])
			v.append(dict1[3][i])
			i = i + 1
			final.append(v)
		else:
			break
	return final
n = int(input())
values = list(map(int, input().split()))
final = teams(values)
print(len(final))
for value in final:
	print(*value)


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


input()
a = []
b = []
c = []
i = 1
for x in map(int, input().split()):
	if x == 1:
		a += [i]
	if x == 2:
		b += [i]
	if x == 3:
		c += [i]
	i += 1
i = min(map(len, [a, b, c]))
print(i)
for j in range(i):
	print(a[j], b[j], c[j])


n = int(input())
s = list(map(int, input().split()))
ar = []
ar.append(s.count(1))
ar.append(s.count(2))
ar.append(s.count(3))
o = min(ar)
ar1 = []
ar2 = []
ar3 = []
for i in range(len(s)):
	if s[i] == 1:
		ar1.append(i + 1)
	if s[i] == 2:
		ar2.append(i + 1)
	if s[i] == 3:
		ar3.append(i + 1)
ar4 = []
print(o)
for i in range(o):
	ar4.append(ar1[i])
	ar4.append(ar2[i])
	ar4.append(ar3[i])
	print(*ar4)
	ar4 = []


n = int(input())
skills = list(map(int, input().split()))
w = min(skills.count(1), skills.count(2), skills.count(3))
print(w)
x = y = z = -1
for i in range(w):
	x = skills.index(1, x + 1)
	y = skills.index(2, y + 1)
	z = skills.index(3, z + 1)
	print(x + 1, y + 1, z + 1, sep=' ')


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


n = int(input())
li = [int(x) for x in input().split()]
a = li.count(1)
b = li.count(2)
c = li.count(3)
num = min(a, b, c)
print(num)
for i in range(num):
	x = li.index(1)
	li[x] = None
	y = li.index(2)
	li[y] = None
	z = li.index(3)
	li[z] = None
	print(x + 1, y + 1, z + 1)


n = int(input())
students = list(map(str, input().split()))[:n]
members = 0
position = []
a = students.count('1')
b = students.count('2')
c = students.count('3')
m = min(a, b)
if m == a:
	l = min(a, c)
else:
	l = min(b, c)
print(l)
d = []
e = []
f = []
for i in range(len(students)):
	if students[i] == '1':
		d.append(i + 1)
	elif students[i] == '2':
		e.append(i + 1)
	else:
		f.append(i + 1)
for i in range(l):
	print(d[i], ' ', e[i], ' ', f[i])


number_of_children = input()
categories = input()
categories = categories.split()
dic = dict()
for i in categories:
	cate = int(i)
	dic[cate] = dic.get(cate, 0) + 1
dic[1] = dic.get(1, 0)
dic[2] = dic.get(2, 0)
dic[3] = dic.get(3, 0)
groups = min(dic.values())
if groups == 0:
	print(0)
	quit()
else:
	print(groups)
lst = list()
count = 0
for i in categories:
	count += 1
	cate = int(i)
	lst.append((count, cate))
lsta = list()
for (k, v) in lst:
	lsta.append((v, k))
lsta.sort()
lstb = list()
for i in range(groups):
	lstb.append((lsta[i][1], lsta[i + dic[1]][1], lsta[i + dic[1] + dic[2]][1]))
for (a, b, c) in lstb:
	print(a, b, c)


n = int(input())
Vi = list(map(int, input().split()))
V1 = [i + 1 for i in range(0, n) if Vi[i] == 1]
V2 = [i + 1 for i in range(0, n) if Vi[i] == 2]
V3 = [i + 1 for i in range(0, n) if Vi[i] == 3]
Len = min(len(V1), len(V2), len(V3))
print(Len)
for i in range(0, Len):
	print('%d %d %d' % (V1[i], V2[i], V3[i]))


n = int(input())
ipt = [int(x) for x in input().split()]
l1 = []
l2 = []
l3 = []
for (i, val) in enumerate(ipt, 1):
	if val == 1:
		l1.append(i)
	elif val == 2:
		l2.append(i)
	else:
		l3.append(i)
if l1 != [] and l2 != [] and (l3 != []):
	min_len = min(len(l1), len(l2), len(l3))
	print(min_len)
	for i in range(min_len):
		print(l1[i], l2[i], l3[i])
else:
	print(0)


a = int(input())
b = [int(i) for i in input().split()]
first = list()
second = list()
third = list()
for i in range(a):
	if b[i] == 1:
		first.append(i + 1)
	elif b[i] == 2:
		second.append(i + 1)
	elif b[i] == 3:
		third.append(i + 1)
if len(first) > 0 and len(second) > 0 and (len(third) > 0):
	print(min(len(first), len(second), len(third)))
	for x in range(min(len(first), len(second), len(third))):
		print(first[x], second[x], third[x])
else:
	print(0)


_ = int(input())
s = list(map(int, input().split()))
x = min(s.count(1), s.count(2), s.count(3))
print(x)

def zero(s, i):
	s[i] = 0
	return s
for _ in range(x):
	temp = str()
	for skill in [1, 2, 3]:
		i = s.index(skill)
		temp += str(i + 1) + ' '
		s = zero(s, i)
	print(temp)


number_of_children = int(input())
x = list(map(int, input().split()))
child_is_good_at_programing = []
child_is_good_at_maths = []
child_is_good_at_PE = []
for i in range(number_of_children):
	if x[i] == 1:
		child_is_good_at_programing.append(i + 1)
	elif x[i] == 2:
		child_is_good_at_maths.append(i + 1)
	elif x[i] == 3:
		child_is_good_at_PE.append(i + 1)
number_of_grops = min(len(child_is_good_at_programing), len(child_is_good_at_maths), len(child_is_good_at_PE))
print(number_of_grops)
for i in range(number_of_grops):
	print(child_is_good_at_programing[i], child_is_good_at_maths[i], child_is_good_at_PE[i])


n = int(input())
lista = [int(x) for x in input().split()]
times = 0
mat = 0
prog = 0
pe = 0
pp = []
mm = []
ppe = []
for x in range(n):
	if lista[x] == 1:
		prog += 1
		pp.append(x + 1)
	elif lista[x] == 2:
		mat += 1
		mm.append(x + 1)
	elif lista[x] == 3:
		pe += 1
		ppe.append(x + 1)
times = min(mat, prog, pe)
print(times)
for x in range(times):
	print(pp[x], mm[x], ppe[x])


import re
from collections import Counter
(n, data_list) = (int(input()), list(input().split()))
data = Counter(data_list)
index = {'1': [], '2': [], '3': []}
for (num, i) in enumerate(data_list):
	index[i].append(num + 1)
if not re.search('1+2+3+', ''.join(sorted(data_list))):
	print(0)
	exit()
if data.get(' '):
	del data[' ']
w = min(data.values())
print(w)
for (t1, t2, t3) in zip(*map(lambda i: i[:w], index.values())):
	print(t1, t2, t3)


n = int(input())
t = list(map(int, input().split(' ')))
c = min(t.count(1), t.count(2), t.count(3))
print(c)
p1 = p2 = p3 = 0
for i in range(c):
	p1 = t.index(1, p1) + 1
	p2 = t.index(2, p2) + 1
	p3 = t.index(3, p3) + 1
	print(p1, p2, p3, sep=' ')


def team(n):
	students = [int(i) for i in input().split()]
	w = min(students.count(1), students.count(2), students.count(3))
	print(w)
	(lst1, lst2, lst3) = ([], [], [])
	for i in range(n):
		if students[i] == 1:
			lst1.append(i + 1)
		elif students[i] == 2:
			lst2.append(i + 1)
		else:
			lst3.append(i + 1)
	for i in range(w):
		print(lst1[i], lst2[i], lst3[i])

def main():
	team(int(input()))
main()


n = input()
s = input().split()
ss = sorted(s)
nt = 0
ones = 0
twos = 0
threes = 0
for item in s:
	if int(item) == 1:
		ones += 1
	elif int(item) == 2:
		twos += 1
	else:
		threes += 1
nt = min(ones, twos, threes)
p = []
print(nt)
indxuno = []
indxdos = []
indxtres = []
for (i, j) in enumerate(s):
	if int(j) == 1:
		indxuno.append(i)
		continue
	elif int(j) == 2:
		indxdos.append(i)
		continue
	else:
		indxtres.append(i)
for i in range(nt):
	print(int(indxuno[i]) + 1, int(indxdos[i]) + 1, int(indxtres[i]) + 1)


n = int(input())
t = input().split()
a = []
b = []
c = []
for i in range(1, n + 1):
	if t[i - 1] == '1':
		a.append(i)
	elif t[i - 1] == '2':
		b.append(i)
	else:
		c.append(i)
ans = min(len(a), len(b), len(c))
print(ans)
for i in range(ans):
	print(str(a.pop()) + ' ' + str(b.pop()) + ' ' + str(c.pop()))


import math
import os
import random
import re
import sys

def index(a_list, value):
	try:
		return a_list.index(value)
	except ValueError:
		return -1
n = int(input())
arr = list(map(int, input().split()))
if index(arr, 1) == -1 or index(arr, 2) == -1 or index(arr, 3) == -1:
	print(0)
else:
	ans = [[], [], []]
	for i in range(n):
		if arr[i] == 1:
			ans[0].append(i + 1)
		elif arr[i] == 2:
			ans[1].append(i + 1)
		else:
			ans[2].append(i + 1)
	a = min(len(ans[0]), len(ans[1]), len(ans[2]))
	print(a)
	for i in range(a):
		print(ans[0][i], ans[1][i], ans[2][i])


n = int(input())
t = list(map(int, input().split()))
pr = 0
ma = 0
ed = 0
l = []
p = []
m = []
e = []
x = set(t)
if len(x) == 3:
	for i in range(1, n + 1):
		if t[i - 1] == 1:
			p.append(i)
			pr += 1
		elif t[i - 1] == 2:
			m.append(i)
			ma += 1
		else:
			e.append(i)
			ed += 1
	l.append(pr)
	l.append(ma)
	l.append(ed)
	if pr >= 1 and ma >= 1 and (ed >= 1):
		print(min(l))
		w = min(l)
		for i in range(w):
			print(p[i], m[i], e[i])
else:
	print(0)


n = int(input())
t = [int(x) for x in input().split()]
t1 = t.count(1)
t2 = t.count(2)
t3 = t.count(3)
nb_equipe = min(t1, t2, t3)
print(nb_equipe)
for x in range(nb_equipe):
	equipe = []
	equipe.append(t.index(1) + 1)
	equipe.append(t.index(2) + 1)
	equipe.append(t.index(3) + 1)
	t[t.index(1)] = 0
	t[t.index(2)] = 0
	t[t.index(3)] = 0
	print(' '.join([str(x) for x in equipe]))


n = input()
a = list(map(int, input().split()))
f1 = 0
f2 = 0
f3 = 0
a1 = []
a2 = []
a3 = []
for i in range(len(a)):
	if a[i] == 1:
		f1 += 1
		a1.append(i)
	elif a[i] == 2:
		f2 += 1
		a2.append(i)
	else:
		f3 += 1
		a3.append(i)
f = min(f1, f2, f3)
print(f)
for i in range(f):
	print(a1[i] + 1, a2[i] + 1, a3[i] + 1)


n = int(input())
arr = list(map(int, input().split()))
m = {}
for i in arr:
	if i in m:
		m[i] += 1
	else:
		m[i] = 1
if len(m) < 3:
	print(0)
else:
	v = list(m.values())
	print(min(v))
	for i in range(0, min(v) * 3):
		if i > 2 and i % 3 == 0:
			print('')
		x = arr.index(i % 3 + 1)
		arr[x] = -1
		print(x + 1, end=' ')
	print('')


n = int(input())
ls = list(map(int, input().split()))
d = {}
d[1] = []
d[2] = []
d[3] = []
for i in range(n):
	d[ls[i]] = d[ls[i]] + [i + 1]
mxt = min(len(d[1]), len(d[2]), len(d[3]))
print(mxt)
for i in range(mxt):
	print(d[1][i], d[2][i], d[3][i])


n = int(input())
s = list(map(int, input().split()))
(c1, c2, c3) = (s.count(1), s.count(2), s.count(3))
com = min(c1, c2, c3)
print(com)
com_list = []
(s1, s2, s3) = (0, 0, 0)
for i in range(com):
	s1 = s.index(1, s1)
	s2 = s.index(2, s2)
	s3 = s.index(3, s3)
	com_list.append(s1)
	com_list.append(s2)
	com_list.append(s3)
	com_list = [j + 1 for j in com_list]
	print(*com_list, sep=' ')
	com_list = []
	(s1, s2, s3) = (s1 + 1, s2 + 1, s3 + 1)


n = int(input())
t = list(map(int, input().split()))
t1 = t.count(1)
t2 = t.count(2)
t3 = t.count(3)
if t1 <= t2 and t1 <= t3:
	print(t1)
	kolvo = t1
elif t2 <= t1 and t2 <= t3:
	print(t2)
	kolvo = t2
elif t3 <= t1 and t3 <= t2:
	print(t3)
	kolvo = t3
for i in range(kolvo):
	print(t.index(1) + 1, end=' ')
	t[t.index(1)] = 0
	print(t.index(2) + 1, end=' ')
	t[t.index(2)] = 0
	print(t.index(3) + 1, end=' ')
	t[t.index(3)] = 0
	print()


n = int(input())
(pro, math, pe) = ([], [], [])
students = [int(x) for x in input().split()]
for i in range(n):
	if students[i] == 1:
		pro.append(i + 1)
	elif students[i] == 2:
		math.append(i + 1)
	else:
		pe.append(i + 1)
print(min(min(len(pro), len(math)), len(pe)))
while len(pro) > 0 and len(math) > 0 and (len(pe) > 0):
	print(str(pro.pop()) + ' ' + str(math.pop()) + ' ' + str(pe.pop()))


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


n = int(input())
a = list(map(int, input().split()))
x = []
y = []
z = []
for (b, i) in enumerate(a):
	if i == 1:
		x.append(b)
	elif i == 2:
		y.append(b)
	else:
		z.append(b)
l = min(len(x), min(len(y), len(z)))
print(l)
for i in range(l):
	print(x[i] + 1, y[i] + 1, z[i] + 1)


n = int(input())
l = list(map(int, input().split()))
l1 = []
l2 = []
l3 = []
for i in range(len(l)):
	if l[i] == 1:
		l1.append(i + 1)
	elif l[i] == 2:
		l2.append(i + 1)
	else:
		l3.append(i + 1)
M = [len(l1), len(l2), len(l3)]
N = min(M)
print(N)
for i in range(N):
	print(l1[i], l2[i], l3[i])


import math
import os
import random
import re
import sys
from operator import itemgetter, attrgetter
(n, t) = (int(input()), [int(x) for x in input().strip().split()])
(a, b, c) = ([[], [], []], 10 ** 6, [])
for i in range(n):
	a[t[i] - 1].append(i + 1)
for i in range(3):
	b = len(a[i]) if len(a[i]) < b else b
for i in range(b):
	c.append((a[0][i], a[1][i], a[2][i]))
print(b)
if b > 0:
	for i in c:
		print(' '.join([str(x) for x in i]))


stu = int(input())
valist = [int(x) for x in input().split()]
ma = pr = pe = 0
prlista = []
prlistb = []
prlistc = []
for i in range(stu):
	if valist[i] == 1:
		ma += 1
	if valist[i] == 2:
		pr += 1
	if valist[i] == 3:
		pe += 1
team = min(ma, pr, pe)
for j in range(len(valist)):
	if valist[j] == 1:
		prlista.append(j)
	if valist[j] == 2:
		prlistb.append(j)
	if valist[j] == 3:
		prlistc.append(j)
print(team)
for i in range(team):
	print(prlista[i] + 1, prlistb[i] + 1, prlistc[i] + 1)


n = int(input())
a = list(map(int, input().split()))
q = min(a.count(1), a.count(2), a.count(3))
if q > 0:
	print(min(a.count(1), a.count(2), a.count(3)))
	while q:
		print(a.index(1) + 1, end=' ')
		a[a.index(1)] = 5
		print(a.index(2) + 1, end=' ')
		a[a.index(2)] = 5
		print(a.index(3) + 1, end=' ')
		a[a.index(3)] = 5
		q -= 1
		print()
else:
	print(0)


n = int(input())
a = list(map(int, input().split()))
l1 = []
l2 = []
l3 = []
for i in range(len(a)):
	if a[i] == 1:
		l1.append(i + 1)
	elif a[i] == 2:
		l2.append(i + 1)
	else:
		l3.append(i + 1)
print(min(len(l1), len(l2), len(l3)))
for i in range(min(len(l1), len(l2), len(l3))):
	print(l1[i], l2[i], l3[i])


n = int(input())
a = list(map(int, input().split()))
b = [0] * 4
c = [[] for i in range(4)]
for i in range(len(a)):
	b[a[i]] = b[a[i]] + 1
	c[a[i]].append(i)
print(min(b[1:]))
set_ = set()
j = 0
i = 0
k = min(b[1:])
i = 1
while k > 0:
	if b[i] != 0:
		b[i] = b[i] - 1
		set_.add(c[i][0] + 1)
		c[i].pop(0)
	if len(set_) == 3:
		print(*set_)
		set_ = set()
		k = k - 1
	i = i + 1
	if i == 4:
		i = 1


n = int(input())
l = list(map(int, input().split()))
(a, b, c) = ([], [], [])
for i in range(n):
	if l[i] == 1:
		a.append(i + 1)
	elif l[i] == 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])


length = int(input())
count = 0
check = list(map(int, input().split()))
values = check[:]
for i in range(length // 2):
	if 1 in check and 2 in check and (3 in check):
		count += 1
		check[check.index(1)] = 0
		check[check.index(2)] = 0
		check[check.index(3)] = 0
print(count)
if count > 0:
	for i in range(length // 2):
		if 1 in values and 2 in values and (3 in values):
			print(values.index(1) + 1, values.index(2) + 1, values.index(3) + 1)
			values[values.index(1)] = 0
			values[values.index(2)] = 0
			values[values.index(3)] = 0


n = int(input())
l = [] * n
l = input().split(' ')
l = [int(i) for i in l]
l1 = []
l2 = []
l3 = []
for i in range(n):
	if l[i] == 1:
		l1.append(i + 1)
	elif l[i] == 2:
		l2.append(i + 1)
	else:
		l3.append(i + 1)
c = min(len(l1), len(l2), len(l3))
if l1 == [] or l2 == [] or l3 == []:
	print(0)
else:
	print(c)
	for i in range(c):
		print(l1[i], l2[i], l3[i])


n = int(input())
f = [int(i) for i in input().split()]
h = min(f.count(1), f.count(2), f.count(3))
if h == 0:
	print(0)
else:
	print(h)
	for i in range(h):
		(a, b, v) = (f.index(1), f.index(2), f.index(3))
		l = [a + 1, b + 1, v + 1]
		(f[a], f[b], f[v]) = (0, 0, 0)
		print(*l)


M = int(input())
l = [int(i) for i in input().split()]
t = []
d = dict()
for i in range(len(l)):
	if l[i] in d.keys():
		d[l[i]].append(i + 1)
	else:
		d[l[i]] = [i + 1]
c = 0
if 1 not in l or 2 not in l or 3 not in l:
	print(c)
else:
	while 1:
		if d[1] != [] and d[2] != [] and (d[3] != []):
			t.append(d[1][0])
			t.append(d[2][0])
			t.append(d[3][0])
			d[1].pop(0)
			d[2].pop(0)
			d[3].pop(0)
			c += 1
		else:
			break
	print(c)
	for k in range(0, len(t), 3):
		print(t[k], end=' ')
		print(t[k + 1], end=' ')
		print(t[k + 2], end=' ')
		print()


n = int(input())
a = [int(i) for i in input().split()]
b = a.count(1)
c = a.count(2)
d = a.count(3)
mine = min(b, c, d)
print(mine)
for i in range(mine):
	x = []
	z = a.index(1)
	zz = a.index(2)
	zzz = a.index(3)
	x.append(z)
	x.append(zz)
	x.append(zzz)
	a[z] = 0
	a[zz] = 0
	a[zzz] = 0
	print(x[0] + 1, x[1] + 1, x[2] + 1, end=' ')


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 = list(map(int, input().split()))
p = t.count(1)
m = t.count(2)
e = t.count(3)
w = min(p, m, e)
print(w)
if w != 0:
	for i in range(w):
		for j in range(1, 3):
			a = t.index(j)
			print(a + 1, end=' ')
			t[a] = 0
		a = t.index(3)
		print(a + 1)
		t[a] = 0


import sys
n = sys.stdin.readline()
n = int(n)
lista = [int(i) for i in sys.stdin.readline().split()]
ones = []
two = []
three = []
for (i, val) in enumerate(lista):
	if val == 1:
		ones.append(str(i + 1))
	elif val == 2:
		two.append(str(i + 1))
	else:
		three.append(str(i + 1))
minval = min(len(ones), len(two), len(three))
print(minval)
if minval > 0:
	for i in range(minval):
		print(' '.join([ones[i], two[i], three[i]]))


n = int(input())
arr = list(map(int, input().split()))
(one, two, three, One, Two, Three) = (0, 0, 0, [], [], [])
for (i, j) in enumerate(arr):
	if j == 1:
		one += 1
		One.append(i + 1)
	elif j == 2:
		two += 1
		Two.append(i + 1)
	elif j == 3:
		three += 1
		Three.append(i + 1)
(i1, i2, i3, ans, Ans) = (0, 0, 0, 0, [])
while one > 0 and two > 0 and (three > 0):
	one -= 1
	two -= 1
	three -= 1
	ans += 1
	Ans.append((One[i1], Two[i2], Three[i3]))
	i1 += 1
	i2 += 1
	i3 += 1
if ans == 0:
	print(ans)
else:
	print(ans)
	for i in Ans:
		print(i[0], i[1], i[2])


import math
n = int(input())
arr = [int(x) for x in input().split()]
tot1s = []
tot2s = []
tot3s = []
for i in range(n):
	if arr[i] == 1:
		tot1s.append(i + 1)
	elif arr[i] == 2:
		tot2s.append(i + 1)
	else:
		tot3s.append(i + 1)
totPossibleTeams = min(min(len(tot1s), len(tot2s)), len(tot3s))
print(totPossibleTeams)
for i in range(totPossibleTeams):
	print(str(tot1s[i]) + ' ' + str(tot2s[i]) + ' ' + str(tot3s[i]))


n = int(input())
s = [int(a) for a in input().split()]
first = s.count(1)
second = s.count(2)
third = s.count(3)
team = min(first, second, third)
print(team)
x = []
y = []
z = []
for j in range(len(s)):
	if s[j] == 1:
		x.append(j + 1)
	elif s[j] == 2:
		y.append(j + 1)
	else:
		z.append(j + 1)
for i in range(team):
	print('{} {} {}'.format(x[i], y[i], z[i]))


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


(n, stu) = (int(input()), list(map(int, input().split(' '))))
l1 = []
l2 = []
l3 = []
for i in range(n):
	if stu[i] == 1:
		l1.append(i + 1)
	elif stu[i] == 2:
		l2.append(i + 1)
	else:
		l3.append(i + 1)
s = min(len(l1), len(l2), len(l3))
print(s)
if s != 0:
	for i in range(s):
		print(l1[i], l2[i], l3[i])


input()
a = list(map(int, input().split()))
b = {1: [0], 2: [0], 3: [0]}
for i in range(len(a)):
	b[a[i]].append(i + 1)
	b[a[i]][0] += 1
print(min(b[1][0], b[2][0], b[3][0]))
for i in range(min(b[1][0], b[2][0], b[3][0])):
	print(b[1][i + 1], b[2][i + 1], b[3][i + 1])


input()
pro = set()
mat = set()
phy = set()
data = [int(x) for x in input().split()]
for i in range(len(data)):
	if data[i] == 1:
		pro.add(i + 1)
	elif data[i] == 2:
		mat.add(i + 1)
	else:
		phy.add(i + 1)
ans = min(len(pro), len(mat), len(phy))
print(ans)
for x in range(ans):
	print(pro.pop(), mat.pop(), phy.pop())


n = int(input())
t = input().split()
w = min(t.count('1'), t.count('2'), t.count('3'))
print(w)
if w == 0:
	exit(0)
for i in range(w):
	a = t.index('1')
	b = t.index('2')
	c = t.index('3')
	print(a + 1, b + 1, c + 1)
	t[a] = 0
	t[b] = 0
	t[c] = 0


n = int(input())
ls = list(map(int, input().split()))
(prg, math, phy) = (0, 0, 0)
for i in ls:
	if i == 1:
		prg += 1
	elif i == 2:
		math += 1
	else:
		phy += 1
teams = min(phy, math, prg)
print(teams)
(i, j, k) = (0, 0, 0)
for m in range(teams):
	programmer = ls[i + m:].index(1) + i
	mathm = ls[j + m:].index(2) + j
	phys = ls[k + m:].index(3) + k
	(i, j, k) = (programmer, mathm, phys)
	print(programmer + 1 + m, mathm + 1 + m, phys + 1 + m)


n = int(input())
children = [int(x) for x in input().split()]
prgm = []
math = []
pe = []
for i in range(len(children)):
	if children[i] == 1:
		prgm.append(i + 1)
	elif children[i] == 2:
		math.append(i + 1)
	else:
		pe.append(i + 1)
print(min(len(prgm), len(math), len(pe)))
if min(len(prgm), len(math), len(pe)) != 0:
	for i in range(min(len(prgm), len(math), len(pe))):
		print(prgm[i], math[i], pe[i])


n = int(input())
a = list(map(int, input().split()))
ones = [i + 1 for (i, y) in enumerate(a) if y == 1]
twos = [i + 1 for (i, y) in enumerate(a) if y == 2]
threes = [i + 1 for (i, y) in enumerate(a) if y == 3]
teams = min(a.count(1), a.count(2), a.count(3))
print(teams)
for i in range(teams):
	print(ones[i], twos[i], threes[i])


a = int(input())
b = input().split()
c = [list(filter(lambda x: b[x] == i, range(a))) for i in '123']
d = min(map(len, c))
print(d)
for i in range(d):
	print(' '.join([str(c[j][i] + 1) for j in range(3)]))


def process(p):
	x = p.count(1)
	y = p.count(2)
	z = p.count(3)
	m = min(x, y, z)
	print(m)
	if m != 0:
		i = 0
		while i < m:
			a = p.index(1)
			b = p.index(2)
			c = p.index(3)
			print('{} {} {}'.format(a + 1, b + 1, c + 1))
			p[a] = 4
			p[b] = 4
			p[c] = 4
			i += 1

def main():
	t = int(input())
	p = [int(x) for x in input().split()]
	process(p)
main()


number = int(input())
alist = list(map(int, input().split()))
mmmin = min(alist.count(3), alist.count(1), alist.count(2))
print(mmmin)
for i in range(mmmin):
	print(alist.index(1) + 1, alist.index(2) + 1, alist.index(3) + 1)
	alist[alist.index(1)] = 0
	alist[alist.index(2)] = 0
	alist[alist.index(3)] = 0


sp = []
n = int(input())
sp1 = input().split()
t1 = 0
t2 = 0
t3 = 0
for i in sp1:
	if int(i) == 1:
		t1 += 1
	elif int(i) == 2:
		t2 += 1
	else:
		t3 += 1
print(min(t1, t2, t3))
for i in range(min(t1, t2, t3)):
	sp.append(int(sp1.index('1')) + 1)
	sp1[sp1.index('1')] = 0
	sp.append(int(sp1.index('2')) + 1)
	sp1[sp1.index('2')] = 0
	sp.append(int(sp1.index('3')) + 1)
	sp1[sp1.index('3')] = 0
for i in range(0, len(sp), 3):
	print(sp[i], sp[i + 1], sp[i + 2])


input()
lists = {'1': [], '2': [], '3': []}
cnt = 0
comp = []
for (idx, skill) in enumerate(input().split()):
	lists[skill].append(idx + 1)
(prg, math, pe) = lists.values()
if len(prg) and len(math) and len(pe):
	while len(prg) and len(math) and len(pe):
		cnt += 1
		comp.append(f'{prg.pop()} {math.pop()} {pe.pop()}')
	print(cnt)
	print('\n'.join(comp))
else:
	print(0)


n = int(input())
l = list(map(int, input().split()))
m = []
p = []
c = []
for i in range(n):
	if l[i] == 1:
		m.append(i)
	elif l[i] == 2:
		p.append(i)
	elif l[i] == 3:
		c.append(i)
x = min(len(m), len(p), len(c))
print(x)
for i in range(x):
	print(m[i] + 1, p[i] + 1, c[i] + 1)


n = int(input())
L = [int(x) for x in input().split()]
m = min(L.count(1), L.count(2), L.count(3))
print(m)
for i in range(m):
	print(L.index(1) + 1, 1 + L.index(2), 1 + L.index(3))
	L[L.index(1)] = 0
	L[L.index(2)] = 0
	L[L.index(3)] = 0


n = int(input())
l = list(map(int, input().split()))
d = {1: [], 2: [], 3: []}
for i in range(n):
	d[l[i]].append(i + 1)
m = min(len(d[1]), len(d[2]), len(d[3]))
if m != 0:
	print(m)
	for i in range(m):
		print(d[1].pop(), d[2].pop(), d[3].pop())
else:
	print(0)


n = int(input())
t = list(map(int, input().split()))
p = m = f = 0
w = []
while p < n and m < n and (f < n):
	while p < n and t[p] != 1:
		p += 1
	while m < n and t[m] != 2:
		m += 1
	while f < n and t[f] != 3:
		f += 1
	if p < n and m < n and (f < n):
		w += [[str(p + 1), str(m + 1), str(f + 1)]]
		p += 1
		m += 1
		f += 1
print(len(w))
for el in w:
	print(' '.join(el))


a = input()
b = input()
b = b.split(' ')
OnesIndexes = []
TowsIndexes = []
ThreesIndexes = []
counter = 1
for i in b:
	if i == '1':
		OnesIndexes.append(counter)
	elif i == '2':
		TowsIndexes.append(counter)
	else:
		ThreesIndexes.append(counter)
	counter = counter + 1
n1 = len(OnesIndexes)
n2 = len(TowsIndexes)
n3 = len(ThreesIndexes)
arr = [n1, n2, n3]
arr.sort()
MaxTeams = arr[0]
arr2 = []
for i in range(MaxTeams):
	m1 = str(OnesIndexes[i])
	m2 = str(TowsIndexes[i])
	m3 = str(ThreesIndexes[i])
	Team = m1 + ' ' + m2 + ' ' + m3 + '\n'
	arr2.append(Team)
arr2 = ''.join(arr2)
arr2 = arr2[0:len(arr2) - 1]
print(MaxTeams)
print(arr2)


a = int(input())
lis = list(map(int, input().split()))
d = min(lis.count(1), lis.count(2), lis.count(3))
print(d)
for i in range(d):
	u = lis.index(1)
	v = lis.index(2)
	w = lis.index(3)
	print(u + 1, v + 1, w + 1)
	lis[u] = 0
	lis[v] = 0
	lis[w] = 0


def index(a_list, value):
	try:
		return a_list.index(value)
	except ValueError:
		return -1
n = int(input())
arr = list(map(int, input().split()))
if index(arr, 1) == -1 or index(arr, 2) == -1 or index(arr, 3) == -1:
	print(0)
else:
	ans = [[], [], []]
	for i in range(n):
		if arr[i] == 1:
			ans[0].append(i + 1)
		elif arr[i] == 2:
			ans[1].append(i + 1)
		else:
			ans[2].append(i + 1)
	a = min(len(ans[0]), len(ans[1]), len(ans[2]))
	print(a)
	for i in range(a):
		print(ans[0][i], ans[1][i], ans[2][i])


n = int(input())
a = list(map(int, input().split()))
res = min(a.count(1), a.count(2), a.count(3))
print(res)
for i in range(res):
	(c, d, e) = (a.index(1), a.index(2), a.index(3))
	(a[c], a[d], a[e]) = (0, 0, 0)
	print(c + 1, d + 1, e + 1)


import sys
n = int(sys.stdin.readline())
talents_list = [int(x) for x in sys.stdin.readline().split()]
talents = [[], [], []]
i = 1
for t in talents_list:
	talents[t - 1].append(i)
	i += 1
if [] in talents:
	print(0)
else:
	w = min([len(l) for l in talents])
	print(w)
	for i in range(w):
		print(' '.join([str(l.pop(0)) for l in talents]))


def index1(x):
	for i in range(x, n):
		if a[i] == 1:
			return i

def index2(x):
	for i in range(x, n):
		if a[i] == 2:
			return i

def index3(x):
	for i in range(x, n):
		if a[i] == 3:
			return i
n = int(input())
a = list(map(int, input().split()))
b1 = 0
b2 = 0
b3 = 0
for i in range(n):
	if a[i] == 1:
		b1 += 1
	elif a[i] == 2:
		b2 += 1
	else:
		b3 += 1
if b1 <= b2 and b1 <= b3:
	print(b1)
	z = b1
elif b2 <= b1 and b2 <= b3:
	print(b2)
	z = b2
else:
	print(b3)
	z = b3
l1 = 0
l2 = 0
l3 = 0
for i in range(z):
	l1 = index1(x=l1)
	l2 = index2(x=l2)
	l3 = index3(x=l3)
	print(l1 + 1, ' ', l2 + 1, ' ', l3 + 1)
	l1 += 1
	l2 += 1
	l3 += 1


n = int(input())
a = b = c = 0
lt = list(map(int, input().split()))
a = lt.count(1)
b = lt.count(2)
c = lt.count(3)
if a != 0 and b != 0 and (c != 0):
	print(min(a, b, c))
	for i in range(min(a, b, c)):
		print(str(lt.index(1) + 1) + ' ' + str(lt.index(2) + 1) + ' ' + str(lt.index(3) + 1))
		for i in range(1, 4):
			lt[lt.index(i)] = 0
else:
	print('0')


from sys import stdin
_input = stdin.readline
(_len, _int, _range, _min) = (len, int, range, min)

def solution():
	n = _int(_input())
	arr = [_int(i) for i in _input().split()]
	group = [[], [], []]
	for i in _range(n):
		group[arr[i] - 1].append(i + 1)
	f = _min([_len(i) for i in group])
	print(f)
	if f > 0:
		for i in zip(*group):
			print(*i)
solution()


a = int(input())
b = [int(b) for b in input().split()]
c = min(b.count(1), b.count(2), b.count(3))
print(c)
if c > 0:
	d = list()
	r = 0
	while r < c:
		index = [b.index(1), b.index(2), b.index(3)]
		b[index[0]] = 0
		b[index[1]] = 0
		b[index[2]] = 0
		index[0] = str(index[0] + 1)
		index[1] = str(index[1] + 1)
		index[2] = str(index[2] + 1)
		print(' '.join((char for char in index)))
		r = r + 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())
students = list(map(int, input().split()))
programming = []
maths = []
pe = []
for i in range(len(students)):
	if students[i] == 1:
		programming.append(i + 1)
	elif students[i] == 2:
		maths.append(i + 1)
	elif students[i] == 3:
		pe.append(i + 1)
ans = min(len(programming), len(maths), len(pe))
print(ans)
for i in range(ans):
	print(programming[i], maths[i], pe[i])


n = int(input())
kidins = [int(x) for x in input().split()]
t1s = []
t2s = []
t3s = []
for j in range(len(kidins)):
	if kidins[j] == 1:
		t1s.append(j + 1)
	elif kidins[j] == 2:
		t2s.append(j + 1)
	else:
		t3s.append(j + 1)
tmin = min(len(t1s), len(t2s), len(t3s))
if tmin == 0:
	print(0)
else:
	print(tmin)
	for j in range(tmin):
		ans = [t1s[j], t2s[j], t3s[j]]
		print(*ans)


n = int(input())
s = [[] for i in range(3)]
j = 0
for i in map(int, input().split()):
	s[i - 1].append(j)
	j += 1
min_s = len(min(s, key=lambda x: len(x)))
print(min_s)
if min_s > 0:
	for i in range(min_s):
		print(s[0][i] + 1, s[1][i] + 1, s[2][i] + 1)


n = int(input())
l = input().split()
count = min(l.count('1'), l.count('2'), l.count('3'))
print(count)
if count:
	for i in range(count):
		p1 = l.index('1')
		p2 = l.index('2')
		p3 = l.index('3')
		print(p1 + 1, p2 + 1, p3 + 1)
		l[p1] = '0'
		l[p3] = '0'
		l[p2] = '0'


students = int(input())
student_skill = list(map(int, input().split()))
program_student = []
math_student = []
pe_student = []
for i in range(students):
	if student_skill[i] == 1:
		program_student.append(i + 1)
	elif student_skill[i] == 2:
		math_student.append(i + 1)
	else:
		pe_student.append(i + 1)
i = 0
print(min(min(len(pe_student), len(math_student)), len(program_student)))
while i < len(pe_student) and i < len(math_student) and (i < len(program_student)):
	print(program_student[i], math_student[i], pe_student[i])
	i += 1


n = int(input())
scores = list(map(int, input().split()))
ones = []
twos = []
threes = []
teams = []
for i in range(n):
	if scores[i] == 1:
		ones.append(i + 1)
	elif scores[i] == 2:
		twos.append(i + 1)
	else:
		threes.append(i + 1)
no_teams = min([len(ones), len(twos), len(threes)])
proceed = True
while proceed:
	if len(ones) > 0 and len(twos) > 0 and (len(threes) > 0):
		prog = ones[0]
		del ones[0]
		math = twos[0]
		del twos[0]
		phy = threes[0]
		del threes[0]
		teams.append([prog, math, phy])
	else:
		proceed = False
print(no_teams)
for team in teams:
	print(team[0], team[1], team[2])


import sys
n = int(input())
x = list(map(int, input().split()))
t1 = []
t2 = []
t3 = []
for i in range(len(x)):
	if x[i] == 1:
		t1.append(i + 1)
	elif x[i] == 2:
		t2.append(i + 1)
	elif x[i] == 3:
		t3.append(i + 1)
x = min(len(t1), len(t2), len(t3))
if x < 1:
	print(0)
	sys.exit()
else:
	print(x)
	for i in range(x):
		print(t1[i], t2[i], t3[i])


n = int(input())
arr = list(map(int, input().split()))
c1 = [key + 1 for (key, i) in enumerate(arr) if i == 1]
c2 = [key + 1 for (key, i) in enumerate(arr) if i == 2]
c3 = [key + 1 for (key, i) in enumerate(arr) if i == 3]
r = list(zip(c1, c2, c3))
print(len(r))
for res in r:
	print(' '.join(map(str, res)))


i2 = input().split()
i1 = input().split()
i = 0
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())
members = list(map(int, input().split()))
count = 0
if len(set(members)) < 3:
	print(0)
else:
	lis = sorted([members.count(1), members.count(2), members.count(3)])
	print(lis[0])
	while members.count(3) > 0 and members.count(2) > 0 and (members.count(1) > 0):
		count += 1
		one = members.index(1) + 1
		two = members.index(2) + 1
		three = members.index(3) + 1
		print(one, two, three)
		(members[one - 1], members[two - 1], members[three - 1]) = (0, 0, 0)


n = int(input())
students = list(map(int, input().split()))
prg = []
math = []
pe = []
for i in range(0, n):
	if students[i] == 1:
		prg.append(i + 1)
	elif students[i] == 2:
		math.append(i + 1)
	else:
		pe.append(i + 1)
if len(prg) == 0 or len(math) == 0 or len(pe) == 0:
	print(0)
else:
	l = []
	l.append(len(prg))
	l.append(len(math))
	l.append(len(pe))
	print(min(l))
	for i in range(0, min(l)):
		print(prg[i], math[i], pe[i])


input()
count = 0
stu = list(map(int, input().split()))
sof = [[], [], []]
for i in range(len(stu)):
	sof[stu[i] - 1].append(i)
l = min([len(x) for x in sof])
print(l)
for i in range(l):
	print('{} {} {}'.format(*[x[i] + 1 for x in sof]))


n = int(input())
arr = list(map(int, input().split()))
nt = 0
ar1 = []
ar2 = []
ar3 = []
for i in range(len(arr)):
	if arr[i] == 1:
		ar1.append(i + 1)
	elif arr[i] == 2:
		ar2.append(i + 1)
	else:
		ar3.append(i + 1)
nt = min(len(ar1), len(ar2), len(ar3))
if nt > 0:
	print(nt)
	for i in range(nt):
		print(ar1[i], ar2[i], ar3[i])
else:
	print(0)


n = int(input())
l = list(map(int, input().strip().split()))
(t1, t2, t3) = ([], [], [])
for i in range(0, len(l)):
	if l[i] == 1:
		t1.append(i + 1)
	elif l[i] == 2:
		t2.append(i + 1)
	else:
		t3.append(i + 1)
mini = min(len(t1), len(t2), len(t3))
if mini == 0:
	print(0)
	exit()
else:
	print(mini)
	for i in range(0, mini):
		print(t1[i], t2[i], t3[i])


n = int(input())
inputArr = list(map(int, input().split()))[:n]
arr = [0] * 4
arr[0] = 500000
arr1 = []
arr2 = []
arr3 = []
for i in inputArr:
	arr[i] = arr[i] + 1
for i in range(n):
	if inputArr[i] == 1:
		arr1.append(i + 1)
	elif inputArr[i] == 2:
		arr2.append(i + 1)
	elif inputArr[i] == 3:
		arr3.append(i + 1)
teamNum = int(min(arr))
print(teamNum)
for i in range(teamNum):
	print(arr1[i], end=' ')
	print(arr2[i], end=' ')
	print(arr3[i], end=' ')
	print()


n = int(input())
l = input().split(' ')
w = min(l.count('1'), l.count('2'), l.count('3'))
print(w)
if w != 0:
	L1 = []
	L1.append(l.index('1') + 1)
	for i in range(L1[0], n):
		if l[i] == '1':
			L1.append(i + 1)
	L2 = []
	L2.append(l.index('2') + 1)
	for i in range(L2[0], n):
		if l[i] == '2':
			L2.append(i + 1)
	L3 = []
	L3.append(l.index('3') + 1)
	for i in range(L3[0], n):
		if l[i] == '3':
			L3.append(i + 1)
for j in range(w):
	ch = ''
	ch += str(L1[j]) + ' ' + str(L2[j]) + ' ' + str(L3[j])
	print(ch)
	ch = ''


n = int(input())
l = list(map(int, input().split()))
a = l.count(1)
b = l.count(2)
c = l.count(3)
d = min(a, b, c)
e = -1
f = -1
g = -1
print(d)
for j in range(d):
	g = l.index(1, g + 1)
	e = l.index(2, e + 1)
	f = l.index(3, f + 1)
	print(g + 1, end=' ')
	print(e + 1, end=' ')
	print(f + 1, end=' ')
	print('')


n = int(input())
table_children = list(map(int, input().split()))
good_programming = []
good_math = []
good_PE = []
Number_programming = 0
Number_math = 0
Number_PE = 0
Table_Team = []
Number_Team = 0
for i in range(n):
	if table_children[i] == 1:
		Number_programming += 1
		good_programming.append(i + 1)
	elif table_children[i] == 2:
		Number_math += 1
		good_math.append(i + 1)
	else:
		Number_PE += 1
		good_PE.append(i + 1)
Table_Team.insert(0, Number_programming)
Table_Team.insert(1, Number_math)
Table_Team.append(Number_PE)
Number_Team = sorted(Table_Team)[0]
print(Number_Team)
if Number_Team == 0:
	pass
elif Number_Team == 1:
	print(good_programming[0], good_math[0], good_PE[0])
else:
	for i in range(Number_Team):
		print(good_programming[i], good_math[i], good_PE[i])


n = int(input())
x = list(map(int, input().split()))
p = x.count(1)
m = x.count(2)
PE = x.count(3)
t = min(p, m, PE)
a = [0] * n
b = [0] * n
c = [0] * n
(j, k, l) = (0, 0, 0)
for i in range(n):
	if x[i] == 1:
		a[j] = i + 1
		j += 1
	elif x[i] == 2:
		b[k] = i + 1
		k += 1
	elif x[i] == 3:
		c[l] = i + 1
		l += 1
print(t)
for i in range(n):
	if a[i] == 0 or b[i] == 0 or c[i] == 0:
		break
	else:
		print(a[i], b[i], c[i])


n = int(input())
a = list(map(int, input().split()))
b = [a.count(1), a.count(2), a.count(3)]
print(min(b))
(b1, b2, b3) = ([], [], [])
for i in range(n):
	if a[i] == 1:
		b1.append(i + 1)
	if a[i] == 2:
		b2.append(i + 1)
	if a[i] == 3:
		b3.append(i + 1)
for i in range(min(b)):
	print(b1[i], b2[i], b3[i])


def ad(dv, dc, k, v):
	dv.setdefault(k, [])
	dv[k].append(v)
	dc.setdefault(k, 0)
	dc[k] += 1

def cmd(v):
	(dv, dc) = [dict() for _ in range(2)]
	for (x, t) in enumerate(v):
		ad(dv, dc, t, x + 1)
	m = min(dc.values()) if len(dc.keys()) == 3 else 0
	v = [(dv[1][x], dv[2][x], dv[3][x]) for x in range(m)]
	return (v, m)
input()
v = [int(x) for x in input().split()]
(v, m) = cmd(v)
print(m)
for x in v:
	print(*x)


n = int(input())
t = [int(x) for x in input().split()]
ind_prog = [i for (i, x) in enumerate(t) if x == 1]
ind_math = [i for (i, x) in enumerate(t) if x == 2]
ind_pe = [i for (i, x) in enumerate(t) if x == 3]
w = min(len(ind_prog), len(ind_math), len(ind_pe))
print(w)
for i in range(w):
	print(ind_prog[i] + 1, ind_math[i] + 1, ind_pe[i] + 1)


n = int(input())
l = input().split()
x = l.count('1')
y = l.count('2')
z = l.count('3')
ans = min(x, y, z)
print(ans)
(first, sec, third, i) = (0, 0, 0, 0)
for k in range(ans):
	for i in range(first, n):
		if l[i] == '1':
			print(i + 1, end=' ')
			break
	first = i + 1
	for i in range(sec, n):
		if l[i] == '2':
			print(i + 1, end=' ')
			break
	sec = i + 1
	for i in range(third, n):
		if l[i] == '3':
			print(i + 1)
			break
	third = i + 1


n = int(input())
x = [int(i) for i in input().split()]
x1 = [0, 0, 0]
kor1 = []
kor2 = []
kor3 = []
for i in range(n):
	if x[i] == 1:
		x1[0] = x1[0] + 1
		kor1.append(i)
	elif x[i] == 2:
		x1[1] = x1[1] + 1
		kor2.append(i)
	elif x[i] == 3:
		x1[2] = x1[2] + 1
		kor3.append(i)
print(min(x1))
for i in range(min(x1)):
	print(kor1[i] + 1, kor2[i] + 1, kor3[i] + 1)


a = int(input())
b = list(map(int, input().split()))
c = 0
d = 0
e = 0
for i in b:
	if i == 1:
		c += 1
	elif i == 2:
		d += 1
	else:
		e += 1
y = 0
print(min(c, d, e))
for i in range(min(c, d, e)):
	for j in range(1, 4):
		print(b.index(j) + 1)
		y += 0
		b[b.index(j)] = 0


def inpNum():
	return int(input())

def inpNums():
	return map(int, input().split())

def inpList():
	return list(map(int, input().split()))
n = inpNum()
ni = inpList()
d = dict()
for i in range(3):
	d[i + 1] = []
for (i, _n) in enumerate(ni):
	d[_n].append(i + 1)
m = len(min(d.values(), key=len))
print(m)
for i in range(m):
	print(d[1][i], d[2][i], d[3][i])


n = int(input())
l = list(input().split())
m = n
a = l.count('1')
b = l.count('2')
c = l.count('3')
if a <= m:
	m = a
if b <= m:
	m = b
if c <= m:
	m = c
print(m)
for i in range(m):
	va = l.index('1')
	vb = l.index('2')
	vc = l.index('3')
	print(va + 1, vb + 1, vc + 1)
	l[va] = 20
	l[vb] = 20
	l[vc] = 20


n = int(input())
t = list(map(int, input().split()))
p = m = f = cnt = 0
w = ''
while p < n and m < n and (f < n):
	while p < n and t[p] != 1:
		p += 1
	while m < n and t[m] != 2:
		m += 1
	while f < n and t[f] != 3:
		f += 1
	if p < n and m < n and (f < n):
		w += str(p + 1) + ' ' + str(m + 1) + ' ' + str(f + 1) + '\n'
		cnt += 1
		p += 1
		m += 1
		f += 1
print(cnt)
print(w)


n = int(input())
array = list(map(int, input().split()))
d = array.count(1)
e = array.count(2)
f = array.count(3)
a = []
a.append(d)
a.append(e)
a.append(f)
if array.count(1) < 1 or array.count(2) < 1 or array.count(3) < 1:
	print('0')
if min(a) != 0:
	print(min(a))
for i in range(min(a)):
	print(f'{array.index(1) + 1} {array.index(2) + 1} {array.index(3) + 1}')
	array[array.index(1)] = 0
	array[array.index(2)] = 0
	array[array.index(3)] = 0


import math
n = int(input())
a = list(map(int, input().split()))
b = [0, 0, 0, 0]
c = {1: [], 2: [], 3: []}
for i in range(n):
	b[a[i]] += 1
	c[a[i]].append(i + 1)
mini = min(b[1], b[2], b[3])
print(mini)
for i in range(mini):
	print(c[1][i], c[2][i], c[3][i])


n = int(input())
l = list(map(int, input().split()))
a = min(l.count(1), l.count(2), l.count(3))
print(a)
(x, y, z) = (-1, -1, -1)
for i in range(a):
	x = l.index(1, x + 1)
	y = l.index(2, y + 1)
	z = l.index(3, z + 1)
	print(x + 1, y + 1, z + 1)


aa = int(input())
x = list(map(int, input().split()))
three = [a + 1 for a in range(aa) if x[a] == 3]
one = [a + 1 for a in range(aa) if x[a] == 1]
two = [a + 1 for a in range(aa) if x[a] == 2]
print(min(len(three), len(two), len(one)))
while three and one and two:
	print(f'{one.pop()} {two.pop()} {three.pop()}')


n = int(input())
t = list(map(int, input().split()))
t1 = []
t2 = []
t3 = []
for i in range(n):
	if t[i] == 1:
		t1.append(i)
	elif t[i] == 2:
		t2.append(i)
	elif t[i] == 3:
		t3.append(i)
l1 = len(t1)
l2 = len(t2)
l3 = len(t3)
min_len = min(l1, l2, l3)
print(min_len)
for i in range(min_len):
	print(t1[i] + 1, t2[i] + 1, t3[i] + 1)


N = int(input())
T = list(map(int, input().split()))
d = {}
for i in range(N):
	if T[i] in d:
		d[T[i]].append(i + 1)
	else:
		d[T[i]] = [i + 1]
ans = 0
andl = []
while True:
	temp = []
	flg = True
	for i in range(1, 4):
		if i in d and len(d[i]) != 0:
			temp.append(d[i][0])
			d[i] = d[i][1:]
		else:
			flg = False
	if flg:
		ans += 1
		andl.append(temp)
	else:
		break
print(ans)
if ans != 0:
	for l in andl:
		print(' '.join(map(str, l)))


n = int(input())
l = input().split()
num1 = []
num2 = []
num3 = []
for i in range(n):
	if l[i] == '1':
		num1.append(i)
	elif l[i] == '2':
		num2.append(i)
	else:
		num3.append(i)
ans = min(len(num1), len(num2), len(num3))
if ans == 0:
	print(ans)
else:
	print(ans)
	for i in range(ans):
		print(num1[i] + 1, num2[i] + 1, num3[i] + 1)


chil = int(input())
tlnts = list(map(int, input().split(' ')))
c1 = tlnts.count(1)
c2 = tlnts.count(2)
c3 = tlnts.count(3)
if c1 == 0 or c2 == 0 or c3 == 0:
	print(0)
else:
	print(min(c1, c2, c3))
	for _ in range(min(c1, c2, c3)):
		print(tlnts.index(1) + 1, tlnts.index(2) + 1, tlnts.index(3) + 1)
		tlnts[tlnts.index(1)] = 0
		tlnts[tlnts.index(2)] = 0
		tlnts[tlnts.index(3)] = 0


a = int(input())
l = list(map(int, input().split()))
one = l.count(1)
two = l.count(2)
three = l.count(3)
mn = min(one, two, three)
ss = set(l)
if len(ss) == 3:
	print(mn)
	for i in range(mn):
		p = []
		p.append(str(l.index(1) + 1))
		l[l.index(1)] = 0
		p.append(str(l.index(2) + 1))
		l[l.index(2)] = 0
		p.append(str(l.index(3) + 1))
		l[l.index(3)] = 0
		print(' '.join(p))
else:
	print(0)


n = int(input())
c = list(map(int, input().split()))
best = min(c.count(1), c.count(2), c.count(3))
print(best)
for i in range(best):
	(pos1, pos2, pos3) = (c.index(1), c.index(2), c.index(3))
	print(pos1 + 1, pos2 + 1, pos3 + 1)
	c[pos1] = 0
	c[pos2] = 0
	c[pos3] = 0


import sys
from random import choice, randint
inp = sys.stdin.readline
out = sys.stdout.write
flsh = sys.stdout.flush
sys.setrecursionlimit(10 ** 9)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def MI():
	return map(int, inp().strip().split())

def LI():
	return list(map(int, inp().strip().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]

def LI_():
	return [int(x) - 1 for x in inp().strip().split()]

def LF():
	return [float(x) for x in inp().strip().split()]

def LS():
	return inp().strip().split()

def I():
	return int(inp().strip())

def F():
	return float(inp().strip())

def S():
	return inp().strip()

def pf(s):
	return out(s + '\n')

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def main():
	n = I()
	a = LI()
	(l1, l2, l3) = ([], [], [])
	for i in range(n):
		if a[i] == 1:
			l1.append(i + 1)
		if a[i] == 2:
			l2.append(i + 1)
		if a[i] == 3:
			l3.append(i + 1)
	x = min([len(l1), len(l2), len(l3)])
	pf(str(x))
	for i in range(x):
		(a, b, c) = (l1.pop(), l2.pop(), l3.pop())
		pf(str(a) + ' ' + str(b) + ' ' + str(c))
main()


n = int(input())
inp = list(map(int, input().split()))
pe = []
pro = []
math = []
for i in range(n):
	if inp[i] == 1:
		pro.append(i + 1)
	elif inp[i] == 2:
		math.append(i + 1)
	else:
		pe.append(i + 1)
ans = min(len(pe), len(pro), len(math))
print(ans)
for i in range(ans):
	print(pro[i], math[i], pe[i])


n = int(input())
l = list(map(int, input().strip().split()))
c = l.count(1)
t = l.count(2)
p = l.count(3)
k = min(c, t, p)
print(k)
for i in range(k):
	print(l.index(1) + 1, l.index(2) + 1, l.index(3) + 1)
	l[l.index(1)] = -1
	l[l.index(2)] = -1
	l[l.index(3)] = -1
print()


n = int(input())
a = [(int(x), y + 1) for (x, y) in zip(input().split(), range(n))]
u = [x for x in a if x[0] == 1]
v = [x for x in a if x[0] == 2]
w = [x for x in a if x[0] == 3]
print(min(len(u), len(v), len(w)))
for (a, b, c) in zip(u, v, w):
	print(a[1], b[1], c[1])


import sys
import math
n = int(sys.stdin.readline())
tn = [int(x) for x in sys.stdin.readline().split()]
d = {1: [], 2: [], 3: []}
t = [0] * 3
for i in range(n):
	t[tn[i] - 1] += 1
	d[tn[i]].append(i + 1)
vmin = min(t)
print(vmin)
for i in range(vmin):
	print(str(d[1][i]) + ' ' + str(d[2][i]) + ' ' + str(d[3][i]))


n = int(input())
a = []
a = input().split()
for i in range(0, n):
	a[i] = int(a[i])
pro = 0
math = 0
pe = 0
for i in range(0, n):
	if a[i] == 1:
		pro = pro + 1
	elif a[i] == 2:
		math = math + 1
	else:
		pe = pe + 1
if pro < math and pro < pe:
	m = pro
elif math < pe:
	m = math
else:
	m = pe
print(m)
for r in range(1, m + 1):
	x1 = a.index(1)
	x2 = a.index(2)
	x3 = a.index(3)
	y1 = str(x1 + 1)
	y2 = str(x2 + 1)
	y3 = str(x3 + 1)
	a[x1] = 0
	a[x2] = 0
	a[x3] = 0
	print(y1 + ' ' + y2 + ' ' + y3)


from collections import defaultdict
input()
students = input().split()

def find_groups():
	new_list = []
	for (e, value) in enumerate(students, 1):
		new_list.append((e, value))
	new_dict = defaultdict(list)
	for (index, ability) in new_list:
		new_dict[ability].append(index)
	mingroup = len(min(new_dict.values(), key=len))
	print(mingroup)
	for i in range(mingroup):
		result = [new_dict[j][i] for j in '123']
		print(*result)
if len(set(students)) < 3:
	print(0)
else:
	find_groups()


n = int(input())
t = [int(x) for x in input().split()]
w = c1 = c2 = c3 = 0
a = []
b = []
c = []
for i in range(len(t)):
	if t[i] == 1:
		c1 += 1
		a.append(i + 1)
	elif t[i] == 2:
		c2 += 1
		b.append(i + 1)
	elif t[i] == 3:
		c3 += 1
		c.append(i + 1)
if c1 == 0 or c2 == 0 or c3 == 0:
	print(w)
else:
	w = min(c1, c2, c3)
	print(w)
for i in range(w):
	print(a[i], b[i], c[i])


from sys import stdin
n = int(stdin.readline())
A = [int(i) for i in stdin.readline().split(' ')]
d = {1: [], 2: [], 3: []}
for i in range(0, n):
	d[A[i]] = d[A[i]] + [i + 1]
print(min(len(d[1]), len(d[2]), len(d[3])))
for i in range(0, min(len(d[1]), len(d[2]), len(d[3]))):
	print(str(d[1][i]) + ' ' + str(d[2][i]) + ' ' + str(d[3][i]))


n = int(input())
l = list(map(int, input().split()))
e = []
f = []
g = []
i = 0
j = 0
k = 0
for r in range(n):
	if l[r] == 1:
		e.append(r + 1)
		i = i + 1
	if l[r] == 2:
		f.append(r + 1)
		j = j + 1
	if l[r] == 3:
		g.append(r + 1)
		k = k + 1
if i == 0 or j == 0 or k == 0:
	print('0')
else:
	a = min(i, j, k)
	print(a)
	for i in range(a):
		print(e[i], f[i], g[i])


num = int(input())
i = 0
st = input()
st_list = list(st)
st1 = []
st2 = []
st3 = []
while i < num * 2 - 1:
	a = st_list[i]
	if a == '1':
		a = int((i + 2) / 2)
		st1.append(a)
	elif a == '2':
		a = int((i + 2) / 2)
		st2.append(a)
	elif a == '3':
		a = int((i + 2) / 2)
		st3.append(a)
	i += 1
a1 = len(st1)
a2 = len(st2)
a3 = len(st3)
if a1 == 0 or a2 == 0 or a3 == 0:
	print('0')
else:
	a4 = min(a1, a2, a3)
	print(a4)
	for j in range(0, a4):
		print(st1[j], end=' ')
		print(st2[j], end=' ')
		print(st3[j], end=' ')
		print('')


n = int(input())
students = input().split()

def olympiad(n, students):
	if n < 3:
		return 0
	if '1' not in students or '2' not in students or '3' not in students:
		return 0
	else:
		(a, b, c) = ([], [], [])
		for i in range(len(students)):
			if students[i] == '1':
				a.append(i + 1)
			elif students[i] == '2':
				b.append(i + 1)
			elif students[i] == '3':
				c.append(i + 1)
		return (a, b, c)
if olympiad(n, students):
	(a, b, c) = olympiad(n, students)
	(lena, lenb, lenc) = (len(a), len(b), len(c))
	w = min(lena, lenb, lenc)
	teams = []
	for i in range(w):
		teams.append((a[i], b[i], c[i]))
	print(w)
	for team in teams:
		for student in team:
			print(student, end=' ')
		print()
else:
	print(0)


n = int(input())
l2 = list(map(int, input().split()))
prog = l2.count(1)
sport = l2.count(2)
mat = l2.count(3)
one = []
two = []
thr = []
smal = min(prog, sport, mat)
c = 0
t = ''
taken = []
if smal == 0:
	print(0)
else:
	for i in range(n):
		if l2[i] == 1:
			one.append(i + 1)
		elif l2[i] == 2:
			two.append(i + 1)
		elif l2[i] == 3:
			thr.append(i + 1)
	print(smal)
	while c < smal:
		t = str(one[c]) + ' ' + str(two[c]) + ' ' + str(thr[c])
		print(t)
		c += 1


n = int(input())
t = list(map(int, input().split()))
w = min(t.count(1), t.count(2), t.count(3))
print(w)
l1 = []
l2 = []
l3 = []
for (i, el) in enumerate(t, 1):
	if el == 1:
		l1.append(i)
	elif el == 2:
		l2.append(i)
	elif el == 3:
		l3.append(i)
for j in range(w):
	print(l1[j], l2[j], l3[j])


a = int(input())
b = list(map(int, input().split()))
one = b.count(1)
two = b.count(2)
three = b.count(3)
print(min(one, two, three))
(m, n, o) = ([], [], [])
for x in range(a):
	if b[x] == 1:
		m.append(x + 1)
	elif b[x] == 2:
		n.append(x + 1)
	elif b[x] == 3:
		o.append(x + 1)
if (len(m) and len(n) and len(o)) > 0:
	for x in range(min(one, two, three)):
		print(m[x], n[x], o[x])


n = int(input())
l = list(map(int, input().split()))
d = {}
d[1] = []
d[2] = []
d[3] = []
for (i, num) in enumerate(l):
	d[num].append(i + 1)
l = list(zip(d[1], d[2], d[3]))
print(len(l))
for (m1, m2, m3) in zip(d[1], d[2], d[3]):
	print(m1, m2, m3)


def conversion(n):
	d = []
	for s in n:
		s = str(s)
		d.append(s)
	res = ' '.join(d)
	return res
n = int(input())
t = list(map(int, input().split()))
a = []
x = t.count(1)
a.append(x)
y = t.count(2)
a.append(y)
z = t.count(3)
a.append(z)
a.sort()
a.reverse()
b = a.pop()
print(b)
i = 0
c = []
j = 0
k = 0
l = 0
while i < b:
	c.append(t.index(1, j) + 1)
	j = c[0]
	c.append(t.index(2, k) + 1)
	k = c[1]
	c.append(t.index(3, l) + 1)
	l = c[2]
	print(conversion(c))
	c = []
	i += 1


input()
s = [[], [], []]
for (i, v) in enumerate(input().split(), 1):
	s[int(v) - 1].append(i)
print(min(map(len, s)))
for x in zip(*s):
	print(*x)


n = int(input())
l = list(map(int, input().split()))
l2 = []
l1 = []
l3 = []
m = min(l.count(1), l.count(2), l.count(3))
print(m)
for (i, x) in enumerate(l):
	if x == 1:
		l1.append(i + 1)
	if x == 2:
		l2.append(i + 1)
	if x == 3:
		l3.append(i + 1)
for i in range(m):
	print(l1[i], l2[i], l3[i])


n = int(input())
h = list(map(int, input().split()))
f = []
s = []
t = []
for i in range(n):
	a = h[i]
	if a == 1:
		f.append(i)
	elif a == 2:
		s.append(i)
	else:
		t.append(i)
l = min(len(f), len(s), len(t))
print(l)
for i in range(l):
	print(f[i] + 1, s[i] + 1, t[i] + 1)


def Main():
	n = int(input())
	arr = list(map(int, input().split()))
	teams = [[], [], []]
	for i in range(n):
		x = arr[i]
		teams[x - 1].append(i + 1)
	n_teams = min(len(teams[0]), len(teams[1]), len(teams[2]))
	print(n_teams)
	for i in range(n_teams):
		print(teams[0][i], teams[1][i], teams[2][i])
Main()


n = int(input())
oli = list(map(int, input().split()))
t1 = 0
t2 = 0
t3 = 0
for i in range(n):
	if oli[i] == 1:
		t1 += 1
	if oli[i] == 2:
		t2 += 1
	if oli[i] == 3:
		t3 += 1
w = min(t1, t2, t3)
if w == 0:
	print(0)
else:
	print(w)
	for i in range(w):
		resp = []
		ja_tem = []
		for j in range(n):
			if oli[j] == 1 and 1 not in ja_tem:
				resp.append(j + 1)
				ja_tem.append(1)
				oli[j] = 0
			if oli[j] == 2 and 2 not in ja_tem:
				resp.append(j + 1)
				ja_tem.append(2)
				oli[j] = 0
			if oli[j] == 3 and 3 not in ja_tem:
				resp.append(j + 1)
				ja_tem.append(3)
				oli[j] = 0
			if len(resp) >= 3:
				break
		for z in resp:
			print(z, end=' ')
		print('')


import math
from collections import *
import sys
from functools import reduce

def get_ints():
	return map(int, input().strip().split())

def get_list():
	return list(get_ints())

def get_string():
	return list(input().strip().split())

def printxsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')
UGLYMOD = int(1000000000.0) + 7
SEXYMOD = 998244353
MAXN = int(100000.0)
n = int(input())
li = get_list()
d = defaultdict(list)
for (ind, val) in enumerate(li):
	d[val].append(ind + 1)
ans = min(len(d[1]), len(d[2]), len(d[3]))
print(ans)
for i in range(ans):
	print(d[1][i], d[2][i], d[3][i])


import sys
a = int(input())
b = str(input())
x = b.count('1')
y = b.count('2')
z = b.count('3')
c = min(x, y, z)
print(c)
b = b.replace(' ', '')
s = ''.join(b)
k = len(s)
m = -1
n = -1
o = -1
for i in range(0, c):
	m = s.find('1', m + 1, k)
	n = s.find('2', n + 1, k)
	o = s.find('3', o + 1, k)
	print(m + 1, n + 1, o + 1)


t = int(input())
l1 = [int(x) for x in input().split()]
l2 = [[], [], []]
for i in range(len(l1)):
	l2[l1[i] - 1].append(i + 1)
min1 = min(len(l2[0]), len(l2[1]), len(l2[2]))
print(min1)
if min1 > 0:
	for i in range(min1):
		print(l2[0][i], l2[1][i], l2[2][i])


import sys
n = int(sys.stdin.readline().split()[0])
t = [int(i) for i in sys.stdin.readline().split()]
programming_count = t.count(1)
math_count = t.count(2)
physical_culture_count = t.count(3)
w = min(programming_count, math_count, physical_culture_count)
print(w)
i = 0
while i < w:
	print('%d %d %d' % (t.index(1) + 1, t.index(2) + 1, t.index(3) + 1))
	t[t.index(1)] = 0
	t[t.index(2)] = 0
	t[t.index(3)] = 0
	i += 1


import sys
import os
t = sys.stdin.readline()
n_stud = int(t)
t = sys.stdin.readline()
vals = t.split()
count_skill = {1: 0, 2: 0, 3: 0}
lista_st = []
for (idx, val) in enumerate(vals):
	lista_st.append((idx, int(val)))
	if int(val) in count_skill.keys():
		count_skill[int(val)] += 1
	else:
		count_skill[int(val)] = 1
lista_st.sort(key=lambda x: x[1])
min_teams = min(count_skill.values())
print(min_teams)
if min_teams != 0:
	for team_i in range(min_teams):
		mem1 = lista_st[team_i][0]
		mem2 = lista_st[team_i + count_skill[1]][0]
		mem3 = lista_st[team_i + count_skill[1] + count_skill[2]][0]
		final_team = [mem1 + 1, mem2 + 1, mem3 + 1]
		print(*final_team)


n = int(input())
a = [int(i) for i in input().split()]
b = set(a)
u = []
h = []
if len(b) < 3:
	print('0')
else:
	for i in range(n // 2):
		h = []
		for j in b:
			if j in a:
				h.append(a.index(j) + 1)
				a[a.index(j)] = 0
			else:
				break
		if len(h) == 3:
			u.append(h)
	print(len(u))
	for i in u:
		print(*i)


__author__ = 'PrimuS'
n = int(input())
s = input()
t = [int(x) for x in s.split()]
x1 = []
x2 = []
x3 = []
for i in range(n):
	if t[i] == 1:
		x1.append(i + 1)
	elif t[i] == 2:
		x2.append(i + 1)
	else:
		x3.append(i + 1)
print(min(len(x1), min(len(x2), len(x3))))
for x in zip(x1, x2, x3):
	print(x[0], x[1], x[2])


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


n = int(input())
students = [int(i) for i in input().split()]
it = []
math = []
pc = []
for i in range(n):
	if students[i] == 1:
		it.append(i + 1)
	elif students[i] == 2:
		math.append(i + 1)
	else:
		pc.append(i + 1)
w = min(len(math), len(it), len(pc))
print(w)
for i in range(w):
	print(it[i], math[i], pc[i])


input()
a = list(map(int, input().split()))
w = min(list(map(lambda x: a.count(x), set(a))))
if len(set(a)) < 3:
	print(0)
else:
	print(w)
	for i in range(w):
		x = a.index(1)
		a[x] = 4
		y = a.index(2)
		a[y] = 4
		z = a.index(3)
		a[z] = 4
		print(x + 1, y + 1, z + 1)


n = int(input())
t = list(map(int, input().strip().split()))[:n]
num1 = 0
num2 = 0
num3 = 0
a1 = []
a2 = []
a3 = []
for i in range(n):
	if t[i] == 1:
		num1 += 1
		a1.append(i + 1)
	elif t[i] == 2:
		num2 += 1
		a2.append(i + 1)
	else:
		num3 += 1
		a3.append(i + 1)
num_temp = min(num1, num2)
num = min(num_temp, num3)
print(num)
if num != 0:
	for i in range(num):
		print('{} {} {}'.format(a1[i], a2[i], a3[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)))


n = int(input())
l = list(map(int, input().split()))
d = {1: [], 2: [], 3: []}
for i in range(n):
	d[l[i]].append(i + 1)
t = min(len(d[1]), len(d[2]), len(d[3]))
print(t)
while t > 0:
	print(d[1].pop(), d[2].pop(), d[3].pop())
	t -= 1


n = int(input())
p = list(map(int, input().split()))
if p.count(1) == 0 or p.count(2) == 0 or p.count(3) == 0:
	print(0)
else:
	po = min(p.count(1), p.count(2), p.count(3))
	print(po)
	for x in range(po):
		l = p.index(1)
		t = p.index(3)
		k = p.index(2)
		print(l + 1, t + 1, k + 1)
		p[l] = -55
		p[t] = -555
		p[k] = -555


n = int(input())
a = list(map(int, input().split()))
it = []
ma = []
fiz = []
for i in range(n):
	if a[i] == 1:
		it.append(a[i])
	elif a[i] == 2:
		ma.append(a[i])
	else:
		fiz.append(a[i])
itl = len(it)
mal = len(ma)
fizl = len(fiz)
kek = min(itl, mal)
lol = min(kek, fizl)
print(lol)
for i in range(lol):
	print(a.index(1) + 1, a.index(2) + 1, a.index(3) + 1)
	a[a.index(1)] = 0
	a[a.index(2)] = 0
	a[a.index(3)] = 0


n = int(input())
l = list(map(int, input().split()))
(l1, l2, l3) = ([], [], [])
(c1, c2, c3) = (0, 0, 0)
for i in range(n):
	if l[i] == 1:
		l1.append(i + 1)
		c1 += 1
	elif l[i] == 2:
		l2.append(i + 1)
		c2 += 1
	else:
		l3.append(i + 1)
		c3 += 1
w = min(c1, c2, c3)
print(w)
for i in range(w):
	print(l1[i], l2[i], l3[i])


n = int(input())
skills = [int(n) for n in input().split()]
i1 = []
i2 = []
i3 = []
for i in range(n):
	if skills[i] == 1:
		i1.append(i)
	if skills[i] == 2:
		i2.append(i)
	if skills[i] == 3:
		i3.append(i)
i1 = list(map(lambda x: x + 1, i1))
i2 = list(map(lambda x: x + 1, i2))
i3 = list(map(lambda x: x + 1, i3))
if min(len(i1), len(i2), len(i3)) == 0:
	print(0)
else:
	print(min(len(i1), len(i2), len(i3)))
	for i in range(min(len(i1), len(i2), len(i3))):
		print(f'{i1[i]} {i2[i]} {i3[i]} ')


n = int(input())
l = list(map(int, input().split()))
d1 = []
d2 = []
d3 = []
(c, d, e) = (0, 0, 0)
for i in range(n):
	if l[i] == 1:
		d1.append(i + 1)
		c += 1
	elif l[i] == 2:
		d2.append(i + 1)
		d += 1
	else:
		d3.append(i + 1)
		e += 1
m = min(c, d, e)
print(m)
for i in range(m):
	print(d1[i], d2[i], d3[i])


a = input()
b = input().split()
d = []
c = ()
x = list()
x = sorted(b)
try:
	k = x.index('1')
except:
	print(0)
	exit()
try:
	f = x.index('2')
except:
	print(0)
	exit()
try:
	g = x.index('3') - f
except:
	print(0)
	exit()
o = g + f
h = len(x) - f - g
m = f
n = g
for i in range(len(b)):
	c = (b[i], i + 1)
	d.append(c)
	d = sorted(d)
v = min(f, g, h)
print(v)
for t in range(v):
	print(d[t][1], d[f][1], d[o][1])
	f = f + 1
	o = o + 1


n = int(input())
oli = list(map(int, input().split()))
t1 = 0
t2 = 0
t3 = 0
prog = []
math = []
py = []
for i in range(n):
	if oli[i] == 1:
		t1 += 1
		prog.append(i + 1)
	if oli[i] == 2:
		t2 += 1
		math.append(i + 1)
	if oli[i] == 3:
		t3 += 1
		py.append(i + 1)
w = min(t1, t2, t3)
print(w)
for i in range(w):
	print(str(prog[i]) + ' ' + str(math[i]) + ' ' + str(py[i]))


n = int(input())
foo = list(map(int, input().split(' ')))
bar = min(foo.count(1), foo.count(2), foo.count(3))
if bar > 0:
	print(bar)
	for i in range(bar):
		f1 = foo.index(1)
		print(f1 + 1, end=' ')
		foo[f1] = 0
		f2 = foo.index(2)
		print(f2 + 1, end=' ')
		foo[f2] = 0
		f3 = foo.index(3)
		print(f3 + 1)
		foo[f3] = 0
else:
	print(0)


n = int(input())
a = list(map(int, input().split()))
b1 = []
b2 = []
b3 = []
for i in range(n):
	if a[i] == 1:
		b1.append(i + 1)
	if a[i] == 2:
		b2.append(i + 1)
	if a[i] == 3:
		b3.append(i + 1)
c = min(len(b1), len(b2), len(b3))
print(c)
for i in range(c):
	print(str(b1[i]) + ' ' + str(b2[i]) + ' ' + str(b3[i]))


n = int(input())
line = [int(i) for i in input().split()]
one = []
two = []
three = []
for j in range(len(line)):
	if line[j] == 1:
		one.append(j + 1)
	elif line[j] == 2:
		two.append(j + 1)
	else:
		three.append(j + 1)
ans = min(len(one), len(two), len(three))
print(str(ans))
if ans != 0:
	for i in range(ans):
		print(str(one[i]) + ' ' + str(two[i]) + ' ' + str(three[i]))


n = int(input())
a = list(map(int, input().split()))
ones = []
twos = []
tres = []
for i in range(n):
	if a[i] == 1:
		ones.append(i + 1)
	elif a[i] == 2:
		twos.append(i + 1)
	else:
		tres.append(i + 1)
k = min(min(len(ones), len(twos)), len(tres))
print(k)
for i in range(k):
	print(ones[i], twos[i], tres[i])


n = int(input())
listt = [None] * n
t1 = [None] * n
t2 = [None] * n
t3 = [None] * n
listt = list(map(int, input().split()))
one = 0
two = 0
three = 0
for i in range(n):
	if listt[i] == 1:
		t1[one] = i + 1
		one = one + 1
	elif listt[i] == 2:
		t2[two] = i + 1
		two = two + 1
	elif listt[i] == 3:
		t3[three] = i + 1
		three = three + 1
check = 0
counter = 0
for i in range(n):
	if t1[i] is not None and t2[i] is not None and (t3[i] is not None):
		check = check + 1
		counter = counter + 1
	else:
		break
if check > 0:
	print(counter)
for i in range(n):
	if t1[i] is not None and t2[i] is not None and (t3[i] is not None):
		check = check + 1
		print(t1[i], t2[i], t3[i])
	else:
		break
if check == 0:
	print(0)


n = int(input())
t = list(map(int, input().split()))
a = t.count(1)
b = t.count(2)
c = t.count(3)
m = min(a, b, c)
if m == 0:
	print(m)
else:
	print(m)
	lst1 = []
	lst2 = []
	lst3 = []
	for i in range(n):
		if t[i] == 1:
			lst1.append(i)
		elif t[i] == 2:
			lst2.append(i)
		else:
			lst3.append(i)
	for i in range(m):
		print(lst1[i] + 1, end=' ')
		print(lst2[i] + 1, end=' ')
		print(lst3[i] + 1)


n = int(input())
x = list(map(int, input().split()))
z = []
y = set(x)
a = len(y)
if a < 3:
	print('0')
else:
	for i in y:
		z.append(x.count(i))
	w = min(z)
	x1 = []
	x2 = []
	x3 = []
	print(w)
	for i in range(n):
		if x[i] == 1:
			x1.append(i + 1)
			x[i] = 0
		elif x[i] == 2:
			x2.append(i + 1)
			x[i] = 0
		elif x[i] == 3:
			x3.append(i + 1)
			x[i] = 0
	j = 0
	while w > 0:
		print(x1[j], x2[j], x3[j])
		j = j + 1
		w = w - 1


n = int(input())
students = list(map(int, input().split()))
students.insert(0, 0)
teams = list()
while True:
	if 1 not in students or 2 not in students or 3 not in students:
		break
	else:
		x = students.index(1)
		students.pop(x)
		students.insert(x, 0)
		y = students.index(2)
		students.pop(y)
		students.insert(y, 0)
		z = students.index(3)
		students.pop(z)
		students.insert(z, 0)
		teams.append([x, y, z])
print(len(teams))
for i in range(len(teams)):
	print(teams[i][0], teams[i][1], teams[i][2])


n = int(input())
t1 = []
t2 = []
t3 = []
val = list(map(int, input().rstrip().split()))
for i in range(n):
	x = val[i]
	if x == 1:
		t1 += [i + 1]
	elif x == 2:
		t2 += [i + 1]
	elif x == 3:
		t3 += [i + 1]
a = len(t1)
b = len(t2)
c = len(t3)
m = min(a, b, c)
print(m)
for i in range(m):
	print(t1[i], t2[i], t3[i])


N = int(input())
a = list(map(int, input().split()))
n = min(a.count(1), a.count(2), a.count(3))
print(n)
for i in range(n):
	A1 = a.index(1)
	print(A1 + 1, end=' ')
	a[A1] = 0
	A2 = a.index(2)
	print(A2 + 1, end=' ')
	a[A2] = 0
	A3 = a.index(3)
	print(A3 + 1)
	a[A3] = 0


n = int(input())
l = [int(i) for i in input().split()]
a = min(l.count(1), l.count(2), l.count(3))
print(a)
for i in range(a):
	x = l.index(1)
	print(x + 1, end=' ')
	l[x] = 0
	y = l.index(2)
	print(y + 1, end=' ')
	l[y] = 0
	z = l.index(3)
	print(z + 1)
	l[z] = 0


n = int(input())
t = list(map(int, input().split()))
w = min(t.count(1), t.count(2), t.count(3))
t1 = []
t2 = []
t3 = []
if 1 in t and 2 in t and (3 in t):
	for i in range(n):
		if t[i] == 1:
			t1.append(i + 1)
		elif t[i] == 2:
			t2.append(i + 1)
		elif t[i] == 3:
			t3.append(i + 1)
else:
	w = 0
print(w)
for i in range(w):
	print(t1[i], t2[i], t3[i])


n = int(input())
l = list(map(int, input().split()))
count = min(l.count(1), l.count(2), l.count(3))
print(count)
f1 = []
f2 = []
f3 = []
for i in range(len(l)):
	if l[i] == 1:
		f1.append(i + 1)
	elif l[i] == 2:
		f2.append(i + 1)
	elif l[i] == 3:
		f3.append(i + 1)
for i in range(count):
	print(f1[i], f2[i], f3[i])


input()
students = [(x + 1, y) for (x, y) in enumerate(map(int, input().split(' ')))]
queues = [[], [], []]
for (x, y) in students:
	queues[y - 1].append(x)
min_len = len(min(queues, key=len))
print(min_len)
for x in range(min_len):
	print(queues[0].pop(), queues[1].pop(), queues[2].pop())


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


cases = int(input(''))
x = input('').split()
counter = 0
list1 = []
list2 = []
list3 = []
list4 = []
output = []
for c in range(cases):
	if int(x[c]) == 1:
		list1.append(c + 1)
	elif int(x[c]) == 2:
		list2.append(c + 1)
	else:
		list3.append(c + 1)
list4.append(len(list1))
list4.append(len(list2))
list4.append(len(list3))
list4.sort()
if list4[0] < 1:
	print(0)
	exit()
output.append(list4[0])
print(*output)
for c in range(list4[0]):
	print(list1[c], list2[c], list3[c])


n = int(input())
(count_p, count_m, count_f) = (0, 0, 0)
peoples = [int(elem) for elem in input().split()]
(p, m, f) = ([], [], [])
for i in range(n):
	if peoples[i] == 1:
		count_p += 1
		p.append(i + 1)
	elif peoples[i] == 2:
		count_f += 1
		f.append(i + 1)
	elif peoples[i] == 3:
		count_m += 1
		m.append(i + 1)
print(min(count_f, count_m, count_p))
for i in range(min(count_f, count_m, count_p)):
	print(p[i], f[i], m[i])


number = int(input())
students = list(map(int, input().split()))
count_1 = students.count(1)
count_2 = students.count(2)
count_3 = students.count(3)
teams = min(count_1, count_2, count_3)
print(teams)
if teams > 0:
	list_1 = []
	list_2 = []
	list_3 = []
	for i in range(number):
		if students[i] == 1:
			list_1.append(i + 1)
		elif students[i] == 2:
			list_2.append(i + 1)
		elif students[i] == 3:
			list_3.append(i + 1)
	for i in range(teams):
		print(list_1[i], list_2[i], list_3[i])


n = int(input())
lst = [int(i) for i in input().split()]
fst = []
scd = []
thd = []
for i in range(n):
	if lst[i] == 1:
		fst.append(i + 1)
	elif lst[i] == 2:
		scd.append(i + 1)
	elif lst[i] == 3:
		thd.append(i + 1)
num = min(len(fst), len(scd), len(thd))
print(num)
if num > 0:
	for i in range(num):
		print(fst[i], scd[i], thd[i])


def solve(xs):
	mathematicians = [i for (i, x) in enumerate(xs, 1) if x == 1]
	programmers = [i for (i, x) in enumerate(xs, 1) if x == 2]
	sportsmen = [i for (i, x) in enumerate(xs, 1) if x == 3]
	return list(zip(mathematicians, programmers, sportsmen))

def main():
	n = int(input())
	xs = [int(i) for i in input().strip().split()]
	assert len(xs) == n
	troikas = solve(xs)
	print(len(troikas))
	for troika in troikas:
		print(' '.join((str(k) for k in troika)))
main()


n = int(input())
l = list(map(int, input().split()))
s = [[] for _ in range(3)]
for (i, j) in enumerate(l, 1):
	s[j - 1].append(i)
nn = min(map(len, s))
print(nn)
for i in range(nn):
	print(s[0][i], s[1][i], s[2][i])


from collections import deque
n = input()
s = input().strip().split()
(a, b, c) = (deque(), deque(), deque())
for (i, n) in enumerate(s):
	if n == '1':
		a.append(i + 1)
	elif n == '2':
		b.append(i + 1)
	else:
		c.append(i + 1)
mini = min(len(a), len(b), len(c))
if mini == 0:
	print(0)
else:
	print(mini)
	for i in range(mini):
		print(f'{a.popleft()} {b.popleft()} {c.popleft()}')


n = int(input())
c = 0
l1 = []
l = list(map(int, input().split(' ')))
for i in range(0, n):
	if 1 in l and 2 in l and (3 in l):
		c = c + 1
		k = l.index(1)
		l[k] = -1
		l1.append(k + 1)
		k = l.index(2)
		l[k] = -1
		l1.append(k + 1)
		k = l.index(3)
		l[k] = -1
		l1.append(k + 1)
	else:
		break
if len(l1) == 0:
	print('0')
else:
	print(c)
	k = 0
	for i in range(0, c):
		print(l1[k], ' ', l1[k + 1], ' ', l1[k + 2])
		k = k + 3


n = int(input())
ts = [[], [], []]
for (i, t) in enumerate(input().split()):
	ts[int(t) - 1].append(i + 1)
mn = min([len(t) for t in ts])
print(mn)
for i in range(mn):
	print(ts[0][i], ts[1][i], ts[2][i])


n = int(input())
L = list(map(int, input().split()))
a = L.count(1)
b = L.count(2)
c = L.count(3)
if a == 0 or b == 0 or c == 0:
	print(0)
else:
	w = min(a, b, c)
	print(w)
	c1 = []
	c2 = []
	c3 = []
	for x in range(n):
		if L[x] == 1:
			c1.append(x + 1)
		elif L[x] == 2:
			c2.append(x + 1)
		elif L[x] == 3:
			c3.append(x + 1)
	for i in range(w):
		print(c1[i], c2[i], c3[i])


n = int(input())
t = list(map(int, input().split()))
a = 0
a1 = []
b = 0
b1 = []
c = 0
c1 = []
for i in range(n):
	if t[i] == 1:
		a += 1
		a1.append(i + 1)
	elif t[i] == 2:
		b += 1
		b1.append(i + 1)
	else:
		c += 1
		c1.append(i + 1)
print(min(a, b, c))
for i in range(min(a, b, c)):
	print(a1[i], b1[i], c1[i])


n = int(input())
q = list(map(int, input().split()))
z = min([q.count(1), q.count(2), q.count(3)])
print(z)
for i in range(z):
	print(q.index(1) + 1, q.index(2) + 1, q.index(3) + 1)
	q[q.index(1)] = 0
	q[q.index(2)] = 0
	q[q.index(3)] = 0


n = int(input())
l = list(map(int, input().split()))
x = []
x.append(l.count(1))
x.append(l.count(2))
x.append(l.count(3))
z = min(x)
print(z)
for i in range(z):
	print(l.index(1) + 1, l.index(2) + 1, l.index(3) + 1)
	(l[l.index(1)], l[l.index(2)], l[l.index(3)]) = (0, 0, 0)


n = int(input())
s = list(map(int, input().split()))
dic = dict()
arr = []
for i in range(n):
	if s[i] not in dic:
		dic[s[i]] = [1, [i + 1]]
	else:
		dic[s[i]][0] += 1
		dic[s[i]][1].append(i + 1)
for key in dic:
	arr.append(dic[key][1])
if len(dic) == 3:
	print(dic[min(dic, key=lambda x: dic[x][0])][0])
	for e in zip(*arr):
		print(*e, sep=' ')
else:
	print(0)


n = int(input())
a = list(map(int, input().split()))
(p, m, s) = (a.count(1), a.count(2), a.count(3))
print(min(p, m, s))
for i in range(min(p, m, s)):
	print(a.index(1) + 1, a.index(2) + 1, a.index(3) + 1)
	a[a.index(1)] = 0
	a[a.index(2)] = 0
	a[a.index(3)] = 0


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


n = int(input())
stu = list(map(int, input().split()))
b = min(stu.count(1), stu.count(2), stu.count(3))
print(b)
if b == 0:
	pass
else:
	for i in range(b):
		print(stu.index(1) + 1, stu.index(2) + 1, stu.index(3) + 1)
		(stu[stu.index(1)], stu[stu.index(2)], stu[stu.index(3)]) = (0, 0, 0)


n = input()
a = input().split()
one = 0
two = 0
th = 0
b = []
c = []
d = []
j = 1
for i in a:
	if i == '1':
		one = one + 1
		b.append(j)
	if i == '2':
		two = two + 1
		d.append(j)
	if i == '3':
		th = th + 1
		c.append(j)
	j = j + 1
ans = min(one, min(two, th))
print(ans)
out = ''
j = 0
for i in range(int(ans)):
	print(b[j], d[j], c[j])
	j = j + 1


def OlympiadTeams(n, students):
	count = 0
	result = ''
	while 1 in students and 2 in students and (3 in students):
		index = students.index(1)
		result = result + str(index + 1) + ' '
		students[index] = 0
		index = students.index(2)
		result = result + str(index + 1) + ' '
		students[index] = 0
		index = students.index(3)
		result = result + str(index + 1) + '\n'
		students[index] = 0
		count = count + 1
	return (count, result)
n = int(input())
students = list(map(int, input().split(' ')))
(n, s) = OlympiadTeams(n, students)
print(n)
print(s)


n = int(input())
a = list(map(int, input().split()))[:n]
first = []
second = []
third = []
for i in range(n):
	if a[i] == 1:
		first.append(i + 1)
	elif a[i] == 2:
		second.append(i + 1)
	elif a[i] == 3:
		third.append(i + 1)
if len(first) == 0 or len(second) == 0 or len(third) == 0:
	print(0)
else:
	temp = min(len(first), len(second), len(third))
	print(temp)
	for i in range(temp):
		print(first[i], second[i], third[i])


n = int(input())
t = input().split()
count1 = 0
count2 = 0
count3 = 0
ind1 = []
ind2 = []
ind3 = []
for i in range(n):
	if int(t[i]) == 1:
		count1 += 1
		ind1.append(i + 1)
	if int(t[i]) == 2:
		count2 += 1
		ind2.append(i + 1)
	if int(t[i]) == 3:
		count3 += 1
		ind3.append(i + 1)
print(min(count1, count2, count3))
for i in range(min(count1, count2, count3)):
	print(ind1[i], ind2[i], ind3[i])


n = int(input())
child = input().split()
(p_skill, m_skill, s_skill) = (list(), list(), list())
(p, m, s) = (0, 0, 0)
for i in range(len(child)):
	if child[i] == '1':
		p_skill.append(i + 1)
		p += 1
	elif child[i] == '2':
		m_skill.append(i + 1)
		m += 1
	else:
		s_skill.append(i + 1)
		s += 1
w = min(p, m, s)
if w == 0:
	print(w)
else:
	print(w)
	for i in range(w):
		print('%d %d %d' % (p_skill[i], m_skill[i], s_skill[i]))


input()
a = list(map(int, input().split()))
a = [[i + 1 for i in range(len(a)) if a[i] == t] for t in range(1, 4)]
mn = min((len(_) for _ in a))
print(mn)
for i in range(mn):
	print(*[a[_][i] for _ in range(3)])


n = int(input())
skillz = [int(x) for x in input().split(' ')]
arr = [0, 0, 0]
index1 = []
index2 = []
index3 = []
for i in range(len(skillz)):
	arr[skillz[i] - 1] += 1
	if skillz[i] == 1:
		index1.append(i)
	elif skillz[i] == 2:
		index2.append(i)
	else:
		index3.append(i)
print(min(arr))
if min(arr) > 0:
	for i in range(min(arr)):
		print(index1[i] + 1, index2[i] + 1, index3[i] + 1)


n = int(input())
w = input().split(' ')
n1 = 0
n2 = 0
n3 = 0
a1 = []
a2 = []
a3 = []
for i in range(n):
	if int(w[i]) == 1:
		n1 = n1 + 1
		a1.append(i + 1)
	if int(w[i]) == 2:
		n2 = n2 + 1
		a2.append(i + 1)
	if int(w[i]) == 3:
		n3 = n3 + 1
		a3.append(i + 1)
print(min(n1, n2, n3))
if min(n1, n2, n3) != 0:
	for i in range(min(n1, n2, n3)):
		print(str(a1[i]) + ' ' + str(a2[i]) + ' ' + str(a3[i]))


n = int(input())
students = list(map(int, input().split(' ')))
group1 = []
group2 = []
group3 = []
for i in range(n):
	if students[i] == 1:
		group1.append(i + 1)
	elif students[i] == 2:
		group2.append(i + 1)
	else:
		group3.append(i + 1)
w = min(len(group1), len(group2), len(group3))
print(w)
for i in range(w):
	print(group1[i], group2[i], group3[i])


import sys
n = sys.stdin.readline()
while n:
	students = sys.stdin.readline().split()
	s1 = []
	s2 = []
	s3 = []
	total_1 = 0
	total_2 = 0
	total_3 = 0
	for (i, s) in enumerate(students):
		if s == '1':
			s1.append(i + 1)
			total_1 += 1
		elif s == '2':
			s2.append(i + 1)
			total_2 += 1
		else:
			s3.append(i + 1)
			total_3 += 1
	total_groups = min(total_1, total_2, total_3)
	print(total_groups)
	while s1 and s2 and s3:
		print(s1.pop(0), s2.pop(0), s3.pop(0))
	n = sys.stdin.readline()


n = int(input())
s = [str(i) for i in input().split()]
m = min(s.count('1'), s.count('2'), s.count('3'))
(a, b, c) = (0, 0, 0)
if m == 0:
	print('0')
else:
	print(m)
	for i in range(m):
		a = s.index('1', a) + 1
		b = s.index('2', b) + 1
		c = s.index('3', c) + 1
		print(a, b, c)


n = int(input())
t = list(map(int, input().split()))
res = 0
resList = []
while 1 in t and 2 in t and (3 in t):
	x1 = t.index(1)
	x2 = t.index(2)
	x3 = t.index(3)
	res += 1
	resList.append(str(x1 + 1) + ' ' + str(x2 + 1) + ' ' + str(x3 + 1))
	t[x1] = 0
	t[x2] = 0
	t[x3] = 0
print(res)
print(*resList, sep='\n')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	a = LI()
	d = collections.defaultdict(list)
	for i in range(n):
		d[a[i]].append(i + 1)
	t = min([len(d[i]) for i in range(1, 4)])
	r = [str(t)]
	for i in range(t):
		o = []
		for j in range(1, 4):
			o.append(d[j][i])
		r.append(' '.join(map(str, o)))
	return '\n'.join(r)
print(main())


from collections import Counter
from sys import exit

def main():
	students = int(input())
	student_gifts = [int(i) for i in input().split()]
	if 1 not in student_gifts or 2 not in student_gifts or 3 not in student_gifts:
		print('0')
		exit(0)
	teams = min(Counter(student_gifts).values())
	ans = []
	print(teams)
	for i in range(teams):
		ans += [[student_gifts.index(1) + 1, student_gifts.index(2) + 1, student_gifts.index(3) + 1]]
		student_gifts[student_gifts.index(1)] = student_gifts[student_gifts.index(2)] = student_gifts[student_gifts.index(3)] = 0
		print(*ans[i])
main()


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())
list1 = list(map(int, input().split()))
a = list1.count(1)
b = list1.count(2)
c = list1.count(3)
m = min(a, b, c)
print(m)
for i in range(m):
	list2 = []
	list2.append(str(list1.index(1) + 1))
	list2.append(str(list1.index(2) + 1))
	list2.append(str(list1.index(3) + 1))
	list1[list1.index(1)] = 0
	list1[list1.index(2)] = 0
	list1[list1.index(3)] = 0
	print(' '.join(list2))


n = int(input())
x = [int(q) for q in input().split()]
t1 = []
t2 = []
t3 = []
for i in range(n):
	if x[i] == 1:
		t1.append(i + 1)
	if x[i] == 2:
		t2.append(i + 1)
	if x[i] == 3:
		t3.append(i + 1)
ans = min(len(t1), len(t2), len(t3))
print(ans)
for i in range(ans):
	print(t1[i], t2[i], t3[i])


N = int(input())
AllStuds = [int(x) for x in input().split()]
NumProg = AllStuds.count(1)
NumMath = AllStuds.count(2)
NumPE = AllStuds.count(3)
IndexesProg = sorted([i for (i, x) in enumerate(AllStuds) if x == 1])
IndexesMath = sorted([i for (i, x) in enumerate(AllStuds) if x == 2])
IndexesPE = sorted([i for (i, x) in enumerate(AllStuds) if x == 3])
MaxNum = min(NumMath, NumProg, NumPE)
if MaxNum == 0:
	print(0)
else:
	print(MaxNum)
	for i in range(MaxNum):
		print(IndexesProg[i] + 1, IndexesMath[i] + 1, IndexesPE[i] + 1)


n = int(input())
a = [int(i) for i in input().split()]
m = min(a.count(1), a.count(2), a.count(3))
print(m)
if m > 0:
	k1 = k2 = k3 = 0
	for i in range(m):
		k1 = a.index(1, k1) + 1
		k2 = a.index(2, k2) + 1
		k3 = a.index(3, k3) + 1
		print(k1, k2, k3)


x = int(input())
students = []
no_of_1 = 0
no_of_2 = 0
no_of_3 = 0
students = list(map(int, input().split()))
no_of_1 = students.count(1)
no_of_2 = students.count(2)
no_of_3 = students.count(3)
if no_of_1 == 0 or no_of_2 == 0 or no_of_3 == 0:
	print('0')
else:
	mini = no_of_1
	if no_of_2 < mini:
		mini = no_of_2
	if no_of_3 < mini:
		mini = no_of_3
	print(mini)
	index_of_1 = -1
	index_of_2 = -1
	index_of_3 = -1
	for i in range(mini):
		index_of_1 = students.index(1, index_of_1 + 1, len(students) + 1)
		index_of_2 = students.index(2, index_of_2 + 1, len(students) + 1)
		index_of_3 = students.index(3, index_of_3 + 1, len(students) + 1)
		print(str(index_of_1 + 1) + ' ' + str(index_of_2 + 1) + ' ' + str(index_of_3 + 1))


n = int(input())
a = list(map(int, input().strip().split()))[:n]
cnt1 = 0
cnt2 = 0
cnt3 = 0
b = []
c = []
d = []
if 1 not in a or 2 not in a or 3 not in a:
	print('0')
else:
	for i in range(n):
		if a[i] == 1:
			cnt1 = cnt1 + 1
		elif a[i] == 2:
			cnt2 = cnt2 + 1
		elif a[i] == 3:
			cnt3 = cnt3 + 1
	m = min(cnt1, cnt2, cnt3)
	print(m)
	for i in range(n):
		if a[i] == 1:
			b.append(i + 1)
		elif a[i] == 2:
			c.append(i + 1)
		elif a[i] == 3:
			d.append(i + 1)
	for i in range(m):
		print(b[i], ' ', c[i], ' ', d[i])


input()
a = [[], [], []]
for (i, x) in enumerate(input().split(), 1):
	a[int(x) - 1] += [i]
print(min(map(len, a)))
for x in zip(*a):
	print(*x)


n = int(input())
l = [int(x) for x in input().split()]
(one, two, three) = ([], [], [])
for i in range(n):
	if l[i] == 1:
		one.append(i)
	elif l[i] == 2:
		two.append(i)
	else:
		three.append(i)
m = min(len(one), len(two), len(three))
print(m)
for i in range(m):
	print(one[i] + 1, two[i] + 1, three[i] + 1)


n = int(input())
l = input().split()
l1 = []
l2 = []
l3 = []
for x in range(len(l)):
	if int(l[x]) == 1:
		l1.append(int(x) + 1)
	elif int(l[x]) == 2:
		l2.append(int(x) + 1)
	else:
		l3.append(int(x) + 1)
key = [1, 2, 3]
value = [l1, l2, l3]
t = min(len(l1), len(l2), len(l3))
print(t)
d = dict(zip(key, value))
for i in range(t):
	print(l1[i], l2[i], l3[i])


n = int(input())
a = list(map(int, input().split()))
ones = []
twos = []
threes = []
for i in range(n):
	if a[i] == 1:
		ones.append(i + 1)
	elif a[i] == 2:
		twos.append(i + 1)
	elif a[i] == 3:
		threes.append(i + 1)
lens = min(len(ones), len(twos), len(threes))
print(lens)
for j in range(lens):
	print(ones[j], twos[j], threes[j])


n = int(input())
a = list(map(int, input().strip().split()))
pr = []
m = []
p = []
pr1 = 0
m1 = 0
p1 = 0
for i in range(len(a)):
	if a[i] == 1:
		pr.append(i + 1)
		pr1 += 1
	if a[i] == 2:
		m.append(i + 1)
		m1 += 1
	if a[i] == 3:
		p.append(i + 1)
		p1 += 1
w = min(pr1, m1, p1)
print(w)
for i in range(w):
	print(pr[i], m[i], p[i])


input()
n = [[], [], []]
for (i, j) in enumerate(input().split(), 1):
	n[int(j) - 1] += [i]
print(min(map(len, n)))
for j in zip(*n):
	print(*j)


n = int(input())
s = input()
s = s.split()
s = [int(i) for i in s]
c = min(s.count(1), s.count(2), s.count(3))
print(c)
while c:
	for i in range(1, 4):
		if i in s:
			print(s.index(i) + 1, end=' ')
			s.insert(s.index(i), 0)
			s.remove(i)
	c -= 1
	print()


NO = input()
students = input().split(' ')
sub = ['1', '2', '3']
teams = []
end = int(NO) // 3
for i in range(0, end):
	temp = []
	x = 0
	for s in sub:
		if s in students[:int(NO)]:
			x = students.index(s)
			temp.append(x + 1)
			students[x] = 0
		else:
			break
	if len(temp) == 3:
		teams.append(temp)
	else:
		break
print(len(teams))
for team in teams:
	print(*team)


import sys
n = int(input())
t = list(map(int, sys.stdin.readline().split()))
teams = dict()
teams[1] = []
teams[2] = []
teams[3] = []
for i in range(len(t)):
	teams[t[i]].append(i + 1)
l = min([len(teams[i]) for i in range(1, 4)])
print(l)
for i in range(l):
	print(teams[1][i], teams[2][i], teams[3][i])


n = int(input())
a = {'1': [], '2': [], '3': []}
t = input().split()
for i in range(len(t)):
	if t[i] == '1':
		a['1'].append(i + 1)
	elif t[i] == '2':
		a['2'].append(i + 1)
	else:
		a['3'].append(i + 1)
q = len(a['1'])
w = len(a['2'])
e = len(a['3'])
mi = min(q, w, e)
if q * w * e == 0:
	print(0)
else:
	print(mi)
	i = 0
	while i < mi:
		print(str(a['1'][i]) + ' ' + str(a['2'][i]) + ' ' + str(a['3'][i]))
		i += 1


n = int(input())
students = [int(num) for num in input().split(' ')]
set1 = set(students)
if len(set1) == 3:
	c1 = students.count(1)
	c2 = students.count(2)
	c3 = students.count(3)
	teams = min(c1, c2, c3)
	print(teams)
	l1 = []
	l2 = []
	l3 = []
	k1 = teams
	k2 = teams
	k3 = teams
	for i in range(n):
		if students[i] == 1:
			l1.append(i + 1)
			k1 -= 1
		if k1 == 0:
			break
	for i in range(n):
		if students[i] == 2:
			l2.append(i + 1)
			k2 -= 1
		if k2 == 0:
			break
	for i in range(n):
		if students[i] == 3:
			l3.append(i + 1)
			k3 -= 1
		if k3 == 0:
			break
	for i in range(len(l1)):
		print(l1[i], l2[i], l3[i])
else:
	print('0')


from sys import stdin, stdout
input = stdin.readline
n = int(input())
a = input()[:-1].split()
one = []
two = []
three = []
for i in range(n):
	if a[i] == '1':
		one.append(i + 1)
	elif a[i] == '2':
		two.append(i + 1)
	else:
		three.append(i + 1)
ans = min(len(one), len(two), len(three))
stdout.write(str(ans) + '\n')
for i in range(ans):
	stdout.write(str(one[i]) + ' ')
	stdout.write(str(two[i]) + ' ')
	stdout.write(str(three[i]) + '\n')


try:
	n = int(input())
	nums = list(map(int, input().split()))

	def count(nums, x):
		cnt_ar = []
		for (idx, ele) in enumerate(nums):
			if ele == x:
				cnt_ar.append(idx + 1)
		return cnt_ar

	def teams(nums):
		ones = count(nums, 1)
		twos = count(nums, 2)
		thress = count(nums, 3)
		m = min(len(ones), len(twos), len(thress))
		print(m) if m > 0 else print(0)
		for i in range(m):
			print(ones[i], twos[i], thress[i])
	teams(nums)
except:
	pass


n = int(input())
l = list(map(int, input().split()))
g = list(set(l))
a = l.count(1)
b = l.count(2)
c = l.count(3)
p = min(a, b, c)
if len(g) == 3:
	print(p)
	while p > 0:
		m = []
		n = []
		for (i, j) in enumerate(l):
			if j == 1 and n.count(1) == 0:
				n.append(j)
				m.append(i + 1)
				l[i] = 9
			elif j == 2 and n.count(2) == 0:
				n.append(j)
				m.append(i + 1)
				l[i] = 9
			elif j == 3 and n.count(3) == 0:
				n.append(j)
				m.append(i + 1)
				l[i] = 9
		print(*m, sep=' ')
		p = p - 1
else:
	print(0)


def solve(n, childrenStatuses):
	programmingLocs = list()
	mathsLocs = list()
	sportsLocs = list()
	for i in range(0, n):
		childrenStatus = childrenStatuses[i]
		if childrenStatus == 1:
			programmingLocs.append(i)
		elif childrenStatus == 2:
			mathsLocs.append(i)
		else:
			sportsLocs.append(i)
	maxTeamCountPossible = min(len(programmingLocs), len(mathsLocs), len(sportsLocs))
	teams = list()
	for i in range(0, maxTeamCountPossible):
		team = list()
		team.append(programmingLocs[i] + 1)
		team.append(mathsLocs[i] + 1)
		team.append(sportsLocs[i] + 1)
		teams.append(team)
	return teams
n = int(input())
childrenStatuses = list(map(int, input().split(' ')))
teams = solve(n, childrenStatuses)
print(len(teams))
for team in teams:
	(print(*team),)


a = int(input())
m = 0
m1 = 0
t = [0, 0, 0]
ind1 = [0] * a
ind2 = [0] * a
ind3 = [0] * a
u = list(map(int, input().split()))
for y in range(3):
	for i in range(a):
		if u[i] == 1 and y == 0:
			ind1[m] = u.index(1, i)
			m += 1
		if i == a - 1 and y != 2:
			m = 0
		if u[i] == 2 and y == 1:
			ind2[m1] = u.index(2, i)
			m1 += 1
		if u[i] == 3 and y == 2:
			ind3[m] = u.index(3, i)
			m += 1
for i in range(a):
	if u[i] == 1:
		t[0] += 1
	elif u[i] == 2:
		t[1] += 1
	else:
		t[2] += 1
t.sort()
print(t[0])
for i in range(t[0]):
	print(ind1[i] + 1, ind2[i] + 1, ind3[i] + 1)


n = int(input())
l = list(map(int, input().strip().split()))
a = 0
b = 0
c = 0
one = []
two = []
three = []
for i in range(n):
	if l[i] == 1:
		one.append(i + 1)
		a = a + 1
	elif l[i] == 2:
		two.append(i + 1)
		b = b + 1
	else:
		three.append(i + 1)
		c = c + 1
print(min(a, b, c))
for i in range(min(a, b, c)):
	print(one[i], end=' ')
	print(two[i], end=' ')
	print(three[i], end=' ')
	print()


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())
l = list(map(int, input().split()))
a = l.count(1)
b = l.count(2)
c = l.count(3)
print(min(a, b, c))
for i in range(min(a, b, c)):
	(p, q, r) = (l.index(1), l.index(2), l.index(3))
	l[p] = 0
	l[q] = 0
	l[r] = 0
	print(p + 1, q + 1, r + 1)


n = int(input())
li = list(map(int, input().split()))
ans = {}
(a, b, c) = (li.count(1), li.count(2), li.count(3))
team = min(a, b, c)
lis = [i for i in range(team)]
j = list(enumerate(li))
(one, two, three) = (list(filter(lambda x: x[1] == 1, j)), list(filter(lambda x: x[1] == 2, j)), list(filter(lambda x: x[1] == 3, j)))
for i in range(team):
	ans[i] = [one[i][0] + 1]
for i in range(team):
	ans[i].append(two[i][0] + 1)
for i in range(team):
	ans[i].append(three[i][0] + 1)
print(team)
for i in ans:
	print(*ans[i])


t = int(input())
ls = list(map(int, input().split()))
(one, two, three) = ([], [], [])
for i in range(t):
	if ls[i] == 1:
		one.append(i + 1)
	elif ls[i] == 2:
		two.append(i + 1)
	else:
		three.append(i + 1)
x = min(len(one), len(two), len(three))
print(x)
for i in range(x):
	print(one[i], two[i], three[i])


n = int(input())
stus = [int(x) for x in input().split()]
stu_no = list(zip(stus, [i for i in range(1, len(stus) + 1)]))
w = min(stus.count(1), stus.count(2), stus.count(3))
print(w)
for i in range(w):
	skills = [1, 2, 3]
	team = []
	for p in stu_no:
		if p[0] in skills:
			skills.remove(p[0])
			team += [p]
		if skills == []:
			break
	for p in team:
		stu_no.remove(p)
	print(' '.join([str(p[1]) for p in team]))


n = int(input())
m = list(map(int, input().split()))
counter1 = m.count(1)
counter2 = m.count(2)
counter3 = m.count(3)
w = min(counter1, counter2, counter3)
if w == 0:
	print(0)
else:
	print(w)
	for i in range(w):
		l = []
		l.append(m.index(1) + 1)
		m[m.index(1)] = 0
		l.append(m.index(2) + 1)
		m[m.index(2)] = 0
		l.append(m.index(3) + 1)
		m[m.index(3)] = 0
		for j in l:
			print(j, end=' ')
		print(' ')


n = int(input())
a = []
b = []
c = []
arr = list(map(int, input().split()))
for i in range(0, n):
	if arr[i] == 1:
		a.append(i + 1)
	elif arr[i] == 2:
		b.append(i + 1)
	else:
		c.append(i + 1)
if len(a) == 0 or len(b) == 0 or len(c) == 0:
	print(0)
else:
	ans = []
	while len(a) > 0 and len(b) > 0 and (len(c) > 0):
		ans.append([a[0], b[0], c[0]])
		a.remove(a[0])
		b.remove(b[0])
		c.remove(c[0])
	print(len(ans))
	for i in ans:
		print(*i)


input()
team = [[] for _ in range(3)]
for (n, i) in enumerate(input().split(), 1):
	team[int(i) - 1].append(str(n))
print(min((len(t) for t in team)))
for t in zip(*team):
	print(' '.join(t))


t = [[], [], []]
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	t[a[i] - 1].append(i + 1)
m = 1000000000.0
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())
t = list(map(int, input().split()))
team = [1, 2, 3]
x = []
f = []
counter1 = 0
counter2 = 0
x.append(t.count(1))
x.append(t.count(2))
x.append(t.count(3))
if min(x) > 0:
	print(min(x))
	while counter2 != min(x):
		if counter2 == min(x):
			break
		for i in range(len(t)):
			if t[i] == team[counter1]:
				f.append(i + 1)
				counter1 += 1
				t[i] = 0
			if counter1 == 3:
				print(*f)
				f = []
				counter1 = 0
				counter2 += 1
if min(x) <= 0:
	print(min(x))


n = int(input())
skills = list(map(int, input().split()))
cnt1 = []
cnt2 = []
cnt3 = []
for i in range(n):
	if skills[i] == 1:
		cnt1.append(i)
	if skills[i] == 2:
		cnt2.append(i)
	if skills[i] == 3:
		cnt3.append(i)
if len(cnt1) == 0 or len(cnt2) == 0 or len(cnt3) == 0:
	print('0')
else:
	if len(cnt1) <= len(cnt2) and len(cnt1) <= len(cnt3):
		print(len(cnt1))
		for i in range(len(cnt1)):
			print(cnt1[i] + 1, cnt2[i] + 1, cnt3[i] + 1)
	if len(cnt2) < len(cnt1) and len(cnt2) <= len(cnt3):
		print(len(cnt2))
		for i in range(len(cnt2)):
			print(cnt1[i] + 1, cnt2[i] + 1, cnt3[i] + 1)
	if len(cnt3) < len(cnt1) and len(cnt3) < len(cnt2):
		print(len(cnt3))
		for i in range(len(cnt3)):
			print(cnt1[i] + 1, cnt2[i] + 1, cnt3[i] + 1)


n = int(input())
m = list(map(int, input().split()))
b = []
while m.count(1) > 0 and m.count(2) > 0 and (m.count(3) > 0):
	i1 = m.index(1)
	i2 = m.index(2)
	i3 = m.index(3)
	o = [i1 + 1, i2 + 1, i3 + 1]
	b.append(o)
	m[i1] = 0
	m[i2] = 0
	m[i3] = 0
a = len(b)
print(a)
for i in b:
	print(i[0], i[1], i[2])


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

def read_int():
	return int(stdin.readline())

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
teams = [[], [], []]
nb_students = read_int()
expertise = read_ints()
for (i, v) in enumerate(expertise):
	teams[v - 1].append(i + 1)
answer = list(zip(teams[0], teams[1], teams[2]))
print(len(answer))
for i in answer:
	print(*i)


n = int(input())
list1 = input().strip().split()
list1 = [int(i) for i in list1]
list3 = []
w = 0
while 1:
	if 1 in list1 and 2 in list1 and (3 in list1):
		w += 1
		x = list1.index(1)
		y = list1.index(2)
		z = list1.index(3)
		list3.append([x + 1, y + 1, z + 1])
		list1[x] = 0
		list1[y] = 0
		list1[z] = 0
	else:
		break
print(w)
for ele in list3:
	print('{} {} {}'.format(ele[0], ele[1], ele[2]))


x = int(input())
y = list(map(int, input().split()))
v1 = y.count(1)
v2 = y.count(2)
v3 = y.count(3)
jk = 0
if v1 > 0 and v2 > 0 and (v3 > 0):
	jk = min(v1, v2, v3)
	print(jk)
	for i in range(jk):
		print(y.index(1) + 1, y.index(2) + 1, y.index(3) + 1)
		y[y.index(1)] = 9
		y[y.index(2)] = 9
		y[y.index(3)] = 9
else:
	print('0')


n = int(input())
a = list(map(int, input().split()))
c1 = a.count(1)
c2 = a.count(2)
c3 = a.count(3)
ans = min(c1, c2, c3)
b = []
c = []
d = []
x = y = z = 0
for i in range(0, n):
	if a[i] == 1:
		b.append(i + 1)
	elif a[i] == 2:
		c.append(i + 1)
	else:
		d.append(i + 1)
print(ans)
for i in range(0, ans):
	print(b[i], c[i], d[i])


n = int(input())
a = list(map(int, input().split()))
p = []
q = []
r = []
for i in range(n):
	if a[i] == 1:
		p.append(i + 1)
	if a[i] == 2:
		q.append(i + 1)
	if a[i] == 3:
		r.append(i + 1)
no = min(len(p), len(q), len(r))
print(no)
for i in range(no):
	print(p[i], q[i], r[i])


n = int(input())
t = input().split()
w = min([t.count('1'), t.count('2'), t.count('3')])
print(w)
for i in range(w):
	print(str(t.index('1') + 1) + ' ' + str(t.index('2') + 1) + ' ' + str(t.index('3') + 1))
	(t[t.index('1')], t[t.index('2')], t[t.index('3')]) = [0] * 3


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


from collections import defaultdict
import sys
n = int(input())
users = list(map(int, input().split()))
s = defaultdict(list)
for (i, u) in enumerate(users):
	s[u].append(i + 1)
if len(s) < 3:
	print(0)
	sys.exit()
minlen = 5001
minkey = 0
for (k, v) in s.items():
	if len(v) < minlen:
		minlen = len(v)
		minkey = k
teams = []
print(minlen)
for i in range(minlen):
	print(' '.join(list(map(str, [s[1].pop(), s[2].pop(), s[3].pop()]))))


n = int(input())
a = list(map(int, input().split()))
x = []
y = []
z = []
c1 = c2 = c3 = 0
for i in range(n):
	if a[i] == 1:
		x.append(i + 1)
		c1 += 1
	if a[i] == 2:
		y.append(i + 1)
		c2 += 1
	elif a[i] == 3:
		z.append(i + 1)
		c3 += 1
print(min(c1, c2, c3))
for i in range(min(c1, c2, c3)):
	print(x[i], y[i], z[i])


n = int(input())
one = []
two = []
three = []
A = [int(x) for x in input().split()]
if min(A.count(1), A.count(2), A.count(3)) == 0:
	print('0')
else:
	for i in range(n):
		if A[i] == 1:
			one.append(i)
		elif A[i] == 2:
			two.append(i)
		else:
			three.append(i)
	print(min(len(one), len(two), len(three)))
	for j in range(min(len(one), len(two), len(three))):
		print(one[j] + 1, two[j] + 1, three[j] + 1)


n = int(input())
d = [[], [], []]
for (i, s) in enumerate(input().split()):
	d[int(s) - 1].append(i + 1)
print(min(map(len, d)))
for a in zip(*d):
	print(a[0], a[1], a[2])


n = int(input())
t = [0] + [int(_) for _ in input().split()]
w = min(t.count(1), t.count(2), t.count(3))
print(w)
for _ in range(w):
	a = t.index(1)
	b = t.index(2)
	c = t.index(3)
	t[a] = 0
	t[b] = 0
	t[c] = 0
	print(a, b, c)


n = int(input())
t = [0]
t[1:] = list(map(int, input().split()))
count = [0, 0, 0]
list1 = []
list2 = []
list3 = []
for index in range(1, n + 1):
	if t[index] == 1:
		count[0] += 1
		list1.append(index)
	elif t[index] == 2:
		count[1] += 1
		list2.append(index)
	else:
		count[2] += 1
		list3.append(index)
if min(count) == 0:
	print('0')
else:
	print(min(count))
	for i in range(min(count)):
		print(list1[i], list2[i], list3[i])


n = input()
l = list(map(int, input().split()))
n = int(n)
f = []
s = []
t = []
for i in range(n):
	if l[i] == 1:
		f.append(i + 1)
	elif l[i] == 2:
		s.append(i + 1)
	elif l[i] == 3:
		t.append(i + 1)
res = min(len(f), len(s), len(t))
if len(f) == 0 or len(s) == 0 or len(t) == 0:
	print(0)
else:
	print(res)
	for i in range(res):
		st = str(f[i]) + ' ' + str(s[i]) + ' ' + str(t[i])
		print(st)


from operator import itemgetter
n = int(input())
ls = list(map(int, input().split()))
ans1 = []
ans2 = []
ans3 = []
c = 0
for i in range(n):
	if ls[i] == 1:
		ans1.append(i + 1)
	elif ls[i] == 2:
		ans2.append(i + 1)
	elif ls[i] == 3:
		ans3.append(i + 1)
zipped = zip(ans1, ans2, ans3)
zipped = list(zipped)
if len(zipped) > 0:
	print(len(zipped))
	for ii in zipped:
		print(*ii)
else:
	print(0)


n = int(input())
a = list(map(int, input().split()))
x = min(a.count(1), a.count(2), a.count(3))
print(x)
for _ in range(x):
	i = a.index(1)
	j = a.index(2)
	k = a.index(3)
	print(i + 1, j + 1, k + 1)
	a[i] = 4
	a[k] = 4
	a[j] = 4


n = int(input())
s = input()
l = s.split()
l2 = []
lo = []
lt = []
lth = []
for i in l:
	l2.append(int(i))
one = l2.count(1)
two = l2.count(2)
three = l2.count(3)
if one == 0 or two == 0 or three == 0:
	print(0)
else:
	l3 = [one, two, three]
	count = min(l3)
	i = 0
	for i in range(len(l2)):
		if l2[i] == 1:
			lo.append(i + 1)
		elif l2[i] == 2:
			lt.append(i + 1)
		elif l2[i] == 3:
			lth.append(i + 1)
	print(count)
	for p in range(count):
		print(lo[p], lt[p], lth[p])


from collections import defaultdict

def main():
	n = int(input())
	children = list(map(int, input().split()))
	batch = [[] for i in range(4)]
	for (index, child) in enumerate(children, 1):
		batch[child].append(index)
	ans = min([len(batch[child]) for child in range(1, 4)])
	print(ans)
	for (a, b, c) in zip(batch[1], batch[2], batch[3]):
		print(a, b, c)
main()


n = int(input())
children = list(map(int, input().split()))
teams = []
team = []
ones = []
tows = []
threes = []
for (i, child) in enumerate(children):
	if child == 1:
		ones.append(i + 1)
	if child == 2:
		tows.append(i + 1)
	if child == 3:
		threes.append(i + 1)
num_teams = min([len(ones), len(tows), len(threes)])
for player in range(num_teams):
	team.append(ones[player])
	team.append(tows[player])
	team.append(threes[player])
	teams.append(team)
	team = []
if num_teams == 0:
	print(0)
else:
	print(num_teams)
	for j in teams:
		for w in j:
			print(w, end=' ')
		print('\n')


n = int(input())
ch = list(map(int, input().split(' ')))
t = min(ch.count(1), ch.count(2), ch.count(3))
print(t)
for i in range(t):
	print(ch.index(1) + 1, ch.index(2) + 1, ch.index(3) + 1, sep=' ', end='\n')
	ch[ch.index(1)] = -1
	ch[ch.index(2)] = -1
	ch[ch.index(3)] = -1


n = int(input())
t = input().strip().split(' ')
l1 = []
l2 = []
l3 = []
for i in range(n):
	t[i] = int(t[i])
	if t[i] == 1:
		l1.append(i + 1)
	elif t[i] == 2:
		l2.append(i + 1)
	else:
		l3.append(i + 1)
nt = min(len(l1), len(l2), len(l3))
print(nt)
for i in range(nt):
	print('{0} {1} {2}'.format(l1[i], l2[i], l3[i]))


n = int(input())
stu = {}
stu[1] = []
stu[2] = []
stu[3] = []
k = 1
for i in input().split(' '):
	i = int(i)
	stu[i].append(k)
	k += 1
min1 = len(stu[1])
if min1 > len(stu[2]):
	min1 = len(stu[2])
if min1 > len(stu[3]):
	min1 = len(stu[3])
(it1, it2, it3) = (0, 0, 0)
if min1 > 0:
	print(min1)
	while it1 != min1:
		print(stu[1][it1], stu[2][it2], stu[3][it3], sep=' ')
		it1 += 1
		it2 += 1
		it3 += 1
else:
	print('0')


n = int(input())
t = list(map(int, input().split()))
freq = [0] * 3
one = []
two = []
three = []
for i in range(n):
	freq[t[i] - 1] += 1
	if t[i] == 1:
		one.append(i)
	elif t[i] == 2:
		two.append(i)
	elif t[i] == 3:
		three.append(i)
m = min(freq)
print(m)
for i in range(m):
	print(one[i] + 1, two[i] + 1, three[i] + 1)


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


def main():
	n = int(input().strip())
	l = list(map(int, input().strip().split()))
	cnt = [0, 0, 0, 0]
	for x in l:
		cnt[x] += 1
	print(min(cnt[1:]))
	ll = [None, [], [], []]
	for (i, x) in enumerate(l):
		ll[x].append(i + 1)
	for xx in zip(*ll[1:]):
		print(*xx)
main()


x = int(input())
y = list(map(int, input().split()))
n1 = y.count(1)
n2 = y.count(2)
n3 = y.count(3)
w = min(n1, n2, n3)
t = []
teams = []
if w > 0:
	for i in range(w):
		t.append(y.index(1) + 1)
		y[y.index(1)] = 0
		t.append(y.index(2) + 1)
		y[y.index(2)] = 0
		t.append(y.index(3) + 1)
		y[y.index(3)] = 0
		z = t.copy()
		teams.append(z)
		t.clear()
print(w)
if w > 0:
	for i in range(w):
		print(*teams[i])


from collections import deque
N = input()
n = int(N)
D1 = deque([])
D2 = deque([])
D3 = deque([])
string = input()
string_seperate = string.split(' ')
for i in range(len(string_seperate)):
	k = int(string_seperate[i])
	if k == 1:
		D1.append(i + 1)
	elif k == 2:
		D2.append(i + 1)
	else:
		D3.append(i + 1)
(l1, l2, l3) = (len(D1), len(D2), len(D3))
m = min(l1, l2, l3)
print(m, end='\n')
for i in range(m):
	print(D1[i], ' ', D2[i], ' ', D3[i], end='\n')


n = int(input())
skills = input().split()
program_list = []
math_list = []
pe_list = []
for i in range(len(skills)):
	if skills[i] == '1':
		program_list.append(i)
	elif skills[i] == '2':
		math_list.append(i)
	else:
		pe_list.append(i)
answer = min(min(len(program_list), len(math_list)), len(pe_list))
print(answer)
for i in range(answer):
	print(program_list[i] + 1, math_list[i] + 1, pe_list[i] + 1)


input()
a = [int(x) for x in input().split()]
k = min(a.count(1), a.count(2), a.count(3))
print(k)
for i in range(k):
	print(a.index(1) + 1, a.index(2) + 1, a.index(3) + 1)
	a[a.index(1)] = 0
	a[a.index(2)] = 0
	a[a.index(3)] = 0


n = int(input())
a = input().split()
a1 = []
a2 = []
a3 = []
for i in range(n):
	if a[i] == '1':
		a1.append(i + 1)
	elif a[i] == '2':
		a2.append(i + 1)
	else:
		a3.append(i + 1)
k = min(min(len(a1), len(a2)), len(a3))
print(k)
for i in range(k):
	print(a1[i], a2[i], a3[i])


n = int(input())
a = [int(s) for s in input().split()]
s = min(a.count(1), a.count(2), a.count(3))
(i1, i2, i3) = (0, 0, 0)
if s != 0:
	print(s)
	while s > 0:
		i1 += a[i1:].index(1) + 1
		i2 += a[i2:].index(2) + 1
		i3 += a[i3:].index(3) + 1
		print(i1, i2, i3)
		s -= 1
else:
	print(0)


n = int(input())
s = input().split()
lst = [[] for i in range(4)]
for i in range(n):
	now = int(s[i])
	lst[now].append(i + 1)
ans = min(len(lst[1]), len(lst[2]), len(lst[3]))
print(ans)
for i in range(ans):
	print(lst[1][i], lst[2][i], lst[3][i])


n = int(input())
t = [str(x) for x in input().split()]
t_ = set(t)
if len(t_) < 3:
	print('0')
else:
	a = ''.join(t)
	m = min(a.count('1'), a.count('2'), a.count('3'))
	print(m)
	for i in range(m):
		(x, y, z) = [a.find('1'), a.find('2'), a.find('3')]
		print(x + 1, y + 1, z + 1)
		t[x] = '*'
		t[y] = '*'
		t[z] = '*'
		a = ''.join(t)


a = int(input())
b = list(map(int, input().split()))
prog = []
math = []
pe = []
for i in range(a):
	if b[i] == 1:
		prog.append(i + 1)
	if b[i] == 2:
		math.append(i + 1)
	if b[i] == 3:
		pe.append(i + 1)
m = min(len(prog), len(math), len(pe))
print(m)
if m != 0:
	for j in range(m):
		print(prog[j], math[j], pe[j])


t = int(input())
a = []
b = []
c = []
o = []
o = list(map(int, input().split()))
for j in range(1, t + 1):
	if o[j - 1] == 1:
		a.append(j)
	elif o[j - 1] == 2:
		b.append(j)
	else:
		c.append(j)
m = min(len(a), len(b), len(c))
print(m)
for i in range(m):
	print(f'{a[i]} {b[i]} {c[i]}')


n = int(input())
l = [int(i) for i in input().split()]
x = l.count(1)
y = l.count(2)
z = l.count(3)
k = min(x, y, z)
print(k)
for i in range(k):
	a = l.index(1)
	b = l.index(2)
	c = l.index(3)
	print(a + 1, b + 1, c + 1)
	(l[a], l[b], l[c]) = (0, 0, 0)


n = int(input())
line = [int(i) for i in input().split()]
num = min(line.count(1), line.count(2), line.count(3))
if num == 0:
	print('0')
else:
	print(num)
	for i in range(num):
		a = line.index(1)
		b = line.index(2)
		c = line.index(3)
		print(a + 1, b + 1, c + 1)
		line[a] = 0
		line[b] = 0
		line[c] = 0


t = input
p = print
r = range
n = int(t())
a = list(map(int, t().split()))
s = {1: [], 2: [], 3: []}
for i in range(n):
	s[a[i]].append(i)
ans = min(map(lambda x: len(x), list(s.values())))
p(ans)
if ans > 0:
	for i in range(ans):
		p(s[1].pop() + 1, s[2].pop() + 1, s[3].pop() + 1)


n = int(input())
mas = list(map(int, input().split(' ')))
t1 = []
t2 = []
t3 = []
for i in range(n):
	if mas[i] == 1:
		t1.append(i)
	elif mas[i] == 2:
		t2.append(i)
	elif mas[i] == 3:
		t3.append(i)
print(min(len(t1), len(t2), len(t3)))
for i in range(min(len(t1), len(t2), len(t3))):
	print(t1[i] + 1, t2[i] + 1, t3[i] + 1)


n = int(input())
t = input().split()
t1 = []
counter = 0
while True:
	tuple1 = []
	if '1' in t:
		tuple1.append(t.index('1'))
		if '2' in t:
			tuple1.append(t.index('2'))
			if '3' in t:
				tuple1.append(t.index('3'))
				counter += 1
				t1.append(tuple1)
				for i in tuple1:
					t[i] = ''
	if len(tuple1) != 3:
		break
print(counter)
for x in t1:
	for i in x:
		v = i + 1
		print(v, end=' ')
	print('\n')


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


n = int(input())
vls = list(map(int, input().split()))
done = min(vls.count(1), vls.count(2), vls.count(3))
(prog, mth, ph, iterate, teams) = ([], [], [], 0, [])
for i in range(n):
	if vls[i] == 1:
		prog.append(i + 1)
	elif vls[i] == 2:
		mth.append(i + 1)
	else:
		ph.append(i + 1)
for s in range(done):
	teams.append([prog[s], mth[s], ph[s]])
if done == 0:
	print(0)
else:
	print(done, end='\n')
	for i in range(done):
		for k in range(3):
			print(teams[i][k], end=' ')
		print(end='\n')


from sys import stdin, stdout
from collections import Counter

def ai():
	return list(map(int, stdin.readline().split()))

def ei():
	return map(int, stdin.readline().split())

def ip():
	return int(stdin.readline().strip())

def op(ans):
	return stdout.write(str(ans) + '\n')
n = ip()
li = ai()
d = Counter(li).values()
teams = min(d)
index = []
if len(d) == 3:
	print(teams)
	for i in range(teams):
		index.append((li.index(1) + 1, li.index(2) + 1, li.index(3) + 1))
		li[li.index(1)] = -1
		li[li.index(2)] = -1
		li[li.index(3)] = -1
	for i in index:
		print(*i)
else:
	print(0)


n = int(input())
ln = input().split(' ')
ts = [0, 0, 0]
ind = [[], [], []]
for i in range(n):
	p = int(ln[i])
	ts[p - 1] += 1
	ind[p - 1].append(i + 1)
if 0 in ts:
	print(0)
else:
	w = min(ts)
	print(w)
	for i in range(w):
		print(ind[0][i], ind[1][i], ind[2][i])


from sys import stdin, stdout, exit as sys_ret
(f_input, f_print, f_flush) = (stdin.readline, stdout.write, stdout.flush)
amount = int(f_input())
kids = [int(_) for _ in f_input().split()]
adv1 = [i + 1 for i in range(amount) if kids[i] == 1]
adv2 = [i + 1 for i in range(amount) if kids[i] == 2]
adv3 = [i + 1 for i in range(amount) if kids[i] == 3]
min_len = min(len(adv1), len(adv2), len(adv3))
f_print(str(min_len) + '\n')
if min_len == 0:
	sys_ret(0)
for i in range(min_len):
	f_print(str(adv1[i]) + ' ' + str(adv2[i]) + ' ' + str(adv3[i]) + '\n')


x = int(input())
l1 = []
kids = list(map(int, input().split(' ')))
n1 = [i for (i, n) in enumerate(kids) if n == 1]
n2 = [i for (i, n) in enumerate(kids) if n == 2]
n3 = [i for (i, n) in enumerate(kids) if n == 3]
m = min(len(n1), len(n2), len(n3))
print(m)
i = 0
while i != m:
	print(n1[i] + 1, end=' ')
	print(n2[i] + 1, end=' ')
	print(n3[i] + 1)
	i = i + 1


i = input()
l = list(map(int, input().split()))
a = l.count(1)
b = l.count(2)
c = l.count(3)
d = min(a, b, c)
print(d)
l1 = []
c = 1
for x in range(d * 3 + 1):
	if c == 4:
		c = 1
		print(' '.join(map(str, l1)))
		l1 = []
	for (v, k) in enumerate(l):
		if k == c:
			l1.append(v + 1)
			l[v] = 0
			c += 1
			break


n = int(input())
lst = list(map(int, input().split()))
set1 = set(lst)
if len(set1) < 3:
	print(0)
else:
	t1 = []
	t2 = []
	t3 = []
	for i in range(1, len(lst) + 1):
		if lst[i - 1] == 1:
			t1.append(str(i))
		if lst[i - 1] == 2:
			t2.append(str(i))
		if lst[i - 1] == 3:
			t3.append(str(i))
	s = min(len(t1), len(t2), len(t3))
	t1 = t1[0:s]
	t2 = t2[0:s]
	t3 = t3[0:s]
	print(str(s))
	for i in range(s):
		lst = [t1[i], t2[i], t3[i]]
		print(' '.join(lst))


import sys
from math import *
input = sys.stdin.readline
RI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
rw = lambda : input().strip().split()
from collections import defaultdict as df
import heapq
infinite = float('inf')
n = int(input())
l = RI()
a = [[] for i in range(3)]
for i in range(n):
	a[l[i] - 1].append(i + 1)
k = min(len(a[0]), min(len(a[1]), len(a[2])))
print(k)
j = 0
for i in range(k):
	print(str(a[0][j]) + ' ' + str(a[1][j]) + ' ' + str(a[2][j]))
	j += 1


n = int(input())
ts = [int(x) for x in input().split(' ')]
ones = [i + 1 for (i, t) in enumerate(ts) if t == 1]
twos = [i + 1 for (i, t) in enumerate(ts) if t == 2]
threes = [i + 1 for (i, t) in enumerate(ts) if t == 3]
l = min([len(ones), len(twos), len(threes)])
print(l)
for i in range(0, l):
	print(str(ones[i]) + ' ' + str(twos[i]) + ' ' + str(threes[i]))


a = int(input())
b = list(map(int, input().split()))
c = []
d = []
e = []
for i in range(a):
	if b[i] == 1:
		c.append(i + 1)
	elif b[i] == 2:
		d.append(i + 1)
	else:
		e.append(i + 1)
f = min(len(c), len(d), len(e))
print(f)
for i in range(f):
	print(c[i], d[i], e[i])


n = int(input())
listy = [int(x) for x in input().split()]
teams = []
n1 = listy.count(1)
n2 = listy.count(2)
n3 = listy.count(3)
nbOfTeams = min(n1, n2, n3)
indexes1 = []
indexes2 = []
indexes3 = []
index = 1
for i in listy:
	if i == 1:
		indexes1.append(index)
		index += 1
		continue
	elif i == 2:
		indexes2.append(index)
		index += 1
		continue
	else:
		indexes3.append(index)
		index += 1
		continue
if nbOfTeams > 0:
	for i in range(nbOfTeams):
		newTeam = []
		newTeam.append(indexes1[0])
		indexes1.pop(0)
		newTeam.append(indexes2[0])
		indexes2.pop(0)
		newTeam.append(indexes3[0])
		indexes3.pop(0)
		teams.append(newTeam)
	print(nbOfTeams)
	for i in teams:
		print(f'{i[0]} {i[1]} {i[2]}')
else:
	print(0)


n = input()
students = input().split()
g = students.count('1')
m = students.count('2')
p = students.count('3')
team = min(g, m, p)
print(team)
if team != 0:
	indices1 = [i for (i, x) in enumerate(students) if x == '1']
	indices2 = [i for (i, x) in enumerate(students) if x == '2']
	indices3 = [i for (i, x) in enumerate(students) if x == '3']
	for i in range(team):
		print(indices1[i] + 1, indices2[i] + 1, indices3[i] + 1)


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)


a = int(input())
b = list(map(int, input().split()))
(p, q, r) = ([], [], [])
for i in range(a):
	if b[i] == 1:
		p.append(i + 1)
	elif b[i] == 2:
		q.append(i + 1)
	else:
		r.append(i + 1)
c = min([len(p), len(q), len(r)])
if c == 0:
	print(0)
else:
	print(c)
	for i in range(c):
		print(p[i], q[i], r[i])


n = input()
n = int(n)
students = input().split()
t1 = []
t2 = []
t3 = []
for number in range(n):
	if students[number] == '1':
		t1.append(number + 1)
	if students[number] == '2':
		t2.append(number + 1)
	if students[number] == '3':
		t3.append(number + 1)
total = [len(t1), len(t2), len(t3)]
if min(total) == 0:
	print('0')
else:
	print(min(total))
	for ans in range(min(total)):
		print(str(t1[ans]) + ' ' + str(t2[ans]) + ' ' + str(t3[ans]))


n = int(input())
t = list(map(int, input().split()))
sc = 0
tl = [[], [], []]
for j in range(len(t)):
	tl[t[j] - 1].append(str(j + 1))
output = list(zip(tl[0], tl[1], tl[2]))
print(len(output))
for out in output:
	print(' '.join(out))


n = int(input())
children = map(int, input().split())
teams = {i: [] for i in range(3)}
for (i, c) in enumerate(children):
	teams[c - 1].append(i + 1)
teams_num = min(map(len, teams.values()))
print(teams_num)
for t in zip(*teams.values()):
	print(*t)


n = int(input(''))
L = list(map(int, input().split(' ')))
L3 = []
cont = 0

def mostrar(L):
	str1 = ''
	for k in range(len(L) - 1):
		str1 += str(L[k]) + ' '
	str1 += str(L[len(L) - 1])
	return str1
while True:
	va = 0
	L2 = []
	for k in range(1, 4):
		if k in L:
			i = L.index(k)
			L2 += [i + 1]
			L[i] = 0
			cont += 1
		else:
			va = 1
	if va == 1:
		break
	L3 += [L2]
if len(L3) == 0:
	print(0)
else:
	print(len(L3))
	for k in range(len(L3)):
		print(mostrar(L3[k]))


ans = []
n = int(input())
l = [int(x) for x in input().split()]
cpp = []
m = []
pe = []
for x in range(len(l)):
	if l[x] == 1:
		cpp.append(x + 1)
	if l[x] == 2:
		m.append(x + 1)
	if l[x] == 3:
		pe.append(x + 1)
if cpp and m and pe:
	ans.append(cpp)
	ans.append(m)
	ans.append(pe)
	ml = min(len(cpp), len(m), len(pe))
	print(ml)
	i = 0
	x = 0
	while x < ml:
		print(ans[i][x], ans[i + 1][x], ans[i + 2][x])
		x += 1
else:
	print(0)


n = int(input())
ls = [int(i) for i in input().split()]
val = min(ls.count(1), ls.count(2), ls.count(3))
if val == 0:
	print('0')
else:
	print(val)
	for i in range(0, val):
		a = ls.index(1)
		b = ls.index(2)
		c = ls.index(3)
		print(a + 1, b + 1, c + 1)
		ls[a] = -99
		ls[b] = -99
		ls[c] = -99


n = int(input())
l = list(map(int, input().split()))
z = min(l.count(1), l.count(2), l.count(3))
print(z)
while z != 0:
	print(l.index(1) + 1, end=' ')
	l[l.index(1)] = 0
	print(l.index(2) + 1, end=' ')
	l[l.index(2)] = 0
	print(l.index(3) + 1)
	l[l.index(3)] = 0
	z -= 1


n = int(input())
teams = [[], [], []]
for (i, v) in enumerate((int(t) for t in input().split())):
	teams[v - 1].append(i + 1)
if not all(teams):
	print(0)
else:
	tt = list(zip(*teams))
	print(len(tt))
	for s in tt:
		print(*s)


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


n = int(input())
l = list(map(int, input().split()))
(a, b, c) = (l.count(1), l.count(2), l.count(3))
z = min(a, b, c)
print(z)
if z != 0:
	while z != 0:
		x = []
		p = []
		for i in range(n):
			if l[i] == 1:
				if 1 not in p:
					x.append(i + 1)
					p.append(l[i])
					l[i] = -1
			if l[i] == 2:
				if 2 not in p:
					x.append(i + 1)
					p.append(l[i])
					l[i] = -1
			if l[i] == 3:
				if 3 not in p:
					x.append(i + 1)
					p.append(l[i])
					l[i] = -2
		print(*x)
		z -= 1


from collections import defaultdict

def solve():
	n = int(input())
	t = input().split()
	t_freq = defaultdict(lambda : 0)
	t_idx = defaultdict(list)
	for (idx, num) in enumerate(t):
		t_freq[num] += 1
		t_idx[num].append(idx + 1)
	if len(t_freq) == 3:
		min_t = min(t_freq.values())
		print(min_t)
		ts = list(t_idx.values())
		for i in range(min_t):
			print(f'{ts[0][i]} {ts[1][i]} {ts[2][i]}')
	else:
		print(0)
solve()


n = int(input())
list1 = list(map(int, input().split(' ')))
list2 = sorted(list1)
on = list2.count(1)
tw = list2.count(2)
th = list2.count(3)
if on and tw and th:
	print(min(on, tw, th))
	k = True
	while k:
		try:
			(on, tw, th) = (list1.index(1) + 1, list1.index(2) + 1, list1.index(3) + 1)
			(list1[on - 1], list1[tw - 1], list1[th - 1]) = (4, 4, 4)
			print(on, tw, th)
		except ValueError:
			break
else:
	print(0)


n = int(input())
children_skills = list(map(int, input().split()))
if len(list(set(children_skills))) < 3 or list(set(children_skills)) != [1, 2, 3]:
	print(0)
	exit(0)
teams = [[None] * 3 for i in range(n // 3)]
j = 0
for i in range(n // 3):
	for k in range(3):
		index = children_skills.index(k + 1)
		teams[j][k] = index + 1
		children_skills[index] = 0
	j += 1
	if list(set(children_skills)) != [0, 1, 2, 3]:
		print(j)
		for i in range(j):
			print(' '.join(list(map(str, teams[i]))))
		exit(0)
print(j)
for i in range(j):
	print(' '.join(list(map(str, teams[i]))))


def main():
	N = int(input())
	x = list(map(int, input().split()))
	pl = []
	ml = []
	el = []
	for i in range(N):
		if x[i] == 1:
			pl.append(i + 1)
		elif x[i] == 2:
			ml.append(i + 1)
		else:
			el.append(i + 1)
	max_teams = min(len(pl), len(ml), len(el))
	print(max_teams)
	for i in range(max_teams):
		print(pl[i], ml[i], el[i])
main()


childs = int(input())
ones = []
twos = []
threes = []
x = input()
x = x.split(' ')
x = [int(i) for i in x]
for i in range(0, len(x)):
	if x[i] == 1:
		ones.append(i + 1)
	if x[i] == 2:
		twos.append(i + 1)
	if x[i] == 3:
		threes.append(i + 1)
minim = min(len(ones), len(twos), len(threes))
print(minim)
for i in range(0, minim):
	print(ones[i], twos[i], threes[i])


n = int(input())
t = list(map(int, input().split()))
idx1 = []
for i in range(len(t)):
	if t[i] == 1:
		idx1.append(t.index(1, i))
idx2 = []
for i in range(len(t)):
	if t[i] == 2:
		idx2.append(t.index(2, i))
idx3 = []
for i in range(len(t)):
	if t[i] == 3:
		idx3.append(t.index(3, i))
arr = [len(idx1), len(idx2), len(idx3)]
min_arr = min(arr)
idx1 = idx1[:min_arr]
idx2 = idx2[:min_arr]
idx3 = idx3[:min_arr]
indices = [[i + 1, j + 1, k + 1] for (i, j, k) in zip(idx1, idx2, idx3)]
print(len(indices))
if len(indices) != 0:
	for k in range(len(indices)):
		print(*indices[k])


x = int(input())
y = list(map(int, input().split()))
t1 = y.count(1)
t2 = y.count(2)
t3 = y.count(3)
t = min(t1, t2, t3)
a = set(y)
(q, w, e) = ([], [], [])
for i in range(x):
	if len(a) < 3:
		print(0)
		break
for i in range(x):
	if len(a) == 3:
		if t1 > t:
			if y[i] == 1:
				y[i] = 0
				t1 -= 1
		if t2 > t:
			if y[i] == 2:
				y[i] = 0
				t2 -= 1
		if t3 > t:
			if y[i] == 3:
				y[i] = 0
				t3 -= 1
for i in range(x):
	if y[i] == 1:
		q.append(i + 1)
	if y[i] == 2:
		w.append(i + 1)
	if y[i] == 3:
		e.append(i + 1)
if len(a) == 3:
	print(t)
for n in range(t):
	print('{} {} {}'.format(q[n], w[n], e[n]))


import math

def f():
	x = int(input())
	t = 0
	li = list(map(int, input().split()))
	one = li.count(1)
	two = li.count(2)
	three = li.count(3)
	m = min(one, two, three)
	print(m)
	for _ in range(m):
		print(li.index(1) + 1, li.index(2) + 1, li.index(3) + 1)
		li[li.index(1)] = 0
		li[li.index(2)] = 0
		li[li.index(3)] = 0
f()


n = int(input())
l = list(map(int, input().split()))
c1 = [i for (i, x) in enumerate(l) if x == 1]
c2 = [i for (i, x) in enumerate(l) if x == 2]
c3 = [i for (i, x) in enumerate(l) if x == 3]
com = min(len(c1), len(c2), len(c3))
print(com)
for i in range(com):
	print(c1[i] + 1, c2[i] + 1, c3[i] + 1)


n = int(input())
x = [int(i) for i in input().split()]
cnt1 = 0
cnt2 = 0
cnt3 = 0
l1 = []
l2 = []
l3 = []
for i in range(n):
	if x[i] == 1:
		cnt1 += 1
		l1.append(i + 1)
	elif x[i] == 2:
		cnt2 += 1
		l2.append(i + 1)
	else:
		cnt3 += 1
		l3.append(i + 1)
z = min(cnt3, cnt2, cnt1)
print(z)
for i in range(z):
	print(l1[i], l2[i], l3[i])


n = int(input())
q = list(map(int, input().split()))
a = []
b = []
c = []
d = []
(a1, b1, c1, z, kk) = (0, 0, 0, 0, 0)
for i in range(len(q)):
	if q[i] == 1:
		a.append(i + 1)
		a1 = len(a)
	elif q[i] == 2:
		b.append(i + 1)
		b1 = len(b)
	elif q[i] == 3:
		c.append(i + 1)
		c1 = len(c)
if len(q) < 3 or (len(q) >= 3 and (a1 == 0 or b1 == 0 or c1 == 0)):
	kk = 0
	print(kk)
elif a1 != 0 and b1 != 0 and (c1 != 0):
	if a1 <= b1 <= c1 or a1 <= c1 <= b1:
		kk = a1
		print(kk)
		for i in range(a1):
			d.append(str(a[i]))
			d.append(str(b[i]))
			d.append(str(c[i]))
			z = ' '.join(d)
			print(z)
			d = []
	elif b1 <= c1 <= a1 or b1 <= a1 <= c1:
		kk = b1
		print(kk)
		for i in range(b1):
			d.append(str(a[i]))
			d.append(str(b[i]))
			d.append(str(c[i]))
			z = ' '.join(d)
			print(z)
			d = []
	elif c1 <= a1 <= b1 or c1 <= b1 <= a1:
		kk = c1
		print(kk)
		for i in range(c1):
			d.append(str(a[i]))
			d.append(str(b[i]))
			d.append(str(c[i]))
			z = ' '.join(d)
			print(z)
			d = []


(_, l) = (input(), map(int, input().split()))
c = [[], [], []]
for (i, e) in enumerate(l):
	c[e - 1].append(i + 1)
n = min((len(i) for i in c))
print(n)
print(*([' '.join([str(d[i]) for d in c]) for i in range(n)] if n != 0 else ''), sep='\n')


n = int(input())
num = [int(x) for x in input().split()]
l1 = []
l2 = []
l3 = []
for i in range(n):
	if num[i] == 1:
		l1.append(i + 1)
	if num[i] == 2:
		l2.append(i + 1)
	if num[i] == 3:
		l3.append(i + 1)
list.sort(l1)
list.sort(l2)
list.sort(l3)
if l1 == [] or l2 == [] or l3 == []:
	print(0)
else:
	print(min(len(l1), len(l2), len(l3)))
	for j in range(min(len(l1), len(l2), len(l3))):
		print(l1[j], l2[j], l3[j])


n = int(input())
arr = list(map(int, input().split()))
count_1 = arr.count(1)
count_2 = arr.count(2)
count_3 = arr.count(3)
ans = min(count_1, count_2, count_3)
print(ans)
for k in range(ans):
	print(arr.index(1) + 1, end=' ')
	arr[arr.index(1)] = 0
	print(arr.index(2) + 1, end=' ')
	arr[arr.index(2)] = 0
	print(arr.index(3) + 1, end=' ')
	arr[arr.index(3)] = 0
	print('')


n = int(input())
s = input()
m = ''
a = []
b = []
c = []
st = [int(k) for k in s.split(' ')]
for index in range(len(st)):
	if st[index] == 1:
		a.append(index + 1)
	if st[index] == 2:
		b.append(index + 1)
	if st[index] == 3:
		c.append(index + 1)
na = len(a)
nb = len(b)
nc = len(c)
n1 = min(na, nb)
n2 = min(n1, nc)
print(n2)
for index in range(n2):
	print(a[index], ' ', b[index], ' ', c[index])


(ans, n, m) = ([], int(input()), list(map(int, input().split())))
while m.count(1) > 0 and m.count(2) > 0 and (m.count(3) > 0):
	a = []
	for i in range(3):
		x = m.index(i + 1)
		a.append(x + 1)
		m[x] += 10
	ans.append(a)
print(len(ans))
[print(*a) for a in ans]


n = int(input())
talents = list(map(int, input().split()))
count = [0, 0, 0]
index_p = []
index_m = []
index_pe = []
for i in range(n):
	if talents[i] == 1:
		count[0] += 1
		index_p.append(i)
	elif talents[i] == 2:
		count[1] += 1
		index_m.append(i)
	else:
		count[2] += 1
		index_pe.append(i)
max_teams = min(count)
print(max_teams)
for j in range(max_teams):
	w = [index_p[j] + 1, index_m[j] + 1, index_pe[j] + 1]
	print(' '.join((str(x) for x in w)))


n = int(input())
ests = list(map(int, input().split()))
(pos1, pos2, pos3) = ([], [], [])
gen = []
for i in range(len(ests)):
	if ests[i] == 1:
		pos1.append(i + 1)
	elif ests[i] == 2:
		pos2.append(i + 1)
	else:
		pos3.append(i + 1)
for j in range(min(len(pos1), len(pos2), len(pos3))):
	t = str(pos1[j]) + ' ' + str(pos2[j]) + ' ' + str(pos3[j])
	gen.append(t)
print(len(gen))
if len(gen) != 0:
	for k in gen:
		print(k)


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


n = int(input())
l = list(map(int, input().split()))
c_1 = l.count(1)
c_2 = l.count(2)
c_3 = l.count(3)
m = min(c_1, c_2, c_3)
print(m)
for i in range(m):
	pos1 = l.index(1)
	l[pos1] = -1
	pos2 = l.index(2)
	l[pos2] = -1
	pos3 = l.index(3)
	l[pos3] = -1
	print(pos1 + 1, pos2 + 1, pos3 + 1)


x = int(input())
l = list(map(int, input().split()))
a = l.count(1)
b = l.count(2)
c = l.count(3)
d = min(a, b, c)
print(d)
for i in range(d):
	k = l.index(1)
	m = l.index(2)
	n = l.index(3)
	print(k + 1, m + 1, n + 1)
	l[k] = 0
	l[m] = 0
	l[n] = 0


n = int(input())
lis = [int(i) for i in input().split()]
l1 = []
l2 = []
l3 = []
for i in range(0, n):
	if lis[i] == 1:
		l1.append(i)
for i in range(0, n):
	if lis[i] == 2:
		l2.append(i)
for i in range(0, n):
	if lis[i] == 3:
		l3.append(i)
m = min(len(l1), len(l2), len(l3))
print(m)
if m != 0:
	for i in range(0, m):
		print(l1[i] + 1, l2[i] + 1, l3[i] + 1)


n = int(input())
pupils = input().split(' ')
(math, geek, sport) = ([], [], [])
for i in range(n):
	if pupils[i] == '1':
		geek.append(i)
	if pupils[i] == '2':
		math.append(i)
	if pupils[i] == '3':
		sport.append(i)
teams = min(len(math), len(geek), len(sport))
print(teams)
for i in range(teams):
	print(geek[i] + 1, math[i] + 1, sport[i] + 1)


def solve():
	n = int(input())
	t = list(map(int, input().split()))
	d = dict = {1: 0, 2: 0, 3: 0}
	for i in t:
		d[i] += 1
	minimum = 1000000
	for i in d:
		minimum = min(minimum, d[i])
	print(minimum)
	if minimum == 0:
		return
	flag = [True] * n
	pos_1 = 0
	pos_2 = 0
	pos_3 = 0
	for i in range(minimum):
		ans = ''
		for j in range(pos_1, n):
			if t[j] == 1 and flag[j] == True:
				ans += str(j + 1)
				flag[j] = False
				pos_1 = j + 1
				break
		for j in range(pos_2, n):
			if t[j] == 2 and flag[j] == True:
				ans += ' ' + str(j + 1)
				flag[j] = False
				pos_2 = j + 1
				break
		for j in range(pos_3, n):
			if t[j] == 3 and flag[j] == True:
				ans += ' ' + str(j + 1)
				flag[j] = False
				pos_3 = j + 1
				break
		print(ans)
solve()


n = int(input())
li = input().split()
li1 = [i for i in range(len(li)) if li[i] == '1']
li2 = [i for i in range(len(li)) if li[i] == '2']
li3 = [i for i in range(len(li)) if li[i] == '3']
m = min(len(li1), len(li2), len(li3))
print(m)
for i in range(m):
	print(li1[i] + 1, li2[i] + 1, li3[i] + 1)


n = int(input())
childrens = list(map(int, input().split()))
c1 = childrens.count(1)
c2 = childrens.count(2)
c3 = childrens.count(3)
teams = []
for i in range(min(c1, c2, c3)):
	teams.append(childrens.index(1) + 1)
	childrens[childrens.index(1)] = 0
	teams.append(childrens.index(2) + 1)
	childrens[childrens.index(2)] = 0
	teams.append(childrens.index(3) + 1)
	childrens[childrens.index(3)] = 0
if len(teams) == 0:
	print(0)
else:
	print(len(teams) // 3)
	for i in range(len(teams) // 2):
		print(teams[i], end=' ')
	print()
	for j in range(i + 1, len(teams)):
		print(teams[j], end=' ')


n = int(input())
a = list(map(int, input().split()))
x = []
y = []
z = []
for i in range(len(a)):
	if a[i] == 1:
		x.append(i)
	elif a[i] == 2:
		y.append(i)
	else:
		z.append(i)
k = min(len(x), min(len(y), len(z)))
print(k)
for i in range(k):
	print(x[i] + 1, end=' ')
	print(y[i] + 1, end=' ')
	print(z[i] + 1)


n = int(input())
l = input().split()
a = l.count('1')
b = l.count('2')
c = l.count('3')
w = min(a, b, c)
print(w)
la = []
lb = []
lc = []
for i in range(n):
	if l[i] == '1':
		la.append(i)
	elif l[i] == '2':
		lb.append(i)
	else:
		lc.append(i)
for i in range(w):
	print(str(la[i] + 1) + ' ' + str(lb[i] + 1) + ' ' + str(lc[i] + 1))


int(input())
list1 = []
list2 = []
list3 = []
anslist = []
x = [int(item) for item in input().split()]
count1 = x.count(1)
count2 = x.count(2)
count3 = x.count(3)
minoflist = min(count1, count2, count3)
print(minoflist)
enux = list(enumerate(x))
for (a, b) in enux:
	if b == 1:
		list1.append(a + 1)
	elif b == 2:
		list2.append(a + 1)
	else:
		list3.append(a + 1)
for item in list(range(minoflist)):
	anslist.append((str(list1[item]), str(list2[item]), str(list3[item])))
for items in anslist:
	print(' '.join(items))


_ = input()
t_arr = list(map(int, input().split()))
v1 = {1: [], 2: [], 3: []}
for t_idx in range(len(t_arr)):
	v1[t_arr[t_idx]].append(t_idx + 1)
num_trips = min(len(v1[1]), len(v1[2]), len(v1[3]))
if num_trips == 0:
	print(0)
else:
	print(num_trips)
	for i in range(num_trips):
		print(v1[1][i], v1[2][i], v1[3][i])


n = int(input())
a = list(map(int, input().split()))
b = []
b.append(a.count(1))
b.append(a.count(2))
b.append(a.count(3))
m = min(b)
print(m)
for i in range(m):
	x = a.index(1)
	a[x] = 5
	y = a.index(2)
	a[y] = 5
	z = a.index(3)
	a[z] = 5
	print(x + 1, y + 1, z + 1)


n = int(input())
t = [0 for i in range(4)]
m = map(int, input().split())
ta = [[] for i in range(4)]
ind = 0
for k in m:
	ind += 1
	ta[k].append(ind)
min_element = min(len(ta[1]), len(ta[2]), len(ta[3]))
print(min_element)
for i in range(min_element):
	ans = str(ta[1][i]) + ' ' + str(ta[2][i]) + ' ' + str(ta[3][i])
	print(ans)


n = int(input())
l = list(map(int, input().split()))
a = min(l.count(1), l.count(2), l.count(3))
print(a)
(l1, l2, l3) = ([], [], [])
for i in range(n):
	if l[i] == 1:
		l1.append(i + 1)
	if l[i] == 2:
		l2.append(i + 1)
	if l[i] == 3:
		l3.append(i + 1)
for i in range(a):
	print(l1[i], l2[i], l3[i])


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


n = int(input())
nums = [int(x) - 1 for x in input().split()]
asd = [[] for _ in range(3)]
for (i, v) in enumerate(nums, 1):
	asd[v].append(i)
print(min(map(len, asd)))
for (a, b, c) in zip(*asd):
	print(a, b, c)


from collections import Counter
global_list = []
n = int(input())
tags = list(map(int, input().split(' ')))
u_tags = set(tags)
if len(u_tags) < 3:
	print(0)
	exit()
frequency = Counter(tags)
key_of_min = min(frequency.keys(), key=lambda k: frequency[k])
lowest_value = frequency[key_of_min]
total_group = lowest_value
print(total_group)
from collections import defaultdict

def list_duplicates(seq):
	tally = defaultdict(list)
	for (i, item) in enumerate(seq):
		tally[item].append(i)
	return ((key, locs) for (key, locs) in tally.items() if len(locs) >= 1)
for dup in sorted(list_duplicates(tags)):
	global_list.append(dup[1])
for group in range(total_group):
	print(global_list[0][group] + 1, global_list[1][group] + 1, global_list[2][group] + 1)


n = int(input())
s = input()
s = s.split()
d = []
pa = []
pb = []
pc = []
ca = 0
cb = 0
cc = 0
for i in range(0, len(s)):
	temp = int(s[i])
	if temp == 1:
		ca += 1
		pa.append(i)
	if temp == 2:
		cb += 1
		pb.append(i)
	if temp == 3:
		cc += 1
		pc.append(i)
mn = min(ca, cb, cc)
if mn == 0:
	print(0)
else:
	print(mn)
	for i in range(0, mn):
		print(' '.join([str(pa[i] + 1), str(pb[i] + 1), str(pc[i] + 1)]))


n = int(input())
(k1, k2, k3) = (0, 0, 0)
c = [0]
a = [int(i) for i in input().split(' ')]
for i in range(len(a)):
	if a[i] == 1:
		k1 = k1 + 1
	elif a[i] == 2:
		k2 = k2 + 1
	else:
		k3 = k3 + 1
f = min(k1, k2, k3)
print(f)
for i in range(f):
	b = ''
	n1 = a.index(1)
	n2 = a.index(2)
	n3 = a.index(3)
	b = b + str(a.index(1) + 1) + ' ' + str(a.index(2) + 1) + ' ' + str(a.index(3) + 1)
	print(b)
	n1 = a.index(1)
	a = a[:n1] + c + a[n1 + 1:]
	n2 = a.index(2)
	a = a[:n2] + c + a[n2 + 1:]
	n3 = a.index(3)
	a = a[:n3] + c + a[n3 + 1:]


n = int(input())
arr = [int(x) for x in input().split()]
arr1 = []
arr2 = []
arr3 = []
for i in range(n):
	if arr[i] == 1:
		arr1.append(i + 1)
	elif arr[i] == 2:
		arr2.append(i + 1)
	else:
		arr3.append(i + 1)
m = min(len(arr1), len(arr2), len(arr3))
print(m)
for j in range(m):
	print(arr1[j], arr2[j], arr3[j])


import sys
input = sys.stdin.readline
n = int(input().rstrip())
s = [[] for i in range(3)]
j = 0
for i in map(int, input().rstrip().split()):
	s[i - 1].append(j)
	j += 1
min_s = len(min(s, key=lambda x: len(x)))
print(min_s)
if min_s > 0:
	for i in range(min_s):
		print(s[0][i] + 1, s[1][i] + 1, s[2][i] + 1)


nStr = input()
n = int(nStr)
memberList = list(map(int, input().split()))
memberList1 = list()
memberList2 = list()
memberList3 = list()
for i in range(len(memberList)):
	if memberList[i] == 1:
		memberList1.append(i + 1)
	elif memberList[i] == 2:
		memberList2.append(i + 1)
	elif memberList[i] == 3:
		memberList3.append(i + 1)
	else:
		continue
w = min(len(memberList1), len(memberList2), len(memberList3))
print(w)
for j in range(w):
	print(memberList1[j], memberList2[j], memberList3[j])


n = int(input())
p = [int(x) for x in input().split()]
a = [[], [], []]
for (i, v) in enumerate(p):
	a[v - 1].append(i + 1)
(pr, math, ph) = a

def Min(a, b):
	if a < b:
		return a
	return b
answer = Min(len(pr), Min(len(math), len(ph)))
print(answer)
for i in range(answer):
	print(pr[i], math[i], ph[i])


n = int(input(''))
list = [int(x) for x in input('').split()]
list2 = [0, 0, 0]
for x in list:
	if x == 1:
		list2[0] += 1
	elif x == 2:
		list2[1] += 1
	elif x == 3:
		list2[2] += 1
list2.sort()
z = list2[0]
print(z)
if z == 0:
	exit()
i = 0
k = 1
j = 0
list2 = []
while i < z:
	if 1 in list:
		d = list.index(1)
		print(d + 1, end=' ')
		list[d] = 5
		if 2 in list:
			d = list.index(2)
			print(d + 1, end=' ')
			list[d] = 5
			if 3 in list:
				d = list.index(3)
				print(d + 1, end=' ')
				list[d] = 5
				print('')
	i += 1


n = int(input())
s = input()
l = []
pc = 0
mc = 0
sc = 0
for i in s.split():
	l.append(int(i))
for i in l:
	if i == 1:
		pc += 1
	elif i == 2:
		mc += 1
	elif i == 3:
		sc += 1
team = 0
while pc != 0 and mc != 0 and (sc != 0):
	pc = pc - 1
	mc = mc - 1
	sc = sc - 1
	team = team + 1
print(team)
pci = []
mci = []
sci = []
for i in range(len(l)):
	if l[i] == 1:
		pci.append(i)
	elif l[i] == 2:
		mci.append(i)
	elif l[i] == 3:
		sci.append(i)
while team != 0:
	for i in range(team):
		print(pci[i] + 1, mci[i] + 1, sci[i] + 1)
		team = team - 1


n = int(input())
t = 0
t2 = 0
l = [int(i) for i in input().split()]
l2 = l[:]
l2.sort()
t1 = l.count(1)
t2 = l.count(2)
t3 = l.count(3)
i1 = 0
i2 = t1
i3 = t1 + t2
print(min(t1, t2, t3))
for i in range(min(t1, t2, t3)):
	print(l.index(l2[i1]) + 1, l.index(l2[i2]) + 1, l.index(l2[i3]) + 1)
	l[l.index(l2[i1])] = -1
	l[l.index(l2[i2])] = -1
	l[l.index(l2[i3])] = -1
	l2[i1] = -1
	l2[i2] = -2
	l2[i3] = -3
	i1 += 1
	i2 += 1
	i3 += 1


n = int(input())
s = list(map(int, input().split()))
t1 = s.count(1)
t2 = s.count(2)
t3 = s.count(3)
a = min(min(t1, t2), t3)
print(a)
for i in range(0, a):
	p = s.index(1)
	q = s.index(2)
	r = s.index(3)
	print(p + 1, q + 1, r + 1)
	s[p] = s[q] = s[r] = 5


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


n = int(input())
arr = list(map(int, input().split()))
d = {1: [], 2: [], 3: []}
for (i, a) in enumerate(arr):
	d[a].append(i + 1)
t = min(map(len, d.values()))
print(t)
if t:
	for i in range(t):
		print(d[1][i], d[2][i], d[3][i])


n = int(input())
l = list(map(int, input().split()))
pro = []
ma = []
pe = []
for i in range(1, n + 1):
	x = l[i - 1]
	if x == 1:
		pro.append(i)
	if x == 2:
		ma.append(i)
	if x == 3:
		pe.append(i)
mi = min(len(pro), len(ma), len(pe))
print(mi)
for i in range(mi):
	print(pro[i], ma[i], pe[i])


n = int(input())
L = [int(i) for i in input().split()]
L1 = []
L2 = []
L3 = []
for i in range(len(L)):
	if L[i] == 1:
		L1.append(i + 1)
	elif L[i] == 2:
		L2.append(i + 1)
	elif L[i] == 3:
		L3.append(i + 1)
x = min(len(L1), len(L2), len(L3))
print(x)
i = 0
while i < x:
	print(L1[i], L2[i], L3[i], '\n')
	i += 1


try:
	n = int(input())
	arr = [int(ele) for ele in input().split()]
	arr1 = []
	arr2 = []
	arr3 = []
	if 1 in arr and 2 in arr and (3 in arr):
		for i in range(0, n):
			if arr[i] == 1:
				arr1.append(i + 1)
			elif arr[i] == 2:
				arr2.append(i + 1)
			else:
				arr3.append(i + 1)
		k = min(len(arr1), len(arr2), len(arr3))
		print(k)
		for i in range(k):
			print(arr1[i], arr2[i], arr3[i])
	else:
		print(0)
except Exception:
	pass


n = int(input())
students = input().split()
skills = {}
(skills['1'], skills['2'], skills['3']) = ([], [], [])
for i in range(n):
	skills[students[i]].append(i + 1)
P = len(skills['1'])
M = len(skills['2'])
PE = len(skills['3'])
m = min(P, M, PE)
print(m)
for i in range(m):
	print(skills['1'].pop(), skills['2'].pop(), skills['3'].pop())


def olympiad(n, array):
	ones = list()
	twos = list()
	threes = list()
	for i in range(len(array)):
		if array[i] == 1:
			ones.append(i + 1)
		elif array[i] == 2:
			twos.append(i + 1)
		else:
			threes.append(i + 1)
	teams = min(len(ones), len(twos), len(threes))
	print(teams)
	for i in range(teams):
		print(ones[i], twos[i], threes[i])
n = input()
array = [int(x) for x in input().split()]
olympiad(int(n), array)


n_children = int(input())
skills = [int(x) for x in input().split(' ')]
pos_groups = min(skills.count(1), skills.count(2), skills.count(3))
print(pos_groups)
for _ in range(pos_groups):
	(a, b, c) = (skills.index(1), skills.index(2), skills.index(3))
	print(a + 1, b + 1, c + 1)
	skills[skills.index(1)] = 0
	skills[skills.index(2)] = 0
	skills[skills.index(3)] = 0


amount = int(input())
kids = [int(i) for i in input().split()]
a = kids.count(1)
b = kids.count(2)
c = kids.count(3)
a = min(a, b, c)
print(a)
ans = ''
for i in range(a):
	ans = str(kids.index(1) + 1) + ' ' + str(kids.index(2) + 1) + ' ' + str(kids.index(3) + 1)
	kids[kids.index(1)] = 0
	kids[kids.index(2)] = 0
	kids[kids.index(3)] = 0
	print(ans)


n = int(input())
t = map(int, input().split())
(t1, t2, t3) = ([], [], [])
for (i, v) in enumerate(t, 1):
	if v == 1:
		t1.append(i)
	elif v == 2:
		t2.append(i)
	else:
		t3.append(i)
print(min(len(t1), len(t2), len(t3)))
for (i1, i2, i3) in zip(t1, t2, t3):
	print(i1, i2, i3)


n = int(input())
l = list(map(int, input().split()))
n1 = len(l) // 3
(l1, l2, l3) = ([], [], [])
if len(set(l)) != 3:
	print(0)
for i in range(len(l)):
	if l[i] == 1:
		l1.append((l[i], i))
	elif l[i] == 2:
		l2.append((l[i], i))
	elif l[i] == 3:
		l3.append((l[i], i))
z1 = l.count(1)
z2 = l.count(2)
z3 = l.count(3)
z = min(z1, z2, z3)
if z != 0:
	print(z)
for i in range(z):
	print(l1[i][1] + 1, l2[i][1] + 1, l3[i][1] + 1)


n = int(input())
one = []
two = []
three = []
l = list(map(int, input().split()))
for i in range(n):
	if l[i] == 1:
		one.append(i + 1)
	elif l[i] == 2:
		two.append(i + 1)
	else:
		three.append(i + 1)
j = [len(one), len(two), len(three)]
print(min(j))
if min(j) > 0:
	for k in range(min(j)):
		print(one[k], two[k], three[k])


import math
import itertools
gh = lambda : map(int, input().split())
intin = lambda : int(input())

def main():
	input()
	a = []
	b = []
	c = []
	ind = 1
	for i in list(gh()):
		if i == 1:
			a.append(ind)
		if i == 2:
			b.append(ind)
		if i == 3:
			c.append(ind)
		ind += 1
	x = min(min(len(a), len(b)), len(c))
	print(x)
	while x:
		x -= 1
		print(a[-1], b[-1], c[-1])
		a.pop()
		b.pop()
		c.pop()
main()


import math
n = int(input())
all = [int(all) for all in input().split()]
m = min(all.count(1), all.count(2), all.count(3))
print(m)
for i in range(m):
	tmp = []
	k = 0
	for j in range(len(all)):
		if all[j] != 0:
			if all[j] in tmp:
				continue
			else:
				k += 1
				tmp.append(all[j])
				all[j] = 0
				print(j + 1, end=' ')
			if k == 3:
				break
	print()


def input_split(f):
	return map(f, input().split())

def main():
	n = int(input())
	t_list = list(input_split(int))
	res = []
	f = lambda v: v + 1
	while True:
		if 1 in t_list and 2 in t_list and (3 in t_list):
			(a, b, c) = (t_list.index(1), t_list.index(2), t_list.index(3))
			(t_list[a], t_list[b], t_list[c]) = (0, 0, 0)
			res.append((f(a), f(b), f(c)))
		else:
			break
	print(str(len(res)))
	for j in res:
		print(' '.join(map(str, j)))
main()


def LinearSearch(a, x):
	for i in range(len(a)):
		if a[i] == x:
			return i + 1
	return -1
n = int(input())
a = input()
prog = a.count('1')
math = a.count('2')
pe = a.count('3')
a = a.split()
for i in range(n):
	a[i] = int(a[i])
res = min(prog, math, pe)
print(res)
team = ''
if res > 0:
	for i in range(res):
		a1 = LinearSearch(a, 1)
		a2 = LinearSearch(a, 2)
		a3 = LinearSearch(a, 3)
		team += str(a1) + ' ' + str(a2) + ' ' + str(a3)
		a[a1 - 1] = -1
		a[a2 - 1] = -1
		a[a3 - 1] = -1
		print(team)
		team = ''


n = int(input())
c1 = 0
c2 = 0
c3 = 0
a = [int(x) for x in input().split()]
res = []
while c1 < n and c2 < n and (c3 < n):
	while c1 < n and a[c1] != 1:
		c1 += 1
	while c2 < n and a[c2] != 2:
		c2 += 1
	while c3 < n and a[c3] != 3:
		c3 += 1
	c1 += 1
	c2 += 1
	c3 += 1
	if c1 <= n and c2 <= n and (c3 <= n):
		res.append([c1, c2, c3])
if len(res) == 0:
	print(0)
else:
	print(len(res))
	for i in res:
		print(' '.join([str(x) for x in i]))


n = int(input())
m = [int(i) for i in input().split()]
x = []
y = []
z = []
for i in range(n):
	if m[i] == 1:
		x.append(i + 1)
	elif m[i] == 2:
		y.append(i + 1)
	else:
		z.append(i + 1)
ma = min(len(x), len(y), len(z))
print(ma)
for i in range(ma):
	print(x[i], y[i], z[i])


n = int(input())
l = list(map(int, input().split()))
m = []
n = []
o = []
for i in range(len(l)):
	if l[i] == 1:
		m.append(i + 1)
	elif l[i] == 2:
		n.append(i + 1)
	elif l[i] == 3:
		o.append(i + 1)
m.sort(reverse=True)
n.sort(reverse=True)
o.sort(reverse=True)
p = []
p.append(len(m))
p.append(len(n))
p.append(len(o))
if min(p) == 0:
	print('0')
	quit()
print(min(p))
for j in range(min(p)):
	print(m[j], n[j], o[j])


n = int(input())
arr = list(map(int, input().split()))
l1 = []
l2 = []
l3 = []
for (i, v) in enumerate(arr):
	if v == 1:
		l1.append(i + 1)
	elif v == 2:
		l2.append(i + 1)
	else:
		l3.append(i + 1)
print(min(len(l1), len(l2), len(l3)))
i = 0
while i < len(l1) and i < len(l2) and (i < len(l3)):
	print(l1[i], ' ', l2[i], ' ', l3[i])
	i += 1


n = int(input())
kids = [int(c) for c in input().split()]
w = min([kids.count(i) for i in range(1, 4)])
teams = [{} for i in range(w)]
for (index, kid) in enumerate(kids):
	for team in teams:
		if kid not in team:
			team[kid] = index
			break
print(w)
for team in teams:
	for index in team.values():
		print(index + 1, end=' ')
	print('')


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()


i = int(input())
l1 = list(map(int, input().strip().split()))
one = []
two = []
three = []
for d in range(0, i):
	if l1[d] == 1:
		one.append(d + 1)
	elif l1[d] == 2:
		two.append(d + 1)
	else:
		three.append(d + 1)
if min(len(one), len(two), len(three)) == 0:
	print(0)
else:
	print(min(len(one), len(two), len(three)))
	for d in range(0, min(len(one), len(two), len(three))):
		print(one[d], two[d], three[d])


n = int(input())
s = [int(s) for s in input().split()]
a = b = c = 0
for i in s:
	if i == 1:
		a += 1
	elif i == 2:
		b += 1
	elif i == 3:
		c += 1
print(max(min(a, b, c), 0))
for i in range(min(a, b, c)):
	z = []
	z.append(s.index(1) + 1)
	s[z[0] - 1] = 0
	z.append(s.index(2) + 1)
	s[z[1] - 1] = 0
	z.append(s.index(3) + 1)
	s[z[2] - 1] = 0
	print(*z, sep=' ')


n = int(input())
f = list(map(int, input().split()))
pr = []
mat = []
sp = []
for i in range(n):
	if f[i] == 1:
		pr.append(i + 1)
	elif f[i] == 2:
		mat.append(i + 1)
	else:
		sp.append(i + 1)
k = min(len(pr), len(mat), len(sp))
print(k)
for i in range(k):
	print(pr[i], mat[i], sp[i])


l = [[], [], []]
input()
for (i, j) in enumerate(map(int, input().split()), 1):
	l[j - 1] += [i]
n = min(map(len, l))
print(n)
for i in range(n):
	print(l[0][i], l[1][i], l[-1][i])


n = int(input(''))
ar = list(map(int, input().split()))
f = min(ar.count(1), ar.count(2), ar.count(3))
print(f)
p = []
q = []
r = []
for i in range(0, len(ar)):
	if ar[i] == 1:
		p.append(i + 1)
	elif ar[i] == 2:
		q.append(i + 1)
	else:
		r.append(i + 1)
for i in range(f):
	print(str(p[i]) + ' ' + str(q[i]) + ' ' + str(r[i]) + ' ')


n = int(input())
arr = list(map(int, input().split()))
(x, y, z) = (arr.count(1), arr.count(2), arr.count(3))
a = min([x, y, z])
print(a)
if a != 0:
	while a > 0:
		print(arr.index(1) + 1, end=' ')
		arr[arr.index(1)] = 0
		print(arr.index(2) + 1, end=' ')
		arr[arr.index(2)] = 0
		print(arr.index(3) + 1, end=' ')
		arr[arr.index(3)] = 0
		a -= 1
		print()


n = int(input())
t = list(map(int, input().split()))
a = t.count(1)
b = t.count(2)
c = t.count(3)
print(min(a, b, c))
x = []
y = []
z = []
for i in range(n):
	if t[i] == 1:
		x.append(i)
	if t[i] == 2:
		y.append(i)
	if t[i] == 3:
		z.append(i)
for i in range(min(a, b, c)):
	print(x[i] + 1, y[i] + 1, z[i] + 1)


import math, os, sys
import string, re
import itertools, functools, operator
from collections import Counter

def inputint():
	return int(input())

def inputarray(func=int):
	return map(func, input().split())
k = inputint()
A = list(enumerate(inputarray()))
B = list(filter(lambda x: x[1] == 1, A))
C = list(filter(lambda x: x[1] == 2, A))
D = list(filter(lambda x: x[1] == 3, A))
print(min(len(B), len(C), len(D)))
for (b, c, d) in zip(B, C, D):
	print(b[0] + 1, c[0] + 1, d[0] + 1)


n = int(input())
gift = list(map(int, input().split()))
num = min(gift.count(1), gift.count(2), gift.count(3))
print(num)
if num != 0:
	teams = {1: [], 2: [], 3: []}
	for (i, g) in enumerate(gift):
		teams[g] = teams[g] + [i + 1]
	for i in range(num):
		print(teams[1][i], teams[2][i], teams[3][i])


n = int(input())
a = list(map(int, input().split()))
good = [[], [], [], []]
for i in range(n):
	good[a[i]].append(i)
cnt = min(len(good[1]), len(good[2]), len(good[3]))
print(cnt)
for i in range(cnt):
	print(str(good[1][i] + 1) + ' ' + str(good[2][i] + 1) + ' ' + str(good[3][i] + 1))


n = int(input())
t = [int(c) for c in input().split()]
teams = min(min(t.count(1), t.count(2)), t.count(3))
print(teams)
for i in range(teams):
	print(t.index(1) + 1, end=' ')
	t[t.index(1)] = 0
	print(t.index(2) + 1, end=' ')
	t[t.index(2)] = 0
	print(t.index(3) + 1)
	t[t.index(3)] = 0


n = int(input())
l = list(map(int, input().split()))
x = l.count(1)
y = l.count(2)
z = l.count(3)
m = min(x, y, z)
print(m)
if m > 0:
	for i in range(m):
		v = l.index(1)
		u = l.index(2)
		w = l.index(3)
		print(v + 1, u + 1, w + 1)
		l[u] = 0
		l[v] = 0
		l[w] = 0


n = int(input())
t = list(map(int, input().split()))
w = []
(one, two, three) = (0, 0, 0)
o = []
ss = []
h = []
for i in range(len(t)):
	if t[i] == 1:
		one += 1
		o.append(i + 1)
	if t[i] == 2:
		two += 1
		ss.append(i + 1)
	if t[i] == 3:
		three += 1
		h.append(i + 1)
if one != 0 or two != 0 or three != 0:
	w.append(one)
	w.append(two)
	w.append(three)
	w = sorted(w)
	print(w[0])
	count = 0
	while count != w[0]:
		print(o[count], ss[count], h[count])
		count += 1
else:
	print(0)


n = int(input())
skills = [(index + 1, int(skill)) for (index, skill) in enumerate(input().split())]
skills.sort(key=lambda x: x[1])
teams = {}
(team, previous, cont) = (0, -1, 0)
for (index, skill) in skills:
	if skill != previous:
		team = 0
	previous = skill
	if team not in teams:
		teams[team] = []
	teams[team].append(index)
	if len(teams[team]) == 3:
		cont += 1
	team += 1
print(cont)
for (_, team) in teams.items():
	if len(team) == 3:
		print(*team, sep=' ')


def main():
	t = int(input())
	collect = list(map(int, input().split()))
	scollect = []
	final = []
	for item in collect:
		scollect.append(str(item))
	if '1' not in scollect or '2' not in scollect or '3' not in scollect:
		print(0)
	else:
		count1 = scollect.count('1')
		count2 = scollect.count('2')
		count3 = scollect.count('3')
		lit = min(count1, count2, count3)
		print(lit)
		while lit != 0:
			x = scollect.index('1')
			y = scollect.index('2')
			z = scollect.index('3')
			final.append([x + 1, y + 1, z + 1])
			scollect[x] = 0
			scollect[y] = 0
			scollect[z] = 0
			lit -= 1
		for item in final:
			print(item[0], item[1], item[2])
main()


n = int(input())
t = list(map(int, input().split()))
(s, w) = (dict(), n)
for i in range(n):
	if t[i] not in s:
		s[t[i]] = [i + 1]
	else:
		s[t[i]].append(i + 1)
if 1 not in s or 2 not in s or 3 not in s:
	print('0')
else:
	for i in s:
		if len(s[i]) < w:
			w = len(s[i])
	print(w)
	for i in range(w):
		print(s[1][i], s[2][i], s[3][i])


n = input()
list = input().split()
one = []
two = []
three = []
for (i, x) in enumerate(list):
	if x == '1':
		one.append(i + 1)
	elif x == '2':
		two.append(i + 1)
	else:
		three.append(i + 1)
size = min(len(one), len(two), len(three))
print(size)
for j in range(size):
	print(one[j], two[j], three[j])


import sys
from math import ceil, log, gcd
RI = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('Yes')

def NO():
	print('No')
INF = 10 ** 18
MOD = 10 ** 9 + 7
dic = {1: [], 2: [], 3: []}
n = int(ri())
a = RI()
for i in range(len(a)):
	if a[i] in dic:
		dic[a[i]].append(i)
	else:
		dic[a[i]] = [i]
maxx = INF
for i in dic:
	maxx = min(maxx, len(dic.get(i, [])))
print(maxx)
for i in range(maxx):
	print(dic[1][i] + 1, end=' ')
	print(dic[2][i] + 1, end=' ')
	print(dic[3][i] + 1, end=' ')
	print()


n = int(input())
k = list(map(int, input().split()))
a = []
b = []
c = []
for i in range(len(k)):
	if k[i] == 1:
		a.append(i + 1)
	if k[i] == 2:
		b.append(i + 1)
	if k[i] == 3:
		c.append(i + 1)
teams = min([len(a), len(b), len(c)])
print(teams)
for i in range(teams):
	print(f'{a[i]} {b[i]} {c[i]}')


x = int(input())
lst = list(map(int, input().split()))
arr = [[], [], []]
i = 0
while i < x:
	arr[lst[i] - 1] += [i + 1]
	i += 1
k = min(map(len, arr))
print(k)
while k:
	print(arr[0].pop(), arr[1].pop(), arr[2].pop())
	k -= 1


n = int(input())
b = input()
a = [int(n) for n in b.split()]
p = [0 for i in range(5)]
num = [[0] * 5010 for i in range(5)]
for i in range(0, n):
	p[a[i]] = p[a[i]] + 1
	num[a[i]][p[a[i]]] = i + 1
t = min(p[1], min(p[2], p[3]))
print(t)
for i in range(1, t + 1):
	print(num[1][i], num[2][i], num[3][i])


n = int(input())
l = list(map(int, input().strip().split()[:n]))
a = []
b = []
c = []
for x in range(len(l)):
	if l[x] == 1:
		a.append(x + 1)
	elif l[x] == 2:
		b.append(x + 1)
	else:
		c.append(x + 1)
p = min(len(a), len(b), len(c))
print(min(len(a), len(b), len(c)))
for x in range(p):
	print(a[x], b[x], c[x])


n = int(input())
t = list(map(int, input().split()))
d = {}
for i in range(n):
	if t[i] in d:
		d[t[i]].append(i + 1)
	else:
		d[t[i]] = [i + 1]
if len(d) < 3:
	print(0)
	exit(0)
a = min(len(d[1]), len(d[2]), len(d[3]))
print(a)
if a > 0:
	for i in range(a):
		print(d[1][i], d[2][i], d[3][i])


n = int(input())
p = []
m = []
pe = []
sub = [int(x) for x in input().split()]
for i in range(0, n):
	if sub[i] == 1:
		p.append(i + 1)
	elif sub[i] == 2:
		m.append(i + 1)
	elif sub[i] == 3:
		pe.append(i + 1)
res = 0
res = min(len(p), len(m), len(pe))
print(res)
for i in range(0, res):
	print(p[i], m[i], pe[i])


fu = input()
numbers = list(map(int, input().split()))
num1 = numbers.count(1)
num2 = numbers.count(2)
num3 = numbers.count(3)
Min = min(num1, num2, num3)
ind1 = ind2 = ind3 = -1
print(Min)
l = ''
for i in numbers:
	try:
		c1 = numbers.index(1, ind1 + 1)
		ind1 = c1
		c2 = numbers.index(2, ind2 + 1)
		ind2 = c2
		c3 = numbers.index(3, ind3 + 1)
		ind3 = c3
	except:
		break
	print(c1 + 1, c2 + 1, c3 + 1)


n = int(input())
t = list(map(int, input().split()))
p = []
m = []
e = []
for i in range(n):
	if t[i] == 1:
		p.append(i)
	if t[i] == 2:
		m.append(i)
	if t[i] == 3:
		e.append(i)
print(min(len(p), len(m), len(e)))
while len(p) > 0 and len(m) > 0 and len(e):
	print(p[0] + 1, m[0] + 1, e[0] + 1)
	p.remove(p[0])
	m.remove(m[0])
	e.remove(e[0])


n = int(input())
t = list(map(int, input().split(' ')))
pr = []
mat = []
sp = []
for i in range(n):
	if t[i] == 1:
		pr.append(i + 1)
	elif t[i] == 2:
		mat.append(i + 1)
	else:
		sp.append(i + 1)
a = min(len(pr), len(sp), len(mat))
print(a)
for i in range(a):
	print(pr[i], end=' ')
	print(mat[i], end=' ')
	print(sp[i])


n = int(input())
l = [int(x) for x in input().split()]
a = l.count(1)
b = l.count(2)
c = l.count(3)
d = min(a, b, c)
if d == 0:
	print('0')
else:
	print(d)
	while d > 0:
		e = l.index(1)
		f = l.index(2)
		g = l.index(3)
		l[e] = 0
		l[f] = 0
		l[g] = 0
		print(e + 1, f + 1, g + 1)
		d = d - 1


n = int(input())
lis = input().split()
lis = [int(x) for x in lis]
l = [0, 0, 0]
for i in lis:
	if i == 1:
		l[0] += 1
	elif i == 2:
		l[1] += 1
	elif i == 3:
		l[2] += 1
m = min(l)
print(m)
for i in range(m):
	a = lis.index(1)
	b = lis.index(2)
	c = lis.index(3)
	print(a + 1, b + 1, c + 1)
	lis[a] = 0
	lis[b] = 0
	lis[c] = 0


length = int(input())
numbers = [int(i) for i in input().split()]
one = numbers.count(1)
two = numbers.count(2)
three = numbers.count(3)
print(min(one, two, three))
indexes1 = []
indexes2 = []
indexes3 = []
for pos in range(len(numbers)):
	if numbers[pos] == 1:
		indexes1.append(pos)
	elif numbers[pos] == 2:
		indexes2.append(pos)
	else:
		indexes3.append(pos)
for x in range(min(one, two, three)):
	print(indexes1[x] + 1, indexes2[x] + 1, indexes3[x] + 1)


n = int(input())
t = list(map(int, input().split()))
prog = []
math = []
pe = []
lst = []
for i in range(n):
	if t[i] == 1:
		prog.append(i + 1)
	if t[i] == 2:
		math.append(i + 1)
	if t[i] == 3:
		pe.append(i + 1)
w = min(len(prog), len(math), len(pe))
print(w)
for j in range(w):
	print(prog[j], math[j], pe[j], sep=' ')


programmer = []
mathematician = []
sportsmen = []
n = int(input())
l = list(input().split())
l = [int(i) for i in l]
for i in range(n):
	if l[i] == 1:
		programmer.append(i + 1)
	elif l[i] == 2:
		mathematician.append(i + 1)
	else:
		sportsmen.append(i + 1)
a = min(len(programmer), len(mathematician), len(sportsmen))
print(a)
for i in range(a):
	print(str(programmer[0]) + ' ' + str(mathematician[0]) + ' ' + str(sportsmen[0]))
	programmer.pop(0)
	mathematician.pop(0)
	sportsmen.pop(0)


a = int(input())
b = input().split(' ')
s1 = []
s2 = []
s3 = []
if len(set(b)) < 3:
	print(0)
else:
	for i in range(a):
		if b[i] == '1':
			s1.append(i + 1)
		elif b[i] == '2':
			s2.append(i + 1)
		elif b[i] == '3':
			s3.append(i + 1)
	c = min(len(s1), len(s2), len(s3))
	print(c)
	for j in range(c):
		print(s1[j], s2[j], s3[j])


t = int(input())
a = list(map(int, input().split()))
p = a.count(1)
q = a.count(2)
r = a.count(3)
g = 0
if 1 not in a or 2 not in a or 3 not in a:
	print(0)
	exit()
while p != 0 and q != 0 and (r != 0):
	g += 1
	p -= 1
	q -= 1
	r -= 1
print(g)
while 1 in a and 2 in a and (3 in a):
	b = a.index(1)
	print(b + 1, end=' ')
	a[b] = 0
	c = a.index(2)
	print(c + 1, end=' ')
	a[c] = 0
	d = a.index(3)
	print(d + 1)
	a[d] = 0


n = int(input())
a = list(map(int, input().split()))
(a1, a2, a3) = ([], [], [])
m = min(a.count(1), a.count(2), a.count(3))
print(m)
for i in range(n):
	if a[i] == 1 and len(a1) <= m:
		a1.append(i)
	if a[i] == 2 and len(a2) <= m:
		a2.append(i)
	if a[i] == 3 and len(a3) <= m:
		a3.append(i)
	if a1 == a2 == a3 == m:
		break
for (i, j, k) in zip(a1, a2, a3):
	print(i + 1, j + 1, k + 1)


n = int(input())
t = list(map(int, input().split()))
w = min(t.count(1), t.count(2), t.count(3))
print(w)
for i in range(w):
	print(t.index(1) + 1, end=' ')
	t[t.index(1)] = 4
	print(t.index(2) + 1, end=' ')
	t[t.index(2)] = 4
	print(t.index(3) + 1, end=' ')
	t[t.index(3)] = 4
	print()


n = int(input())
a = list(map(int, input().split()))
p = a.count(1)
m = a.count(2)
s = a.count(3)
print(min(p, m, s))
if min(p, m, s) == 0:
	exit()
i1 = []
i2 = []
i3 = []
for i in range(n):
	if a[i] == 1:
		i1.append(i)
	if a[i] == 2:
		i2.append(i)
	if a[i] == 3:
		i3.append(i)
for i in range(min(p, m, s)):
	x = ' '
	print(str(i1[i] + 1) + x + str(i2[i] + 1) + x + str(i3[i] + 1))


n = int(input())
a = [[] for i in range(3)]
for (indice, i) in enumerate(map(int, input().split())):
	a[i - 1].append(indice + 1)
h = min([len(a[i]) for i in range(3)])
print(h)
for i in range(h):
	for b in range(3):
		print(a[b][i], end=' ')
	print()


n = int(input())
a = list(map(int, input().split()))
(one, two, three) = (0, 0, 0)
for i in range(len(a)):
	if a[i] == 1:
		one += 1
	elif a[i] == 2:
		two += 1
	elif a[i] == 3:
		three += 1
print(min(one, two, three))
for i in range(len(a)):
	if 1 in a and 2 in a and (3 in a):
		print(a.index(1) + 1, a.index(2) + 1, a.index(3) + 1)
	else:
		break
	a[a.index(1)] = 0
	a[a.index(2)] = 0
	a[a.index(3)] = 0


n = int(input())
skills = [int(i) for i in input().split(' ')]
skills_1 = skills.count(1)
skills_2 = skills.count(2)
skills_3 = skills.count(3)
teams = min(skills_1, min(skills_2, skills_3))
print(teams)
for i in range(teams):
	b = skills.index(1)
	print(b + 1, end=' ')
	skills[b] = 100
	c = skills.index(2)
	print(c + 1, end=' ')
	skills[c] = 100
	d = skills.index(3)
	print(d + 1)
	skills[d] = 100


n = int(input())
x = input()
xx = x.split()
a = []
b = []
c = []
for i in range(0, n):
	if xx[i] == '1':
		a.append(i + 1)
	elif xx[i] == '2':
		b.append(i + 1)
	else:
		c.append(i + 1)
hjhj = [len(a), len(b), len(c)]
w = min(hjhj)
print(w)
for i in range(0, w):
	print(a[i], end=' ')
	print(b[i], end=' ')
	print(c[i])


n = int(input())
l = list(input().split())
one = l.count('1')
two = l.count('2')
three = l.count('3')
if one == 0 or two == 0 or three == 0:
	print('0')
else:
	t = min(one, two, three)
	print(t)
	ek = l.index('1')
	dui = l.index('2')
	tin = l.index('3')
	print(ek + 1, dui + 1, tin + 1)
	for i in range(t - 1):
		ek = l.index('1', ek + 1)
		dui = l.index('2', dui + 1)
		tin = l.index('3', tin + 1)
		print(ek + 1, dui + 1, tin + 1)


n = int(input())
list = [int(i) for i in input().split()]
(a, b, c) = ([], [], [])
for i in range(n):
	x = list[i]
	if x == 1:
		a.append(i + 1)
	elif x == 2:
		b.append(i + 1)
	else:
		c.append(i + 1)
if len(a) == 0 or len(b) == 0 or len(c) == 0:
	print(0)
elif len(a) <= len(b) and len(a) <= len(c):
	print(len(a))
	for i in range(len(a)):
		print(a[i], b[i], c[i])
elif len(b) <= len(a) and len(b) <= len(c):
	print(len(b))
	for i in range(len(b)):
		print(a[i], b[i], c[i])
else:
	print(len(c))
	for i in range(len(c)):
		print(a[i], b[i], c[i])


n = int(input())
x = [int(g) for g in input().split()]
(a, b, c) = ([], [], [])
j = 0
(t, r, y) = (0, 0, 0)
for i in range(n):
	if x[i] == 1:
		a.append(i + 1)
		t += 1
	elif x[i] == 2:
		b.append(i + 1)
		r += 1
	else:
		c.append(i + 1)
		y += 1
	if t >= 1 and r >= 1 and (y >= 1):
		t -= 1
		r -= 1
		y -= 1
		j += 1
print(j)
for i in range(min(len(a), len(b), len(c))):
	if a[i] > 0 and b[i] > 0 and (c[i] > 0):
		print(a[i], b[i], c[i], sep=' ')


n = int(input())
t = 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])


people = int(input())
specs = list(map(int, input().split()))
math = list()
code = list()
sport = list()
for i in range(people):
	if specs[i] == 1:
		code.append(i)
	elif specs[i] == 2:
		math.append(i)
	else:
		sport.append(i)
teams = min(len(code), len(math), len(sport))
print(teams)
for i in range(teams):
	print(code[i] + 1, math[i] + 1, sport[i] + 1)


input()
pupils = list(map(int, input().split()))
a = []
b = []
c = []
index = 1
for i in pupils:
	if i == 1:
		a.append(index)
	elif i == 2:
		b.append(index)
	else:
		c.append(index)
	index += 1
counts = []
counts.append(len(a))
counts.append(len(b))
counts.append(len(c))
minT = min(counts)
print(minT)
for i in range(minT):
	print(a[i], b[i], c[i])


n = int(input())
s = [int(i) for i in input().split()]
c = [[d + 1 for d in range(n) if s[d] == f] for f in range(1, 4)]
teams = list(zip(*c))
print(len(teams))
for r in teams:
	print(*r)


n = int(input())
a = list(map(int, input().split()))
(x, y, z, ans) = (0, 0, 0, min(a.count(1), min(a.count(2), a.count(3))))
print(ans)
while ans > 0:
	print(a[x:n].index(1) + x + 1, a[y:n].index(2) + y + 1, a[z:n].index(3) + z + 1)
	(x, y, z, ans) = (x + a[x:n].index(1) + 1, y + a[y:n].index(2) + 1, z + a[z:n].index(3) + 1, ans - 1)


n = int(input())
one = 0
two = 0
three = 0
ele = []
list_one = []
list_two = []
list_three = []
ele = [int(x) for x in input().split()]
for i in range(0, n):
	if ele[i] == 1:
		list_one.append(i + 1)
		one += 1
	elif ele[i] == 2:
		list_two.append(i + 1)
		two += 1
	else:
		list_three.append(i + 1)
		three += 1
mi = min(one, min(two, three))
if mi == 0:
	print('0\n')
else:
	print('{}'.format(mi))
	for i in range(0, mi):
		print('{} {} {}'.format(list_one[i], list_two[i], list_three[i]))


n = int(input())
t = list(map(int, input().split()))
c = min(t.count(1), t.count(2), t.count(3))
print(c)
if c > 0:
	for i in range(c):
		print(str(t.index(1) + 1) + ' ' + str(t.index(2) + 1) + ' ' + str(t.index(3) + 1))
		t[t.index(1)] = -1
		t[t.index(2)] = -1
		t[t.index(3)] = -1


n = int(input())
s = list(map(int, input().split(' ')))
(count1, count2, count3) = (0, 0, 0)
(team1, team2, team3) = ([], [], [])
for i in range(n):
	if s[i] == 1:
		count1 += 1
		team1.append(i)
	if s[i] == 2:
		count2 += 1
		team2.append(i)
	if s[i] == 3:
		count3 += 1
		team3.append(i)
t = min(count1, count2, count3)
print(t)
for i in range(t):
	print(team1[i] + 1, team2[i] + 1, team3[i] + 1)


m = int(input())
l = input().split()
l1 = []
l2 = []
l3 = []
for i in range(len(l)):
	if l[i] == '1':
		l1.append(str(i))
	elif l[i] == '2':
		l2.append(str(i))
	else:
		l3.append(str(i))
z = min(len(l1), len(l2), len(l3))
if z != 0:
	u = min(z, m)
	print(u)
	for x in range(u):
		a = int(l1.pop()) + 1
		b = int(l2.pop()) + 1
		c = int(l3.pop()) + 1
		print(a, b, c)
else:
	print(0)


def make_comands(ch_likes):
	left = 0
	right = 0
	balance = 0
	comands = dict()
	comand = list()
	strong = list()
	for i in range(len(ch_likes)):
		for j in range(i, len(ch_likes)):
			if ch_likes[j] is not None:
				if balance + ch_likes[j] <= 6 and ch_likes[j] not in strong:
					strong.append(ch_likes[j])
					balance = balance + ch_likes[j]
					comand.append(j + 1)
					ch_likes[j] = None
				if len(comand) == 3:
					strong = list()
					num = len(comands) + 1
					comands[num] = comand
					comand = list()
					balance = 0
					break
	return comands

def main():
	_ = input()
	ch_likes = list(map(int, input().split()))
	result = make_comands(ch_likes)
	print(len(result))
	for cmd in result:
		print(*result[cmd])
main()


n = int(input())
sequence = [int(i) for i in input().split(' ')]
no_of_teams = min(sequence.count(1), sequence.count(2), sequence.count(3))
print(no_of_teams)
for _ in range(no_of_teams):
	print(sequence.index(1) + 1, sequence.index(2) + 1, sequence.index(3) + 1)
	sequence[sequence.index(1)] = 0
	sequence[sequence.index(2)] = 0
	sequence[sequence.index(3)] = 0


def solve(n, s):
	d = {}
	c_1 = 0
	c_2 = 0
	c_3 = 0
	for j in range(n):
		if s[j] not in d:
			d[s[j]] = list()
		if s[j] == 1:
			c_1 += 1
		elif s[j] == 2:
			c_2 += 1
		elif s[j] == 3:
			c_3 += 1
		d[s[j]].append(j + 1)
	m = min(c_1, c_2, c_3)
	if m == 0:
		print(0)
		return None
	else:
		print(m)
		for i in range(m):
			ans = [str(d[j][i]) for j in d]
			print(' '.join(ans))
n = int(input())
s = list(map(int, input().split()))
solve(n, s)


a = int(input())
b = list(map(int, input().split(' ')))
one = b.count(1)
two = b.count(2)
three = b.count(3)
print(min(one, two, three))
while b.count(1) != 0 and b.count(2) != 0 and (b.count(3) != 0):
	c = b.index(1)
	d = b.index(2)
	e = b.index(3)
	b.remove(1)
	b.insert(c, 0)
	b.remove(2)
	b.insert(d, 0)
	b.remove(3)
	b.insert(e, 0)
	print(c + 1, d + 1, e + 1)


input()
l = input().split()
if len(set(l)) < 3:
	print(0)
	exit()
c = min([l.count(i) for i in set(l)])
i1 = i2 = i3 = 0
print(c)
for i in range(c):
	i1 += 1 + l[i1:].index('1')
	i2 += 1 + l[i2:].index('2')
	i3 += 1 + l[i3:].index('3')
	print(i1, i2, i3)


n = int(input())
arr = list(map(int, input().split(' ')))
ans = [0] * 3
a1 = []
a2 = []
a3 = []
count = 1
for i in arr:
	ans[i - 1] += 1
	if i == 1:
		a1.append(count)
	elif i == 2:
		a2.append(count)
	else:
		a3.append(count)
	count += 1
if 0 in ans:
	print(0)
else:
	y = min(ans)
	print(y)
	for j in range(y):
		print(a1[j], a2[j], a3[j], sep=' ')


def m(a, b, c):
	if a <= b:
		if a <= c:
			return a
		else:
			return c
	elif b <= c:
		return b
	else:
		return c
num = int(input())
line = [int(x) for x in input().split()]
n1 = n2 = n3 = 0
for i in range(num):
	if line[i] == 1:
		n1 += 1
	elif line[i] == 2:
		n2 += 1
	else:
		n3 += 1
w = m(n1, n2, n3)
group = [[] for i in range(3)]
ng = []
k1 = k2 = k3 = 1
if w == 0:
	print(w)
else:
	for i in range(num):
		if line[i] == 1 and k1 <= w:
			group[0].append(str(i + 1))
			k1 += 1
	for i in range(num):
		if line[i] == 2 and k2 <= w:
			group[1].append(str(i + 1))
			k2 += 1
	for i in range(num):
		if line[i] == 3 and k3 <= w:
			group[2].append(str(i + 1))
			k3 += 1
	for i in range(len(group[0])):
		n = []
		for j in range(3):
			n.append(group[j][i])
		ng.append(n)
	print(w)
	for i in range(w):
		print(' '.join(ng[i]))


n = int(input())
l = list(map(int, input().split()))
ans = min(l.count(1), l.count(2), l.count(3))
d = list(zip(range(1, n + 1), l))
s1 = list(filter(lambda x: x[1] == 1, d))
s2 = list(filter(lambda x: x[1] == 2, d))
s3 = list(filter(lambda x: x[1] == 3, d))
print(ans)
if ans != 0:
	for i in range(ans):
		print(s1[i][0], s2[i][0], s3[i][0])


a = int(input())
b = list(map(int, input().split()))
count = 0
for i in range(1, 4):
	if i not in b:
		count = count + 1
		break
o = 0
o1 = 0
o2 = 0
x = []
z = []
y = []
h = []
s = []
f = []
d = []
for i in b:
	if count == 1:
		break
	elif i == 1:
		x.append(b.index(i, o))
	elif i == 2:
		z.append(b.index(i, o1))
	else:
		y.append(b.index(i, o2))
	o += 1
	o1 += 1
	o2 += 1

def found():
	if len(x) != len(z) or len(x) != len(y) or len(y) != len(z):
		for i in range(3):
			if len(x) > len(z):
				while len(x) != len(z):
					x.pop()
			elif len(x) < len(y):
				while len(y) != len(x):
					y.pop()
			elif len(z) > len(y):
				while len(z) != len(y):
					z.pop()
	return (x, z, y)
v = found()

def pop():
	e = len(x) + len(z) + len(y)
	g = e / 3
	return round(g)
print(pop())
for i in range(pop()):
	print(str(x[i] + 1) + ' ' + str(z[i] + 1) + ' ' + str(y[i] + 1))


n = int(input())
nums = list(map(int, input().split()))
teamCount = min(nums.count(1), nums.count(2), nums.count(3))
if not 1 in nums or not 2 in nums or (not 3 in nums):
	print(0)
else:
	print(teamCount)
	for i in range(teamCount):
		i1 = nums.index(1)
		i2 = nums.index(2)
		i3 = nums.index(3)
		print(i1 + 1, i2 + 1, i3 + 1)
		nums[i1] = 0
		nums[i2] = 0
		nums[i3] = 0


n = int(input())
l = list(map(int, input().split()))
a = l.count(1)
b = l.count(2)
c = l.count(3)
if a == 0 or b == 0 or c == 0:
	print(0)
else:
	x = min(a, b, c)
	print(x)
	for i in range(x):
		m = [str(l.index(1) + 1), str(l.index(2) + 1), str(l.index(3) + 1)]
		l[l.index(1)] = 0
		l[l.index(2)] = 0
		l[l.index(3)] = 0
		print(' '.join(m))


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_char_list = lambda : sys.stdin.readline().strip().split()
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x))
n = get_int()
students = get_int_list()
a = students.count(1)
b = students.count(2)
c = students.count(3)
ans = min(a, b, c)
if ans <= 0:
	print(ans)
else:
	print(ans)
	for i in range(ans):
		a = students.index(1)
		b = students.index(2)
		c = students.index(3)
		students[a] = -1
		students[b] = -1
		students[c] = -1
		print(a + 1, b + 1, c + 1)


n = int(input())
a = list(map(int, input().split()))
t = 0
tl = []
for i in range(n):
	apnd = False
	lngth = len(tl)
	for j in range(lngth):
		if a[i] not in [x[0] for x in tl[j]]:
			tl[j].append((a[i], i + 1))
			apnd = True
			if len(tl[j]) == 3:
				t += 1
			break
	if lngth == 0 or apnd == False:
		tl.append([(a[i], i + 1)])
print(t)
for k in tl:
	if len(k) == 3:
		for l in k:
			print(l[1], end=' ')
		print()


members = int(input())
cap = [int(x) for x in input().split()]
(pro, mat, edf) = ([], [], [])
aaa = [0, pro, mat, edf]
for i in range(members):
	aaa[cap[i]].append(i + 1)
cu = min([len(pro), len(mat), len(edf)])
print(cu)
for buceta in range(cu):
	a = []
	for pinto in range(1, 4):
		a.append(str(aaa[pinto][buceta]))
	print(' '.join(a))


def teams(arr):
	di = {}
	for (i, n) in enumerate(arr):
		if n in di:
			di[n].append(i + 1)
		else:
			di[n] = [i + 1]
	ans = []
	while True:
		tmp = []
		if di[1]:
			tmp.append(di[1].pop())
		else:
			break
		if di[2]:
			tmp.append(di[2].pop())
		else:
			break
		if di[3]:
			tmp.append(di[3].pop())
		else:
			break
		ans.append(tmp)
	print(len(ans))
	for i in ans:
		for j in i:
			print(j, '', end='')
		print()
n = int(input())
x = list(map(int, input().rstrip().split()))
if 1 not in x or 2 not in x or 3 not in x:
	print(0)
else:
	teams(x)


n = int(input())
a = input().split(sep=' ')
counst = [0, 0, 0]
for x in a:
	if x == '1':
		counst[0] += 1
	elif x == '2':
		counst[1] += 1
	else:
		counst[2] += 1
print(min(counst))
t_skills = []
t_indxs = []
for team in range(0, min(counst)):
	for i in range(0, n):
		if a[i] != 0 and a[i] not in t_skills:
			t_skills.append(a[i])
			a[i] = 0
			t_indxs.append(i + 1)
			if len(t_skills) == 3:
				break
	for x in t_indxs:
		print(x, end=' ')
	print()
	t_skills.clear()
	t_indxs.clear()


n = int(input())
y = 0
j = 0
k = 0
lst1 = [int(item) for item in input().split()]
a = lst1.count(1)
b = lst1.count(2)
c = lst1.count(3)
mn = min(a, b, c)
if mn == 1:
	print(1)
	x = lst1.index(1)
	v = lst1.index(2)
	s = lst1.index(3)
	print(x + 1, v + 1, s + 1)
else:
	print(mn)
	for i in range(mn):
		x = lst1.index(1, y)
		y = x + 1
		v = lst1.index(2, k)
		k = v + 1
		s = lst1.index(3, j)
		j = s + 1
		print(x + 1, v + 1, s + 1)


n = int(input())
li = list(map(int, input().split()))[:n]
prog = []
progC = 0
math = []
mathC = 0
pe = []
peC = 0
for i in range(n):
	if li[i] == 1:
		prog.append(i + 1)
		progC += 1
	elif li[i] == 2:
		math.append(i + 1)
		mathC += 1
	elif li[i] == 3:
		pe.append(i + 1)
		peC += 1
teams = min(progC, mathC, peC)
print(teams)
for i in range(teams):
	print(prog[i], math[i], pe[i])


a = [[5001, []], [0, []], [0, []], [0, []]]
n = int(input())
l = [*map(int, input().split())]
for i in range(n):
	a[l[i]][0] += 1
	a[l[i]][1].append(i + 1)
a = sorted(a)
print(a[0][0])
for i in range(a[0][0]):
	for j in range(3):
		print(a[j][1][i], end=' ')
	print()


n = int(input())
l = list(map(int, input().split()))
c1 = l.count(1)
c2 = l.count(2)
c3 = l.count(3)
c = 0
cond = True
while True:
	if c1 >= 1 and c2 >= 1 and (c3 >= 1):
		c += 1
		c1 -= 1
		c2 -= 1
		c3 -= 1
	else:
		cond = False
		break
print(c)
for i in range(c):
	print(l.index(1) + 1, l.index(2) + 1, l.index(3) + 1)
	l[l.index(1)] = 0
	l[l.index(2)] = 0
	l[l.index(3)] = 0


t = int(input())
q = [int(x) for x in input().split()]
n = min(q.count(1), q.count(2), q.count(3))
print(n)
for _ in range(n):
	i1 = q.index(1) + 1
	i2 = q.index(2) + 1
	i3 = q.index(3) + 1
	q[i1 - 1] = -1
	q[i2 - 1] = -1
	q[i3 - 1] = -1
	print(i1, end=' ')
	print(i2, end=' ')
	print(i3)


t = int(input())
l = list(map(int, input().split()))
l1 = []
l2 = []
l3 = []
for i in range(t):
	if l[i] == 1:
		l1.append(i + 1)
	elif l[i] == 2:
		l2.append(i + 1)
	else:
		l3.append(i + 1)
x = min(len(l1), min(len(l2), len(l3)))
if x == 0:
	print(0)
else:
	print(x)
	for i in range(x):
		print(l1[i], l2[i], l3[i])


input()
x = list(map(int, input().split()))
a = []
b = []
c = []
for i in range(len(x)):
	if x[i] == 1:
		a.append(i)
	elif x[i] == 2:
		b.append(i)
	else:
		c.append(i)
w = min(len(a), len(b), len(c))
print(w)
for j in range(0, w):
	print(str(a[j] + 1) + ' ' + str(b[j] + 1) + ' ' + str(c[j] + 1))


n = int(input())
perfect = list(map(int, input().split()))
programe = list()
math = list()
pe = list()
for i in range(len(perfect)):
	t = perfect[i]
	if t == 1:
		programe.append(i + 1)
	elif t == 2:
		math.append(i + 1)
	else:
		pe.append(i + 1)
team = min(len(programe), len(math), len(pe))
print(team)
for i in range(team):
	print(programe[i], ' ', math[i], ' ', pe[i])


n = int(input())
a = input()
a = a.replace(' ', '')
(kol1, kol2, kol3) = (0, 0, 0)
for i in range(n):
	if a[i] == '1':
		kol1 += 1
	elif a[i] == '2':
		kol2 += 1
	else:
		kol3 += 1
if kol1 == 0 or kol2 == 0 or kol3 == 0:
	print(0)
else:
	k = min(kol1, kol2, kol3)
	print(k)
	while k > 0:
		print(a.index('1') + 1, a.index('2') + 1, a.index('3') + 1)
		a = a.replace('1', '0', 1)
		a = a.replace('2', '0', 1)
		a = a.replace('3', '0', 1)
		k -= 1


n = int(input())
a = [int(i) for i in input().split()]
l = []
m = []
d = 1
k = 0
s = 0
while s < n * 500:
	for i in range(n):
		s += 1
		if a[i] == d:
			d += 1
			l.append(i + 1)
			a[i] = 0
		if d == 4:
			d = 1
			k += 1
if k == 0:
	print(0)
	exit(0)
print(k)
k = len(l)
while k % 3 != 0:
	k -= 1
for i in range(k):
	print(l[i], end=' ')
	if (i + 1) % 3 == 0:
		print()


z = int(input())
ar = [int(x) for x in input().split()]
tprog = []
tmath = []
tpyh = []
for i in range(0, len(ar)):
	if ar[i] == 1:
		tprog.append(i)
	elif ar[i] == 2:
		tmath.append(i)
	else:
		tpyh.append(i)
w = min(ar.count(1), min(ar.count(2), ar.count(3)))
print(str(w))
for i in range(0, w):
	print(tprog[i] + 1, tmath[i] + 1, tpyh[i] + 1)


import sys
import math
input = sys.stdin.readline
n = int(input())
a = map(int, input().split())
l = [[], [], []]
for (i, ai) in enumerate(a, 1):
	l[ai - 1].append(i)
print(min(len(l[0]), len(l[1]), len(l[2])))
for j in zip(*l):
	print(' '.join(map(str, j)))


n = int(input())
a = list(map(int, input().strip().split()))
c1 = 0
c2 = 0
c3 = 0
for i in a:
	if i == 1:
		c1 += 1
	elif i == 2:
		c2 += 1
	else:
		c3 += 1
c = min(c1, c2, c3)
print(c)
while c:
	for i in [1, 2, 3]:
		print(a.index(i) + 1, end=' ')
		a[a.index(i)] = 0
	print('')
	c -= 1


def main():
	n = int(input())
	s = list(map(int, input().split()))
	cnt = [0, 0, 0]
	for i in s:
		cnt[i - 1] += 1
	p = min(cnt)
	if p == 0:
		print(0)
	else:
		out = [[0, 0, 0] for _ in range(p)]
		(j0, j1, j2, j, i) = (0, 0, 0, 0, 0)
		while j < 3 * p:
			if j0 < p and s[i] == 1:
				out[j0][0] = i + 1
				j0 += 1
				j += 1
			if j1 < p and s[i] == 2:
				out[j1][1] = i + 1
				j1 += 1
				j += 1
			if j2 < p and s[i] == 3:
				out[j2][2] = i + 1
				j2 += 1
				j += 1
			i += 1
		print(p)
		for i in range(p):
			print(out[i][0], out[i][1], out[i][2])
main()


n = int(input())
a = list(map(int, input().split()))
x = []
y = []
z = []
o = []
if a.count(1) != 0 and a.count(2) != 0 and (a.count(3) != 0):
	for i in range(n):
		if a[i] == 1:
			x.append(i + 1)
		elif a[i] == 2:
			y.append(i + 1)
		else:
			z.append(i + 1)
	x1 = len(x)
	y1 = len(y)
	z1 = len(z)
	o.append(x1)
	o.append(y1)
	o.append(z1)
	w = min(o)
	print(w)
	for i in range(w):
		print(x[i], y[i], z[i])
else:
	print('0')


t = int(input())
arr = [int(x) for x in input().split()]
p = []
m = []
s = []
for i in range(len(arr)):
	if arr[i] == 1:
		p.append(i + 1)
	elif arr[i] == 2:
		m.append(i + 1)
	else:
		s.append(i + 1)
if p == [] or m == [] or s == []:
	print(0)
else:
	x = min(len(s), len(m), len(p))
	print(x)
	for i in range(x):
		print(p[i], m[i], s[i])


n = int(input())
l = list(map(int, input().split()))
(l1, l2, l3) = ([], [], [])
for x in range(n):
	if l[x] == 1:
		l1.append(x + 1)
	if l[x] == 2:
		l2.append(x + 1)
	if l[x] == 3:
		l3.append(x + 1)
if min(len(l1), len(l2), len(l3)) == 0:
	print(0)
else:
	print(min(len(l1), len(l2), len(l3)))
	for x in range(min(len(l1), len(l2), len(l3))):
		print(l1[x], l2[x], l3[x])


n = int(input())
lis = [int(x) for x in input().split()]
dic = {'1': [], '2': [], '3': []}
for i in range(0, n):
	if lis[i] == 1:
		dic['1'].append(i + 1)
	elif lis[i] == 2:
		dic['2'].append(i + 1)
	elif lis[i] == 3:
		dic['3'].append(i + 1)
o = lis.count(1)
t = lis.count(2)
th = lis.count(3)
mini = o
if mini > t:
	mini = t
if mini > th:
	mini = th
print(mini)
for i in range(0, mini):
	print(dic['1'][i], end=' ')
	print(dic['2'][i], end=' ')
	print(dic['3'][i])


n = int(input())
students = list(map(int, input().split()))
teams = [[], [], []]
for i in range(n):
	if students[i] == 1:
		teams[0].append(i + 1)
	elif students[i] == 2:
		teams[1].append(i + 1)
	elif students[i] == 3:
		teams[2].append(i + 1)
print(min(len(teams[0]), len(teams[1]), len(teams[2])))
for j in range(min(len(teams[0]), len(teams[1]), len(teams[2]))):
	actual = [teams[0][j], teams[1][j], teams[2][j]]
	print(*actual)


n = int(input())
a = list(map(int, input().split()))
a.insert(0, -1)
d = [-1, 0, 0, 0]
vt = [-1, [], [], []]
for i in range(1, n + 1):
	d[a[i]] += 1
	vt[a[i]].append(i)
d.pop(0)
c = min(d)
t = -1
for i in range(0, 3):
	if d[i] == c:
		t = i + 1
print(c)
for i in range(len(vt[t])):
	print(vt[1][i], vt[2][i], vt[3][i])


n = int(input())
v = list(map(int, input().split()))
T = [[], [], [], []]
for i in range(n):
	T[v[i]].append(i + 1)
k = min(v.count(1), v.count(2), v.count(3))
print(k)
while k > 0:
	k -= 1
	print(T[1][-1], T[2][-1], T[3][-1])
	T[1].pop()
	T[2].pop()
	T[3].pop()


n = int(input())
x = [int(x) for x in input().split()]
a = []
b = []
c = []
for i in range(n):
	if x[i] == 1:
		a.append(i + 1)
	if x[i] == 2:
		b.append(i + 1)
	if x[i] == 3:
		c.append(i + 1)
p = x.count(1)
q = x.count(2)
r = x.count(3)
l = [p, q, r]
z = min(l)
print(z)
for i in range(z):
	print(a[i], b[i], c[i])


x = input()
inp = input().split()
a = inp.count('1')
b = inp.count('2')
c = inp.count('3')
x = min(a, b, c)
print(x)
for i in range(x):
	a = inp.index('1')
	b = inp.index('2')
	c = inp.index('3')
	inp[a] = inp[b] = inp[c] = 0
	print(a + 1, b + 1, c + 1)


input()
listo = list(map(int, input().split()))
if 1 not in listo and 2 not in listo and (3 not in listo):
	print(0)
else:
	count = 0
	z = []
	while 1 in listo and 2 in listo and (3 in listo):
		count += 1
		z.append((listo.index(1) + 1, listo.index(2) + 1, listo.index(3) + 1))
		listo[listo.index(1)] = 0
		listo[listo.index(2)] = 0
		listo[listo.index(3)] = 0
	print(count)
	for i in range(count):
		print('{} {} {}'.format(z[i][0], z[i][1], z[i][2]))


def TeamOlympiad():
	n = int(input())
	children = {1: [], 2: [], 3: []}
	talent_math = []
	talent_prog = []
	talent_pe = []
	temp = [*map(int, input().strip().split())]
	for i in range(n):
		children[temp[i]].append(i + 1)
	return (min(len(children[1]), len(children[2]), len(children[3])), zip(children[1], children[2], children[3]))
a = TeamOlympiad()
print(a[0])
for team in a[1]:
	print(*team)


n = int(input())
a = [int(i) for i in input().split()]
fq = [0] * 4
s = []
o = []
r = []
for i in range(n):
	fq[a[i]] += 1
	if a[i] == 1:
		s.append(i + 1)
	if a[i] == 2:
		o.append(i + 1)
	if a[i] == 3:
		r.append(i + 1)
T_n = min(fq[1], fq[2], fq[3])
print(T_n)
if T_n > 0:
	for i in range(T_n):
		print(s[i], o[i], r[i])


n = int(input())
t = [int(x) for x in input().split()]
one = []
two = []
three = []
for i in range(len(t)):
	if t[i] == 1:
		one.append(i + 1)
	elif t[i] == 2:
		two.append(i + 1)
	else:
		three.append(i + 1)
print(min(len(one), len(two), len(three)))
for (x, y, z) in zip(one, two, three):
	print(x, y, z)


from sys import stdin
i = [x.rstrip().split() for x in stdin.readlines()][1]
(c1, c2, c3) = ([], [], [])
for (j, x) in enumerate(i):
	if x == '1':
		c1.append(j + 1)
	elif x == '2':
		c2.append(j + 1)
	else:
		c3.append(j + 1)
minLen = min(len(c1), len(c2), len(c3))
print(minLen)
for (a, b, c) in zip(c1[:minLen], c2[:minLen], c3[:minLen]):
	print(a, b, c)


n = int(input())
li = [int(x) for x in input().split()]
one = li.count(1)
two = li.count(2)
three = li.count(3)
if one == 0 or two == 0 or three == 0:
	print(0)
else:
	one_in = [i for (i, val) in enumerate(li) if val == 1]
	two_in = [i for (i, val) in enumerate(li) if val == 2]
	three_in = [i for (i, val) in enumerate(li) if val == 3]
	min = min(one, two, three)
	print(min)
	for i in range(min):
		print(one_in[i] + 1, two_in[i] + 1, three_in[i] + 1)


n = int(input())
t = [[], [], []]
for (i, v) in enumerate(input().split()):
	t[int(v) - 1].append(i + 1)
print(min(map(len, t)))
for arr in zip(*t):
	print(arr[0], arr[1], arr[2])


import sys
import math as m

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def sinp():
	return sys.stdin.readline().strip()

def iinp():
	return int(input())

def ninp():
	return map(int, sys.stdin.readline().strip().split())

def linp():
	return list(map(int, sys.stdin.readline().strip().split()))

def p(a):
	print(a)
n = iinp()
t = linp()
l1 = []
l2 = []
l3 = []
ind = 0
for i in t:
	if i == 1:
		l1.append(ind + 1)
		ind += 1
	elif i == 2:
		l2.append(ind + 1)
		ind += 1
	else:
		l3.append(ind + 1)
		ind += 1
if len(l1) == 0 or len(l2) == 0 or len(l3) == 0:
	print(0)
else:
	print(min(len(l1), len(l2), len(l3)))
	ind = 0
	for j in range(min(len(l1), len(l2), len(l3))):
		print(l1[ind], end=' ')
		print(l2[ind], end=' ')
		print(l3[ind], end=' ')
		ind += 1
		print()


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


a = int(input())
b = input().split()
a1 = []
a2 = []
a3 = []
for i in range(len(b)):
	exec('a' + b[i] + '.append(int(i)+1)')
c = []
c.append(len(a1))
c.append(len(a2))
c.append(len(a3))
c.sort()
print(c[0])
for i in range(c[0]):
	print(str(a1[i]) + ' ' + str(a2[i]) + ' ' + str(a3[i]))


x = int(input())
l = [int(x) for x in input().split()]
l1 = []
l2 = []
l3 = []
for i in range(len(l)):
	if l[i] == 1:
		l1.append(i + 1)
	elif l[i] == 2:
		l2.append(i + 1)
	else:
		l3.append(i + 1)
print(min(len(l1), len(l2), len(l3)))
for i in range(min(len(l1), len(l2), len(l3))):
	print(str(l1[i]) + ' ' + str(l2[i]) + ' ' + str(l3[i]))


_ = input()
l = ['0'] + list(input().split())
c = min([l.count('1'), l.count('2'), l.count('3')]) + 1
if c == 1:
	print(0)
else:
	(t1, t2, t3) = (0, 0, 0)
	print(c - 1)
	for i in range(1, c):
		(t1, t2, t3) = (l.index('1', t1 + 1), l.index('2', t2 + 1), l.index('3', t3 + 1))
		print(t1, t2, t3)


n = int(input())
ip = list(map(int, input().split()))
x = y = z = 0
t1 = []
t2 = []
t3 = []
for i in range(n):
	if ip[i] == 1:
		x = x + 1
		t1.append(i + 1)
	elif ip[i] == 2:
		y = y + 1
		t2.append(i + 1)
	elif ip[i] == 3:
		z = z + 1
		t3.append(i + 1)
min = x
if y < min:
	min = y
if z < min:
	min = z
print(min)
for i in range(min):
	print(t1[i], t2[i], t3[i])


n = int(input())
l = [int(x) for x in input().split()]
if len(set(l)) < 3:
	print(0)
else:
	t = min(l.count(1), l.count(2), l.count(3))
	print(t)
	for i in range(t):
		print(l.index(1) + 1, l.index(2) + 1, l.index(3) + 1)
		for j in range(1, 4):
			l[l.index(j)] = 0


n = int(input())
ls = list(map(int, input().split()))
(t1, t2, t3) = (list(), list(), list())
for i in range(n):
	if ls[i] == 1:
		t1.append(i)
	if ls[i] == 2:
		t2.append(i)
	if ls[i] == 3:
		t3.append(i)
num = min(len(t1), len(t2), len(t3))
print(num)
for i in range(num):
	print(t1[i] + 1, t2[i] + 1, t3[i] + 1)


n = int(input())
students = input().split()
(ones, twos, threes) = ([], [], [])
for i in range(len(students)):
	if students[i] == '1':
		ones.append(i + 1)
	elif students[i] == '2':
		twos.append(i + 1)
	elif students[i] == '3':
		threes.append(i + 1)
s = min(len(ones), len(twos), len(threes))
print(s)
for i in range(s):
	print(ones[i], twos[i], threes[i])


n = int(input())
v = [int(x) for x in input().split()]
v1 = []
v2 = []
v3 = []
for i in range(n):
	if v[i] == 1:
		v1.append(i + 1)
	elif v[i] == 2:
		v2.append(i + 1)
	else:
		v3.append(i + 1)
mn = min(len(v1), len(v2), len(v3))
print(mn)
for i in range(mn):
	print(v1[i], v2[i], v3[i])


n = int(input())
l = list(map(int, input().split()))
d = {1: [], 2: [], 3: []}
for i in range(n):
	d[l[i]].append(i + 1)
val = min(len(d[1]), len(d[2]), len(d[3]))
print(val)
for i in range(val):
	print(d[1][i], d[2][i], d[3][i])


n = input()
k = input()
T = k.split(' ')
T1 = []
T2 = []
T3 = []
TN = []
a = 0
while a < len(T):
	if T[a] == '1':
		p = a + 1
		T1.append(p)
	elif T[a] == '2':
		p = a + 1
		T2.append(p)
	elif T[a] == '3':
		p = a + 1
		T3.append(p)
	a += 1
for i in range(min(len(T1), len(T2), len(T3))):
	y = []
	y.append(T1[i])
	y.append(T2[i])
	y.append(T3[i])
	TN.append(y)
print(min(len(T1), len(T2), len(T3)))
for j in range(len(TN)):
	for d in range(3):
		print(TN[j][d], end=' ')
	print()


n = int(input())
t = list(map(int, input().split()))
a = 0
b = 0
c = 0
l1 = []
l2 = []
l3 = []
for i in range(len(t)):
	if t[i] == 1:
		a += 1
		l1.append(i + 1)
	elif t[i] == 2:
		b += 1
		l2.append(i + 1)
	elif t[i] == 3:
		c += 1
		l3.append(i + 1)
if a == b == c:
	print(a)
	for i in range(a):
		print(str(l1[i]) + ' ' + str(l2[i]) + ' ' + str(l3[i]))
else:
	x = min(a, b, c)
	print(x)
	for k in range(x):
		print(str(l1[k]) + ' ' + str(l2[k]) + ' ' + str(l3[k]))


n = input()
a = list(map(lambda x: int(x), input().split()))
math_kol = 0
prog_kol = 0
fiz_kol = 0
ls = [[], [], []]
i = 0
for ii in a:
	i += 1
	ls[ii - 1].append(i)
	if ii == 1:
		prog_kol += 1
	elif ii == 2:
		math_kol += 1
	else:
		fiz_kol += 1
n = min(prog_kol, math_kol, fiz_kol)
print(n)
for i in range(1, n + 1):
	print(ls[0].pop(), ls[1].pop(), ls[2].pop())
print()


N = int(input())
L = list(map(int, input().split()))
(C1, C2, C3) = ([], [], [])
for i in range(N):
	if L[i] == 1:
		C1.append(i)
	if L[i] == 2:
		C2.append(i)
	if L[i] == 3:
		C3.append(i)
X = min(len(C1), len(C2), len(C3))
print(X)
for i in range(X):
	print(C1[i] + 1, C2[i] + 1, C3[i] + 1)


n = int(input())
m = list(map(int, input().split()))
l = min(m.count(1), m.count(2), m.count(3))
print(l)
d = 0
j = n
for i in range(l):
	a = 0
	b = 0
	c = 0
	p = 1
	while p:
		if a == 0 and m[d % j] == 1:
			a = d % j + 1
			m[d % j] = 0
			d = d + 1
		if b == 0 and m[d % j] == 2:
			b = d % j + 1
			m[d % j] = 0
			d = d + 1
		if c == 0 and m[d % j] == 3:
			c = d % j + 1
			m[d % j] = 0
			d = d + 1
		d = d + 1
		if a != 0 and b != 0 and (c != 0):
			p = 0
	print(a, b, c)


n = int(input())
t = [int(x) for x in input().split()]
(one, two, three) = (0, 0, 0)
for i in range(n):
	if t[i] == 1:
		one += 1
	elif t[i] == 2:
		two += 1
	elif t[i] == 3:
		three += 1
team = min(one, two, three)
print(team)
for j in range(team):
	print(t.index(1) + 1, t.index(2) + 1, t.index(3) + 1)
	(t[t.index(1)], t[t.index(2)], t[t.index(3)]) = (0, 0, 0)


n = int(input())
li = [int(i) for i in input().split()]
one = []
two = []
three = []
for j in range(len(li)):
	if li[j] == 1:
		one.append(j + 1)
	elif li[j] == 2:
		two.append(j + 1)
	elif li[j] == 3:
		three.append(j + 1)
if (len(one) or len(two) or len(three)) < 1:
	print(0)
else:
	m = min(len(one), len(two), len(three))
	print(m)
	for k in range(m):
		print(f'{one[k]} {two[k]} {three[k]}')


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


n = int(input())
a = list(map(int, input().split()))
p1 = []
p2 = []
p3 = []
for i in range(n):
	if a[i] == 3:
		p3.append(i + 1)
	elif a[i] == 1:
		p1.append(i + 1)
	else:
		p2.append(i + 1)
t = min(len(p1), len(p2), len(p3))
if t > 0:
	print(t)
	for i in range(t):
		print('{} {} {}'.format(p1[i], p2[i], p3[i]))
else:
	print('0')


n = int(input())
x = [int(x) for x in input().split()]
a = set(x)
if len(a) == 3:
	x = [i - 4 for i in x]
	one_l = [i for (i, value) in enumerate(x) if value == -3]
	two_l = [i for (i, value) in enumerate(x) if value == -2]
	three_l = [i for (i, value) in enumerate(x) if value == -1]
	print(min(len(one_l), len(two_l), len(three_l)))
	for (a, b, c) in zip(one_l, two_l, three_l):
		print(a + 1, b + 1, c + 1)
else:
	print(0)


import sys

def stdinWrapper():
	data = '7\n1 3 1 3 2 1 2\n'
	for line in data.split('\n'):
		yield line
if '--debug' not in sys.argv:

	def stdinWrapper():
		while True:
			yield input()
inputs = stdinWrapper()

def inputWrapper():
	return next(inputs)
studentsCount = int(inputWrapper())
studentsSkills = [int(x) for x in inputWrapper().split()]
teams = {1: [], 2: [], 3: []}
for (i, skill) in enumerate(studentsSkills):
	teams[skill].append(i)
teamsCount = min([len(x) for x in teams.values()])
print(teamsCount)
for i in range(teamsCount):
	print(' '.join([str(t[i] + 1) for t in teams.values()]))


import math
from collections import Counter

def get(f):
	return map(f, input().split())

def divides(a, b):
	return a % b == 0

def main():
	n = int(input())
	students = list(get(int))
	pr = []
	ma = []
	ph = []
	choice = {1: pr, 2: ma, 3: ph}
	for i in range(n):
		choice[students[i]].append(i + 1)
	mi = min(len(pr), len(ma), len(ph))
	print(mi)
	for i in range(mi):
		print(pr[i], ma[i], ph[i])
main()


n = int(input())
s = input()
s = s.split(' ')
one = 0
two = 0
three = 0
index1 = []
index3 = []
index2 = []
for i in range(len(s)):
	if s[i] == '1':
		one += 1
		index1.append(i + 1)
	elif s[i] == '2':
		two += 1
		index2.append(i + 1)
	elif s[i] == '3':
		three += 1
		index3.append(i + 1)

def smaller(x, y):
	if x > y:
		return y
	else:
		return x
no = smaller(smaller(one, two), three)
shift = 0
print(no)
for i in range(no):
	print(str(index1[i]) + ' ' + str(index3[i]) + ' ' + str(index2[i]))


n = int(input())
a = list(map(int, input().split()))
i1 = []
i2 = []
i3 = []
for x in range(n):
	if a[x] == 1:
		i1.append(x + 1)
	elif a[x] == 2:
		i2.append(x + 1)
	else:
		i3.append(x + 1)
t = min(len(i1), len(i2), len(i3))
print(t)
for x in range(t):
	print(i1[x], i2[x], i3[x])


t = int(input())
ta = list(map(int, input().split()))
(p1, p2, p3) = ([], [], [])
for i in range(len(ta)):
	if ta[i] == 1:
		p1.append(i + 1)
	elif ta[i] == 2:
		p2.append(i + 1)
	elif ta[i] == 3:
		p3.append(i + 1)
mn = min(len(p1), min(len(p2), len(p3)))
print(mn)
for i in range(mn):
	print(p1[i], p2[i], p3[i])


import sys
n = int(input())
li = [int(i) for i in input().split()]
li1 = []
li2 = []
li3 = []
for i in range(len(li)):
	if li[i] == 1:
		li1.append(i + 1)
	elif li[i] == 2:
		li2.append(i + 1)
	else:
		li3.append(i + 1)
f = len(li1)
s = len(li2)
t = len(li3)
mini = sys.maxsize
if mini > f:
	mini = f
if mini > s:
	mini = s
if mini > t:
	mini = t
if mini == 0:
	print('0')
else:
	print(mini)
	for i in range(mini):
		print(li1[i], li2[i], li3[i])


n = int(input())
kids = list(map(int, input().split()))
prog = []
math = []
pe = []
for i in range(n):
	if kids[i] == 1:
		prog.append(i + 1)
	if kids[i] == 2:
		math.append(i + 1)
	if kids[i] == 3:
		pe.append(i + 1)
teams = min(min(len(prog), len(math)), len(pe))
print(teams)
for i in range(teams):
	print(f'{prog[i]} {math[i]} {pe[i]}')


n = int(input())
t = list(map(int, input().split()))
t1 = []
t2 = []
t3 = []
ct1 = 0
ct2 = 0
ct3 = 0
for i in range(n):
	if t[i] == 1:
		ct1 += 1
		t1.append(i + 1)
	elif t[i] == 2:
		ct2 += 1
		t2.append(i + 1)
	else:
		ct3 += 1
		t3.append(i + 1)
ans = min(ct1, ct2, ct3)
print(ans)
if ans > 0:
	for i in range(ans):
		print(t1[i], t2[i], t3[i])


def solution(a):
	m = dict()
	for i in range(1, 4):
		m[i] = []
	for i in range(len(a)):
		m[a[i]].append(i + 1)
	k = min(len(m[1]), len(m[2]), len(m[3]))
	print(k)
	for i in range(k):
		print(m[1].pop(), m[2].pop(), m[3].pop())
n = int(input())
a = list(map(int, input().split()))
solution(a)


n = int(input())
p = input()
p = p.split()
l = []
l1 = 0
m = []
m2 = 0
q = []
q3 = 0
for i in range(n):
	if p[i] == '1':
		l1 += 1
		l.append(i + 1)
	if p[i] == '2':
		m2 += 1
		m.append(i + 1)
	if p[i] == '3':
		q3 += 1
		q.append(i + 1)
if l1 == 0 or m2 == 0 or q3 == 0:
	print(0)
else:
	w = min(l1, m2, q3)
	print(w)
	for i in range(w):
		print(l[i], m[i], q[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())
a = list(map(int, input().split()))
count1 = count2 = count3 = 0
for i in a:
	if i == 1:
		count1 += 1
	elif i == 2:
		count2 += 1
	else:
		count3 += 1
teams = min(count1, count2, count3)
print(teams)
index1 = []
index2 = []
index3 = []
for j in range(n):
	if a[j] != 0:
		if a[j] == 1:
			a[j] = 0
			index1.append(j + 1)
		elif a[j] == 2:
			a[j] = 0
			index2.append(j + 1)
		elif a[j] == 3:
			a[j] = 0
			index3.append(j + 1)
for i in range(teams):
	print(index1.pop(), index2.pop(), index3.pop())


n = eval(input())
l1 = list(map(eval, input().split()))
if 1 not in l1 or 2 not in l1 or 3 not in l1:
	print('0')
else:
	m = min(l1.count(1), l1.count(2), l1.count(3))
	print(m)
	x = []
	for i in range(len(l1)):
		if l1[i] == 1:
			x.append(i + 1)
	y = []
	for i in range(len(l1)):
		if l1[i] == 2:
			y.append(i + 1)
	z = []
	for i in range(len(l1)):
		if l1[i] == 3:
			z.append(i + 1)
	for i in range(m):
		print(x[i], y[i], z[i])


n = int(input())
t = list(map(int, input().split()))
Total = 0
Team = []
Cek = True
while Cek:
	if 1 in t and 2 in t and (3 in t):
		Team.append([t.index(1) + 1, t.index(2) + 1, t.index(3) + 1])
		t[t.index(1)] = 0
		t[t.index(2)] = 0
		t[t.index(3)] = 0
		Total += 1
	else:
		break
print(Total)
for i in range(Total):
	print(' '.join(map(str, Team[i])))


n = int(input())
a = list(map(int, input().split()))
s = a.count(1)
t = a.count(2)
u = a.count(3)
p = min(s, t, u)
print(p)
for i in range(p):
	l = a.index(1)
	a[l] = 0
	print(l + 1, end=' ')
	l = a.index(2)
	a[l] = 0
	print(l + 1, end=' ')
	l = a.index(3)
	a[l] = 0
	print(l + 1)


m = int(input())
li = list(map(int, input().split(' ')))
print(min(li.count(2), li.count(1), li.count(3)))
x = min(li.count(2), li.count(1), li.count(3))
for j in range(x):
	print([i for (i, n) in enumerate(li) if n == 1][j] + 1, [i for (i, n) in enumerate(li) if n == 2][j] + 1, [i for (i, n) in enumerate(li) if n == 3][j] + 1)


n = int(input())
t = list(map(int, input().split()))
(t1, t2, t3) = ([], [], [])
for a in range(n):
	if t[a] == 1:
		t1.append(a + 1)
	elif t[a] == 2:
		t2.append(a + 1)
	else:
		t3.append(a + 1)
ttotal = min(len(t1), len(t2), len(t3))
print(ttotal)
for b in range(ttotal):
	print(t1[b], t2[b], t3[b])


n = int(input())
math = []
prog = []
phys = []
t = map(int, input().split())
for (i, pupil) in enumerate(t):
	num = i + 1
	if pupil == 1:
		prog.append(num)
	elif pupil == 2:
		math.append(num)
	else:
		phys.append(num)
final = list(zip(math, prog, phys))
print(len(final))
for (m, p, ps) in final:
	print(m, p, ps)


import math
import sys

def ri():
	return input()

def ii():
	return int(input())

def li():
	return input().split()

def mi():
	return list(map(int, input().split()))
n = ii()
t = mi()
p = 0
m = 0
PE = 0
pA = []
mA = []
PEA = []
for i in range(len(t)):
	if t[i] == 1:
		p += 1
		pA.append(i + 1)
	elif t[i] == 2:
		m += 1
		mA.append(i + 1)
	else:
		PE += 1
		PEA.append(i + 1)
w = min(min(p, m), PE)
print(w)
for i in range(w):
	print(pA[i], mA[i], PEA[i])


n = int(input().strip(' '))
s = list(map(int, input().strip(' ').split(' ')))
w = [0, 0, 0]
d = {}
for i in range(len(s)):
	w[s[i] - 1] += 1
	if s[i] not in d:
		d[s[i]] = [i + 1]
	else:
		d[s[i]].append(i + 1)
if min(w) > 0:
	print(min(w))
	c = 0
	while c < min(w):
		for k in d:
			print(d[k][c], end=' ')
		print()
		c += 1
else:
	print(min(w))


n = int(input())
a = [int(i) for i in input().split()]
(p, m, s) = (0, 0, 0)
(ap, am, asp) = ([], [], [])
for i in range(n):
	if a[i] == 1:
		p += 1
		ap.append(i + 1)
	elif a[i] == 2:
		m += 1
		am.append(i + 1)
	elif a[i] == 3:
		s += 1
		asp.append(i + 1)
x = min(p, m, s)
print(x)
for i in range(x):
	print(ap[i], am[i], asp[i])


n = int(input())
a = [[] for i in range(3)]
for (i, x) in enumerate((int(x) for x in input().split())):
	a[x - 1].append(i + 1)
ans = min((len(x) for x in a))
print(ans)
if ans >= 1:
	for i in range(ans):
		print(a[0][i], a[1][i], a[2][i])


n = int(input())
lst = list(map(int, input().split()))
first = []
second = []
third = []
for i in range(len(lst)):
	if lst[i] == 1:
		first.append(i + 1)
	if lst[i] == 2:
		second.append(i + 1)
	if lst[i] == 3:
		third.append(i + 1)
if len(first) < len(second):
	min = len(first)
else:
	min = len(second)
if min > len(third):
	min = len(third)
print(min)
for i in range(min):
	print(first[i], second[i], third[i])


n = int(input())
t = list(map(int, input().split()))
t_1 = []
t_2 = []
t_3 = []
for i in range(len(t)):
	if t[i] == 1:
		t_1.append(i + 1)
	elif t[i] == 2:
		t_2.append(i + 1)
	else:
		t_3.append(i + 1)
a = min(len(t_3), len(t_2), len(t_1))
print(a)
for i in range(a):
	print(t_1[i], t_2[i], t_3[i])


n = int(input())
ss = input().split()
one = []
two = []
three = []
for i in range(n):
	if ss[i] == '1':
		one.append(i + 1)
	elif ss[i] == '2':
		two.append(i + 1)
	else:
		three.append(i + 1)
m = min(len(one), len(two), len(three))
print(m)
for p in range(m):
	print('%d %d %d' % (one[p], two[p], three[p]))


n = int(input())
l = list(input().split())
k1 = l.count('1')
k2 = l.count('2')
k3 = l.count('3')
k = min(k1, k2, k3)
if k == 0:
	print('0')
else:
	s1 = [i + 1 for i in range(n) if l[i] == '1']
	s2 = [i + 1 for i in range(n) if l[i] == '2']
	s3 = [i + 1 for i in range(n) if l[i] == '3']
	print(k)
	for i in range(k):
		print(s1[i], s2[i], s3[i])


n = int(input())
li = list(map(int, input().split()))
a = min(li.count(1), li.count(3), li.count(2))
print(a)
while a:
	(b, c, d) = (li.index(1), li.index(2), li.index(3))
	print(b + 1, c + 1, d + 1)
	li[b] = 0
	li[c] = 0
	li[d] = 0
	a -= 1


n = int(input())
lst = [int(i) for i in input().split()]
one = two = three = 0
for i in lst:
	if i is 1:
		one += 1
	elif i is 2:
		two += 1
	else:
		three += 1
if one > 0 and two > 0 and (three > 0):
	print(min(one, two, three))
	for i in range(min(one, two, three)):
		print('{} {} {}'.format(lst.index(1) + 1, lst.index(2) + 1, lst.index(3) + 1))
		lst[lst.index(1)] = 0
		lst[lst.index(2)] = 0
		lst[lst.index(3)] = 0
else:
	print(0)


n = int(input())
t = [int(x) for x in input().split()]
t1 = t.count(1)
t2 = t.count(2)
t3 = t.count(3)
w = min(t1, t2, t3)
T1 = []
T2 = []
T3 = []
for i in range(n):
	if t[i] == 1:
		T1.append(i + 1)
	elif t[i] == 2:
		T2.append(i + 1)
	else:
		T3.append(i + 1)
print(w)
if w != 0:
	for i in range(w):
		print(T1[i], T2[i], T3[i])


m = int(input())
l = list(map(int, input().rstrip().split()))
c = min(l.count(1), l.count(2), l.count(3))
if c:
	print(c)
	(l1, l2, l3) = ([], [], [])
	for i in range(len(l)):
		if l[i] == 1:
			l1.append(i + 1)
		elif l[i] == 2:
			l2.append(i + 1)
		else:
			l3.append(i + 1)
	for i in range(c):
		print(l1[i], end=' ')
		print(l2[i], end=' ')
		print(l3[i])
else:
	print(c)


k = int(input())
a = list(map(int, input().split()))
b = {1: [], 2: [], 3: []}
for i in range(len(a)):
	b[a[i]].append(i + 1)
c = min(len(b[1]), len(b[2]), len(b[3]))
print(c)
while c > 0:
	print(b[1].pop(), b[2].pop(), b[3].pop())
	c -= 1


n = int(input())
sp = list(map(int, input().split()))
sr = [[], [], []]
if not 1 in sp or not 2 in sp or (not 3 in sp):
	print(0)
else:
	for i in range(n):
		if sp[i] == 1:
			sr[0].append(i + 1)
		elif sp[i] == 2:
			sr[1].append(i + 1)
		elif sp[i] == 3:
			sr[2].append(i + 1)
	pr = min(len(sr[0]), len(sr[1]), len(sr[2]))
	print(pr)
	for i in range(pr):
		print(sr[0][i], sr[1][i], sr[2][i])


n = int(input())
arr = list(map(int, input().strip().split(' ')))
a = arr.count(1)
b = arr.count(2)
c = arr.count(3)
maxi = min(min(a, b), c)
print(maxi)
result = [[], [], []]
for i in range(len(arr)):
	result[arr[i] - 1].append(str(i + 1))
for i in range(maxi):
	print(result[0][i], result[1][i], result[2][i])


n = int(input())
a = list(map(int, input().split()))
c1 = c2 = c3 = 0
i1 = []
i2 = []
i3 = []
for x in range(n):
	if a[x] == 1:
		c1 += 1
		i1.append(x + 1)
	elif a[x] == 2:
		c2 += 1
		i2.append(x + 1)
	else:
		c3 += 1
		i3.append(x + 1)
t = min(c1, c2, c3)
print(t)
for x in range(t):
	print(i1[x], i2[x], i3[x])


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


input_s = int(input())
input_l = input().split(' ')
result_list = [[], [], []]
for (index, l) in enumerate(input_l):
	num_l = int(l)
	result_list[num_l - 1].append(index + 1)
j = min(len(result_list[0]), len(result_list[1]), len(result_list[2]))
print(j)
for i in range(len(result_list[0])):
	if len(result_list[1]) < i + 1 or len(result_list[2]) < i + 1:
		break
	print('{} {} {}'.format(result_list[0][i], result_list[1][i], result_list[2][i]))


n = int(input())
students = input().split()
s = min(students.count('1'), students.count('2'), students.count('3'))
print(s)
for i in range(s):
	one = students.index('1')
	two = students.index('2')
	three = students.index('3')
	students[one] = students[two] = students[three] = 0
	print(one + 1, two + 1, three + 1)


n = int(input())
children = {1: [], 2: [], 3: []}
childrensHabilities = [int(n) for n in input().split()]
for (index, hability) in enumerate(childrensHabilities):
	children[hability].append(index)
numGroups = min(len(children[1]), len(children[2]), len(children[3]))
print(numGroups)
for i in range(numGroups):
	print('%d %d %d' % (children[1][i] + 1, children[2][i] + 1, children[3][i] + 1))


n = int(input())
a = input()
list_n = a.split()
count1 = 0
count2 = 0
count3 = 0
list_c1 = []
list_c2 = []
list_c3 = []
for i in range(len(list_n)):
	if list_n[i] == '1':
		count1 += 1
		list_c1.append(i)
	elif list_n[i] == '2':
		count2 += 1
		list_c2.append(i)
	else:
		count3 += 1
		list_c3.append(i)
w = min(count1, count2, count3)
print(w)
for i in range(w):
	print(str(list_c3[i] + 1) + ' ' + str(list_c2[i] + 1) + ' ' + str(list_c1[i] + 1))


n = int(input())
a = list(map(int, input().rstrip().split()))
x = a.count(1)
y = a.count(2)
z = a.count(3)
b = min(x, y, z)
print(b)
t = 0
while t < b:
	print(a.index(1) + 1, end=' ')
	a[a.index(1)] = 0
	print(a.index(2) + 1, end=' ')
	a[a.index(2)] = 0
	print(a.index(3) + 1, end=' ')
	a[a.index(3)] = 0
	print()
	t += 1


n = int(input())
people = [int(i) for i in input().split()]
a1 = people.count(1)
a2 = people.count(2)
a3 = people.count(3)
team = min(a1, a2, a3)
b1 = []
b2 = []
b3 = []
for i in range(n):
	if people[i] == 1:
		b1.append(i + 1)
	elif people[i] == 2:
		b2.append(i + 1)
	else:
		b3.append(i + 1)
print(team)
for i in range(team):
	print(b1[i], end=' ')
	print(b2[i], end=' ')
	print(b3[i])


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


n = int(input())
A = list(map(str, input().split(' ')))
(m, count, n1, j) = ([], 3, n // 3, 0)
dict = {}
B = set(A)
for i in A:
	if i in dict:
		dict[i] += 1
	else:
		dict[i] = 1
if len(B) == 3:
	print(min(dict.values()))
	while j < len(A):
		try:
			print(A.index('1') + 1, A.index('2') + 1, A.index('3') + 1, end=' ')
			A.insert(A.index('1'), '0')
			A.remove(A[A.index('1')])
			A.insert(A.index('2'), '0')
			A.remove(A[A.index('2')])
			A.insert(A.index('3'), '0')
			A.remove(A[A.index('3')])
			count += 1
		except:
			break
		print()
		j += 1
else:
	print(0)


num_child = int(input())
lst = [i for i in input().split()]
index_lst_one = []
index_lst_two = []
index_lst_three = []
final_lst = []
t1 = 0
t2 = 0
t3 = 0
for i in range(1, len(lst) + 1):
	if lst[i - 1] == '1':
		t1 += 1
		index_lst_one.append(i - 1)
	elif lst[i - 1] == '2':
		t2 += 1
		index_lst_two.append(i - 1)
	else:
		t3 += 1
		index_lst_three.append(i - 1)
max_teams = min(t1, t2, t3)
print(max_teams)
for i in range(max_teams):
	print(index_lst_one[i] + 1, index_lst_two[i] + 1, index_lst_three[i] + 1)


n = int(input())
studs = [x for x in input().split(' ')]
w = min(studs.count('1'), studs.count('2'), studs.count('3'))
if w != 0:
	print(w)
	for x in range(w):
		print('{0} {1} {2}'.format(studs.index('1') + 1, studs.index('2') + 1, studs.index('3') + 1))
		studs[studs.index('1')] = 0
		studs[studs.index('2')] = 0
		studs[studs.index('3')] = 0
else:
	print(w)


input()
a = [int(x) for x in input().split()]
x = a.count(1)
y = a.count(2)
z = a.count(3)
n = min(x, y, z)
l = len(a)
print(n)
m = -1
p = -1
o = -1
for i in range(n):
	while 1:
		m += 1
		if a[m] == 1:
			print(m + 1, end=' ')
			break
	while 1:
		p += 1
		if a[p] == 2:
			print(p + 1, end=' ')
			break
	while 1:
		o += 1
		if a[o] == 3:
			print(o + 1)
			break


n = int(input())
t = [int(x) for x in input().split()]
amount = min(t.count(1), t.count(2), t.count(3))
print(amount)
l1 = []
l2 = []
l3 = []
for i in range(n):
	if t[i] == 1 and len(l1) < amount:
		l1.append(i + 1)
	elif t[i] == 2 and len(l2) < amount:
		l2.append(i + 1)
	elif t[i] == 3 and len(l3) < amount:
		l3.append(i + 1)
	if len(l1) == len(l2) == len(l3) == amount:
		break
for j in range(amount):
	print(l1[j], l2[j], l3[j])


n = int(input())
l = [[], [], []]
for (i, put) in enumerate(input().split(), 1):
	l[int(put) - 1] += [i]
m = min(map(len, l))
print(m)
for i in zip(*l):
	print(*i)


n = int(input())
talent = [[], [], [], []]
line = [int(i) for i in input().split()]
for i in range(n):
	talent[line[i]].append(i + 1)
team = min(len(talent[1]), len(talent[2]), len(talent[3]))
print(team)
for i in range(team):
	print('{} {} {}'.format(talent[1][i], talent[2][i], talent[3][i]))


n = int(input())
t = list(map(int, input().split()))
s = sorted(enumerate(t, 1), key=lambda x: x[1])
ones = [(a, b) for (a, b) in s if b == 1]
twoes = [(a, b) for (a, b) in s if b == 2]
threes = [(a, b) for (a, b) in s if b == 3]
count = [len(ones), len(twoes), len(threes)]
print(min(count))
for i in range(min(count)):
	print(ones[i][0], twoes[i][0], threes[i][0])


n = int(input().strip())
(o, tw, th) = (0, 0, 0)
di = {1: [], 2: [], 3: []}
arr = [int(__) for __ in input().strip().split()]
for (i, x) in enumerate(arr):
	if x == 1:
		o += 1
		di[1].append(i + 1)
	elif x == 2:
		tw += 1
		di[2].append(i + 1)
	else:
		th += 1
		di[3].append(i + 1)
ts = min(o, tw, th)
if ts == 0:
	print(0)
else:
	print(ts)
	for i in range(ts):
		print(di[1][i], di[2][i], di[3][i])


n = int(input())
l = list(map(int, input().split()))
one = []
two = []
thr = []
for i in enumerate(l, start=1):
	if i[1] == 1:
		one.append(i[0])
	elif i[1] == 2:
		two.append(i[0])
	elif i[1] == 3:
		thr.append(i[0])
if len(one) == 0 or len(two) == 0 or len(thr) == 0:
	print(0)
else:
	print(min(len(one), len(two), len(thr)))
	itr = min(len(one), len(two), len(thr))
	ans = []
	while itr > 0:
		ans.append([thr.pop(), two.pop(), one.pop()])
		itr -= 1
	for i in ans:
		print(*i)


c = input()
a = input()
b = [int(i) for i in a.split(' ')]
dico = {1: 0, 2: 0, 3: 0}
for i in b:
	for (k, v) in dico.items():
		if i == k:
			dico[k] += 1
team = min(dico.values())
un = []
deux = []
trois = []
for (n, i) in enumerate(b):
	if i == 1:
		un.append(n)
	if i == 2:
		deux.append(n)
	if i == 3:
		trois.append(n)
print(team)
for i in range(team):
	print('{} {} {}'.format(un[i] + 1, deux[i] + 1, trois[i] + 1))


n = int(input())
x = [int(x) for x in input().split()]
pro = []
math = []
sports = []
for i in range(n):
	if x[i] == 1:
		pro.append(i + 1)
	elif x[i] == 2:
		math.append(i + 1)
	else:
		sports.append(i + 1)
team = min(len(pro), len(math), len(sports))
print(team)
for i in range(team):
	print(pro[i], math[i], sports[i])


n = int(input())
w = list(map(int, input().split()))
a = min(w.count(1), w.count(2), w.count(3))
print(a)
i = 0
j = 1
while a > 0:
	if j == 1:
		print(w.index(1) + 1, end=' ')
		w[w.index(1)] = 0
		j += 1
	if j == 2:
		print(w.index(2) + 1, end=' ')
		w[w.index(2)] = 0
		j += 1
	if j == 3:
		print(w.index(3) + 1, end='\n')
		w[w.index(3)] = 0
		j = 1
	a -= 1


n = int(input())
s = list(map(int, input().split(' ')))
s1 = []
s2 = []
s3 = []
for i in range(len(s)):
	if s[i] == 1:
		s1.append(i + 1)
	elif s[i] == 2:
		s2.append(i + 1)
	else:
		s3.append(i + 1)
m = min(len(s1), len(s2), len(s3))
print(m)
for j in range(m):
	print(str(s1[j]) + ' ' + str(s2[j]) + ' ' + str(s3[j]))


import sys
inf = float('inf')
(mod, MOD) = (1000000007, 998244353)
from math import ceil, floor, log, sqrt, factorial

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
n = int(input())
Arr = get_array()
mydict = {1: [], 2: [], 3: []}
for i in range(n):
	mydict[Arr[i]].append(i + 1)
ans = min(len(mydict[1]), min(len(mydict[2]), len(mydict[3])))
T = ans
result = []
while T:
	array = []
	array.append(mydict[1].pop())
	array.append(mydict[2].pop())
	array.append(mydict[3].pop())
	result.append(array)
	T -= 1
print(ans)
for i in result:
	print(*i)


n = int(input())
my_list = list(map(int, input().split()))
one = 0
two = 0
three = 0
for i in my_list:
	if i == 1:
		one += 1
	elif i == 2:
		two += 1
	else:
		three += 1
print(min(one, two, three))
if min(one, two, three) != 0:
	set_of_indices = set()
	for j in range(min(one, two, three)):
		one_added = False
		two_added = False
		three_added = False
		answer = []
		for k in range(n):
			if my_list[k] == 1 and (not one_added) and (k not in set_of_indices):
				answer.append(k)
				one_added = True
				set_of_indices.add(k)
			if my_list[k] == 2 and (not two_added) and (k not in set_of_indices):
				answer.append(k)
				two_added = True
				set_of_indices.add(k)
			if my_list[k] == 3 and (not three_added) and (k not in set_of_indices):
				answer.append(k)
				three_added = True
				set_of_indices.add(k)
		print(*[x + 1 for x in answer])


n = int(input())
l = list(map(int, input().split()))
cpy = l[:]
c1 = set()
c2 = set()
c3 = set()
for j in range(len(l)):
	if l[j] == 1:
		c1.add(j + 1)
	if l[j] == 2:
		c2.add(j + 1)
	if l[j] == 3:
		c3.add(j + 1)
samp = []
c1 = list(c1)
c2 = list(c2)
c3 = list(c3)
k = min(len(c1), len(c2), len(c3))
for i in range(k):
	samp.append([c1[i], c2[i], c3[i]])
if len(samp) == 0:
	print(0)
else:
	print(len(samp))
	for i in samp:
		print(*i)


n = int(input())
l = list(map(int, input().split()))
(a1, a2, a3) = (0, 0, 0)
for i in l:
	if i == 1:
		a1 += 1
	elif i == 2:
		a2 += 1
	else:
		a3 += 1
g = min(a1, a2, a3)
if g == 0:
	print(0)
else:
	print(g)
	(b1, b2, b3) = ([], [], [])
	for i in range(n):
		if l[i] == 1:
			b1 += [i]
		elif l[i] == 2:
			b2 += [i]
		else:
			b3 += [i]
	for i in range(g):
		print(b1[i] + 1, b2[i] + 1, b3[i] + 1)


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


def fun(n, li):
	dic = {1: [0, []], 2: [0, []], 3: [0, []]}
	for i in range(len(li)):
		dic[li[i]][0] += 1
		dic[li[i]][1].append(i)
	mi = min(dic[1][0], dic[2][0], dic[3][0])
	print(mi)
	for i in range(mi):
		print(dic[1][1].pop() + 1, dic[2][1].pop() + 1, dic[3][1].pop() + 1)
n = int(input())
li = list(map(lambda x: int(x), input().split()))
fun(n, li)


input()
st = [int(x) for x in input().split()]
n = min(st.count(1), st.count(2), st.count(3))
print(n)
if n > 0:
	for i in range(n):
		print(st.index(1) + 1, end=' ')
		print(st.index(2) + 1, end=' ')
		print(st.index(3) + 1)
		st[st.index(1)] = st[st.index(2)] = st[st.index(3)] = 0


n = int(input(''))
t = [int(x) for x in input('').split()]
pg = []
mt = []
pe = []
w = 0
for i in range(n):
	if t[i] == 1:
		pg.append(i + 1)
	elif t[i] == 2:
		mt.append(i + 1)
	elif t[i] == 3:
		pe.append(i + 1)
w = min(len(pg), min(len(mt), len(pe)))
print(w)
for i in range(w):
	print(pg[i], mt[i], pe[i])


from sys import stdin, stdout
import math
from fractions import gcd

def sin():
	return stdin.readline().rstrip()

def listInput():
	return list(map(int, sin().split()))

def printBS(li):
	if not li:
		return
	for i in range(len(li) - 1):
		stdout.write('%d ' % li[i])
	stdout.write('%d\n' % li[-1])
n = int(sin())
li = listInput()
a = []
b = []
c = []
for i in range(n):
	if li[i] == 1:
		a.append(i + 1)
	elif li[i] == 2:
		b.append(i + 1)
	else:
		c.append(i + 1)
m = min(len(a), len(b), len(c))
print(m)
for i in range(m):
	print(a[i], b[i], c[i])


n = int(input())
t = [int(x) for x in input().split()]
t1 = list()
t2 = list()
t3 = list()
idx = 0
for e in t:
	idx = idx + 1
	if e == 1:
		t1.append(idx)
	elif e == 2:
		t2.append(idx)
	else:
		t3.append(idx)
W = min(len(t1), min(len(t2), len(t3)))
print(W)
for w in range(W):
	print(t1[w], t2[w], t3[w])


n = int(input())
s = list(map(int, input().split()))
cnt1 = []
cnt2 = []
cnt3 = []
for i in range(len(s)):
	if s[i] == 1:
		cnt1.append(i + 1)
	elif s[i] == 2:
		cnt2.append(i + 1)
	elif s[i] == 3:
		cnt3.append(i + 1)
print(min(len(cnt1), len(cnt2), len(cnt3)))
for i in range(min(len(cnt1), len(cnt2), len(cnt3))):
	print(cnt1[i], cnt2[i], cnt3[i])


a = int(input())
b = [int(s) for s in input().split()]
k = min(b.count(1), b.count(2), b.count(3))
if k != 0:
	print(k)
	l1 = []
	l2 = []
	l3 = []
	for j in range(len(b)):
		if b[j] == 1:
			l1.append(j + 1)
		elif b[j] == 2:
			l2.append(j + 1)
		else:
			l3.append(j + 1)
	for j in range(k):
		print(l1[j], l2[j], l3[j])
else:
	print(k)


n = int(input())
l = list(map(int, input().split(' ')))
r = list()
a = l.count(1)
b = l.count(2)
c = l.count(3)
t = min(a, b, c)
count1 = -1
count2 = -1
count3 = -1
for i in range(0, t):
	r.append([0, 0, 0])
for i in range(0, n):
	if l[i] == 1 and count1 < t - 1:
		count1 = count1 + 1
		r[count1][0] = i + 1
	elif l[i] == 2 and count2 < t - 1:
		count2 = count2 + 1
		r[count2][1] = i + 1
	elif l[i] == 3 and count3 < t - 1:
		count3 = count3 + 1
		r[count3][2] = i + 1
	if count1 == t - 1 and count2 == t - 1 and (count3 == t - 1):
		break
if t != 0:
	print(t)
	for i in r:
		print(*i)
else:
	print('0')


n = int(input())
a = [int(x) for x in input().split()]
pr = []
math = []
pe = []
for i in range(n):
	if a[i] == 1:
		pr.append(i + 1)
	if a[i] == 2:
		math.append(i + 1)
	if a[i] == 3:
		pe.append(i + 1)
print(min(len(pr), len(math), len(pe)))
for i in range(min(len(pr), len(math), len(pe))):
	print(pr[i], math[i], pe[i])


n = int(input())
daf = list(map(int, input().split()))
m = [i for i in range(n) if daf[i] == 1]
p = [i for i in range(n) if daf[i] == 2]
s = [i for i in range(n) if daf[i] == 3]
x = min(len(m), len(p), len(s))
if x == 0:
	print(0)
else:
	print(x)
	for i in range(x):
		print(m[i] + 1, p[i] + 1, s[i] + 1)


n = int(input())
t = list(map(int, input().split()))
t1 = t.count(1)
t2 = t.count(2)
t3 = t.count(3)
ans = min(t1, t2, t3)
if ans == 0:
	print(0)
	exit()
print(ans)
while ans != 0:
	teaml = []
	for i in range(1, 4):
		index = t.index(i)
		teaml.append(index + 1)
		t[index] = 0
	print(*teaml, sep=' ')
	ans -= 1


n = int(input())
a = list(map(int, input().split()))
(a1, a2, a3) = ([], [], [])
for i in range(len(a)):
	if a[i] == 1:
		a1.append(i + 1)
	elif a[i] == 2:
		a2.append(i + 1)
	else:
		a3.append(i + 1)
x = min(len(a1), len(a2), len(a3))
print(x)
for i in range(x):
	print(a1[i], a2[i], a3[i], sep=' ')


ky = int(input())
sy = [int(i) for i in input().split()]
kk = min(sy.count(1), sy.count(2), sy.count(3))
print(kk)
ip = 0
im = 0
iq = 0
for i in range(kk):
	ip = ip + sy[ip:].index(1) + 1
	im = im + sy[im:].index(2) + 1
	iq = iq + sy[iq:].index(3) + 1
	print(ip, im, iq)


def solve(n, a):
	(pr, m, pe) = ([], [], [])
	for (i, v) in enumerate(a):
		if v == 1:
			pr.append(i + 1)
		elif v == 2:
			m.append(i + 1)
		else:
			pe.append(i + 1)
	t = min(len(m), len(pr), len(pe))
	print(t)
	for i in range(t):
		print(pr[i], pe[i], m[i])

def main():
	n = int(input())
	a = list(map(int, input().split()))
	solve(n, a)
main()


input()
Students = list(map(int, input().split()))
Programming = list()
PE = list()
Math = list()
for i in range(Students.__len__()):
	if Students[i] == 1:
		Programming.append(i + 1)
	elif Students[i] == 2:
		Math.append(i + 1)
	else:
		PE.append(i + 1)
MIN = min(Programming.__len__(), PE.__len__(), Math.__len__())
if MIN == 0:
	print(str(0))
else:
	print(MIN)
	for i in range(MIN):
		print(Programming[i], PE[i], Math[i])


n = int(input())
l = [int(x) for x in input().split()]
(l1, l2, l3) = ([], [], [])
for i in range(n):
	if l[i] == 1:
		l1.append(i + 1)
	elif l[i] == 2:
		l2.append(i + 1)
	else:
		l3.append(i + 1)
a = min(len(l1), len(l2), len(l3))
print(a)
if a != 0:
	for j in range(a):
		print(l1[j], l2[j], l3[j])


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())
x = list(map(int, input().split()))
if x.count(1) == 0 or x.count(2) == 0 or x.count(3) == 0:
	print(0)
else:
	teams = 0
	y = []
	while x.count(1) != 0 and x.count(2) != 0 and (x.count(3) != 0):
		y.append(x.index(1) + 1)
		x[x.index(1)] = 0
		y.append(x.index(2) + 1)
		x[x.index(2)] = 0
		y.append(x.index(3) + 1)
		x[x.index(3)] = 0
		teams += 1
	print(teams)
	i = 0
	while i < len(y) - 2:
		print(y[i], y[i + 1], y[i + 2])
		i += 3


def main():
	n = int(input())
	a = list(map(int, input().split()))
	mi = []
	for i in range(1, 4):
		mi.append(a.count(i))
	w = min(mi)
	if w == 0:
		print(0)
	else:
		print(w)
		while w:
			i1 = a.index(1)
			i2 = a.index(2)
			i3 = a.index(3)
			print(i1 + 1, i2 + 1, i3 + 1, sep=' ')
			(a[i1], a[i2], a[i3]) = (0, 0, 0)
			w = w - 1
main()


n = int(input())
a = list(map(int, input().split()))
b = min(a.count(1), a.count(2), a.count(3))
print(b)
if b > 0:
	c = [[] for j in range(3)]
	for i in range(n):
		c[a[i] - 1].append(i + 1)
	for i in range(b):
		print(c[0][i], c[1][i], c[2][i])


n = int(input())
lst = [int(i) for i in input().split()]
teams = [[] for i in range(3)]
for i in range(n):
	teams[lst[i] - 1].append(i + 1)
print(min(len(teams[0]), len(teams[1]), len(teams[2])))
while min(len(teams[0]), len(teams[1]), len(teams[2])) > 0:
	print(teams[0].pop(), teams[1].pop(), teams[2].pop())


num_children = int(input())
list_children_skills = list(map(int, input().split()))
dict_skills_children = dict()
dict_skills_children[1] = list()
dict_skills_children[2] = list()
dict_skills_children[3] = list()
child = 1
for each in list_children_skills:
	dict_skills_children[each].append(child)
	child += 1
skill_1 = len(dict_skills_children[1])
skill_2 = len(dict_skills_children[2])
skill_3 = len(dict_skills_children[3])
num_teams = min([skill_1, skill_2, skill_3])
print(num_teams)
if num_teams != 0:
	for team in range(num_teams):
		print(dict_skills_children[1][team], dict_skills_children[2][team], dict_skills_children[3][team])


n = int(input())
a = [int(i) for i in input().split()]
s = min(a.count(1), a.count(2), a.count(3))
t1 = 0
t2 = 0
t3 = 0
print(s)
for i in range(s):
	t1 = a[t1:].index(1) + t1 + 1
	t2 = a[t2:].index(2) + t2 + 1
	t3 = a[t3:].index(3) + t3 + 1
	print(t1, t2, t3)


n = int(input())
stud = list(map(int, input().split()))
d1 = {1: [], 2: [], 3: []}
d2 = {1: 0, 2: 0, 3: 0}
for i in range(n):
	d1[stud[i]] = d1[stud[i]] + [i + 1]
	d2[stud[i]] += 1
k = d2[min(d2, key=d2.get)]
print(k)
for i in range(k):
	print(' '.join((str(d1[x][i]) for x in d1)))


n = int(input())
s = input().split(' ')
a = []
c1 = s.count('1')
c2 = s.count('2')
c3 = s.count('3')
print(min([c1, c2, c3]))
for i in range(min([c1, c2, c3])):
	b = []
	for j in range(n):
		if s[j] == '1':
			s[j] = '-1'
			b.append(j + 1)
			break
	for j in range(n):
		if s[j] == '2':
			s[j] = '-1'
			b.append(j + 1)
			break
	for j in range(n):
		if s[j] == '3':
			s[j] = '-1'
			b.append(j + 1)
			break
	print(' '.join((str(x) for x in b)))


n = int(input())
a = list(map(int, input().split()))
matan = []
coder = []
sportic = []
for i in range(n):
	if a[i] == 1:
		coder.append(i + 1)
	elif a[i] == 2:
		matan.append(i + 1)
	else:
		sportic.append(i + 1)
minlen = min(len(coder), len(matan), len(sportic))
if minlen == 0:
	print('0')
else:
	print(minlen)
	for i in range(minlen):
		print(coder[i], matan[i], sportic[i])


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

def counto(a):
	c1 = 0
	c2 = 0
	c3 = 0
	for i in range(len(a)):
		if a[i] == 1:
			c1 += 1
		elif a[i] == 2:
			c2 += 1
		else:
			c3 += 1
	return min(c1, c2, c3)
minc = counto(a)
t1 = 0
t2 = 0
t3 = 0
result = [minc * [] for i in range(minc)]
for i in range(len(a)):
	if a[i] == 1:
		if t1 < minc:
			result[t1].append(i + 1)
			t1 += 1
	elif a[i] == 2:
		if t2 < minc:
			result[t2].append(i + 1)
			t2 += 1
	elif t3 < minc:
		result[t3].append(i + 1)
		t3 += 1
printed = True
if len(result) == 0:
	print(0)
else:
	for i in range(len(result)):
		if printed == True:
			n = len(result)
			print(n)
			printed = False
		print(' '.join(map(str, result[i])))


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
n = inp()
li = inlt()
p = li.count(1)
m = li.count(2)
f = li.count(3)
w = min(p, m, f)
print(w)
a = []
b = []
c = []
for i in range(n):
	if li[i] == 1:
		a.append(i + 1)
	elif li[i] == 2:
		b.append(i + 1)
	elif li[i] == 3:
		c.append(i + 1)
for i in range(w):
	print(a[i], b[i], c[i])


n = int(input())
arr = [int(i) for i in input().split()]
d = {1: [], 2: [], 3: []}
for (i, j) in enumerate(arr):
	d[j].append(i + 1)
m = min(min(len(d[1]), len(d[2])), len(d[3]))
print(m)
for i in range(m):
	print(d[1][i], d[2][i], d[3][i])


n = int(input())
l = list(map(int, input().split()))
d1 = {1: 0, 2: 0, 3: 0}
for i in l:
	d1[i] += 1
t = min(d1.values())
if t == 0:
	print(0)
else:
	d2 = {1: [], 2: [], 3: []}
	for i in range(len(l)):
		d2[l[i]].append(i + 1)
	print(t)
	c = 0
	while c < t:
		for i in d2:
			print(d2[i][c], end=' ')
		c += 1
		print()


n = int(input())
t = [int(i) for i in input().split()]
freq = [0, 0, 0]
for i in range(n):
	freq[t[i] - 1] += 1
if not freq[0] or not freq[1] or (not freq[2]):
	print(0)
else:
	l = min(freq)
	print(l)
	triple = [[0, 0, 0] for i in range(l)]
	pos = [0, 0, 0]
	for i in range(n):
		if pos[t[i] - 1] < l:
			triple[pos[t[i] - 1]][t[i] - 1] = i + 1
			pos[t[i] - 1] += 1
		if pos[0] >= l and pos[1] >= l and (pos[2] >= l):
			break
	for i in range(l):
		print(triple[i][0], triple[i][1], triple[i][2])


__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)


n = int(input())
t = list(map(int, input().split()))
x = {}
oneCnt = 0
twoCnt = 0
threeCnt = 0
oneIdx = []
twoIdx = []
threeIdx = []
if len(set(t)) < 3:
	print('0')
else:
	for i in range(n):
		if t[i] == 1:
			oneCnt += 1
			oneIdx.append(i + 1)
		if t[i] == 2:
			twoCnt += 1
			twoIdx.append(i + 1)
		if t[i] == 3:
			threeCnt += 1
			threeIdx.append(i + 1)
	w = min(min(oneCnt, twoCnt), threeCnt)
	print(w)
	for x in range(w):
		print(str(oneIdx[x]) + ' ' + str(twoIdx[x]) + ' ' + str(threeIdx[x]))


x = int(input())
y = list(map(int, input().split()))
z = min(y.count(1), y.count(2), y.count(3))
print(z)
for i in range(z):
	k = 1
	if k == 1:
		print(y.index(k) + 1, end=' ')
		y[y.index(k)] = 0
		k += 1
	if k == 2:
		print(y.index(k) + 1, end=' ')
		y[y.index(k)] = 0
		k += 1
	if k == 3:
		print(y.index(k) + 1, end='\n')
		y[y.index(k)] = 0


import sys
n = int(input())
l = list(map(int, input().split()))
p = min(l.count(1), l.count(2), l.count(3))
if p == 0:
	print(0)
	sys.exit(0)
print(p)
while p != 0:
	a = l.index(1)
	b = l.index(2)
	c = l.index(3)
	print(a + 1, b + 1, c + 1)
	l[a] = l[b] = l[c] = 0
	p -= 1


n = int(input())
lis = list(map(int, input().split()))
dic1 = {1: 0, 2: 0, 3: 0}
dic = {1: [], 2: [], 3: []}
result = [[0, 0, 0]]
base = 0
for i in range(n):
	t = lis[i]
	dic[t].append(i + 1)
	dic1[t] += 1
mi = min(dic1.values())
print(mi)
for i in range(mi):
	print(dic[1][i], dic[2][i], dic[3][i])


n = int(input())
st = [int(x) for x in input().split(' ')]
a = st.count(1)
b = st.count(2)
c = st.count(3)
if a == 0 or b == 0 or c == 0:
	print(0)
else:
	m = min(a, b, c)
	v = m
	print(m)
	if a == m:
		m = 1
		m1 = 2
		m2 = 3
	elif b == m:
		m = 2
		m1 = 1
		m2 = 3
	else:
		m = 3
		m1 = 1
		m2 = 2
	cnt = 0
	for i in range(len(st)):
		if st[i] == m:
			cnt += 1
			print(i + 1, st.index(m1) + 1, st.index(m2) + 1)
			st[st.index(m1)] = 0
			st[st.index(m2)] = 0
		if cnt == v:
			break


n = input()
inp = input().split()
lis = list(map(int, inp))
t1 = []
t2 = []
t3 = []
for i in range(len(lis)):
	if lis[i] == 1:
		t1.append(i + 1)
	elif lis[i] == 2:
		t2.append(i + 1)
	else:
		t3.append(i + 1)
n = min(len(t1), len(t2), len(t3))
print(n)
if n != 0:
	for i in range(n):
		print(t1[i], t2[i], t3[i])


n = int(input())
a = list(map(int, input().split()))
from collections import defaultdict
d = defaultdict(list)
for i in range(0, len(a)):
	d[a[i]].append(i)
mn = min(len(d[1]), len(d[2]), len(d[3]))
if mn == 0:
	print(mn)
else:
	print(mn)
	for i in range(0, mn):
		print(d[1][i] + 1, d[2][i] + 1, d[3][i] + 1)


n = int(input())
s = list(map(int, input().split()))
print(min([s.count(1), s.count(2), s.count(3)]))
while all((x in s for x in [1, 2, 3])):
	print(s.index(1) + 1, s.index(2) + 1, s.index(3) + 1)
	for y in range(1, 4):
		s[s.index(y)] = '.'


n = int(input())
a = input().split(' ')
a = [int(i) for i in a]
total_teams = n // 3
result = []
is_empty = True
for i in range(n):
	w = []
	if 1 in a:
		index = a.index(1)
		w.append(index)
		a[index] = 0
	if 2 in a:
		index = a.index(2)
		w.append(index)
		a[index] = 0
	if 3 in a:
		index = a.index(3)
		w.append(index)
		a[index] = 0
		is_empty = False
	if len(w) == 3:
		result.append(w)
len_result = len(result)
print(len_result)
if len_result > 0:
	[print(f'{i[0] + 1} {i[1] + 1} {i[2] + 1}') for i in result]


N = int(input())
t_data = input().split()
if t_data.count('1') == 0 or t_data.count('2') == 0 or t_data.count('3') == 0:
	print('0')
	exit
else:
	t1 = [(i + 1, t_data[i]) for i in range(N) if t_data[i] == '1']
	t2 = [(i + 1, t_data[i]) for i in range(N) if t_data[i] == '2']
	t3 = [(i + 1, t_data[i]) for i in range(N) if t_data[i] == '3']
	teams = []
	team_counter = 0
	while True:
		if len(t1) - 1 < team_counter or len(t2) - 1 < team_counter or len(t3) - 1 < team_counter:
			break
		teams.append([t1[team_counter][0], t2[team_counter][0], t3[team_counter][0]])
		team_counter += 1
	print(team_counter)
	print('\n'.join((' '.join(map(str, line)) for line in teams)))


n = int(input())
t = [i for i in input().split()]
team = [t.count(str(i)) for i in range(1, 4)]
print(min(team))
t = ''.join(t)
for i in range(min(team)):
	print(t.index('1') + 1, t.index('2') + 1, t.index('3') + 1)
	t = t.replace('1', ' ', 1)
	t = t.replace('2', ' ', 1)
	t = t.replace('3', ' ', 1)


t = int(input())
a = list(map(int, input().split()))
l1 = []
l2 = []
l3 = []
for i in range(t):
	if a[i] == 1:
		l1.append(i + 1)
	elif a[i] == 2:
		l2.append(i + 1)
	elif a[i] == 3:
		l3.append(i + 1)
ans = min(len(l1), len(l2), len(l3))
print(ans)
for i in range(ans):
	print(l1[i], l2[i], l3[i])


n = int(input())
nums = list(map(int, input().split()))
one = []
two = []
three = []
for i in range(n):
	if nums[i] == 1:
		one.append(i)
	if nums[i] == 2:
		two.append(i)
	if nums[i] == 3:
		three.append(i)
if len(one) == 0 or len(two) == 0 or len(three) == 0:
	print(0)
else:
	mini = min(len(one), len(two), len(three))
	print(mini)
	for i in range(mini):
		print(one[i] + 1, two[i] + 1, three[i] + 1)


n = int(input())
L = [int(x) for x in input().split()]
ct = [0, 0, 0, 0]
clist = [[], [], [], []]
for x in range(n):
	ct[L[x]] += 1
	clist[L[x]].append(x + 1)
ans = min(ct[1:])
print(ans)
for i in range(ans):
	M = [clist[j][i] for j in range(1, 4)]
	for x in M:
		print(x, end=' ')
	print('')


def main():
	mp = {}
	v = []
	n = int(input())
	v = input()
	v = v.split(' ')
	for i in range(0, n):
		v[i] = int(v[i])
		if v[i] not in mp:
			mp[v[i]] = [i + 1]
		else:
			mp[v[i]].append(i + 1)
	if 1 not in mp or 2 not in mp or 3 not in mp:
		print(0)
		return
	rez = min(len(mp[1]), len(mp[2]))
	rez = min(rez, len(mp[3]))
	print(rez)
	for i in range(0, rez):
		print(mp[1][i], ' ', mp[2][i], ' ', mp[3][i])
main()


from collections import Counter
n = int(input())
t = list(map(int, input().split()))
if 1 in t and 2 in t and (3 in t):
	teams = min(Counter(t).values())
	print(teams)
	one_ind = []
	two_ind = []
	three_ind = []
	for (i, num) in enumerate(t):
		if num == 1:
			one_ind.append(i + 1)
		elif num == 2:
			two_ind.append(i + 1)
		else:
			three_ind.append(i + 1)
	z = list(zip(one_ind, two_ind, three_ind))
	for i in range(teams):
		print(*z[i])
else:
	print(0)


n = int(input())
numbers = list(map(int, input().split()))
programing = []
math = []
pe = []
for i in range(n):
	if numbers[i] == 1:
		programing.append(i + 1)
	elif numbers[i] == 2:
		math.append(i + 1)
	else:
		pe.append(i + 1)
s = min(len(programing), len(math), len(pe))
print(s)
for i in range(s):
	print(programing[i], math[i], pe[i])


string = input()
k = list(map(int, input().split()))
dic = {1: [], 2: [], 3: []}
for i in range(len(k)):
	dic[k[i]].append(i)
mlen = 10000000.0
for i in dic:
	if len(dic[i]) <= mlen:
		mlen = len(dic[i])
print(mlen)
if mlen > 0:
	for i in range(mlen):
		for d in dic:
			print(dic[d][i] + 1, end=' ')
		print()


n = int(input())
lst = input().split()
count = min(lst.count('1'), lst.count('2'), lst.count('3'))
print(count)
teams = [[] for i in range(3)]
for i in range(n):
	if lst[i] == '1':
		teams[0].append(i + 1)
	elif lst[i] == '2':
		teams[1].append(i + 1)
	else:
		teams[2].append(i + 1)
j = 0
while count != 0:
	print(teams[0][j], teams[1][j], teams[2][j])
	j = j + 1
	count = count - 1


m = input()
g = input().split()
k = min(g.count('1'), g.count('2'), g.count('3'))
r1 = [i + 1 for (i, j) in enumerate(g) if j == '1']
r2 = [i + 1 for (i, j) in enumerate(g) if j == '2']
r3 = [i + 1 for (i, j) in enumerate(g) if j == '3']
print(k)
for i in range(k):
	print(r1[i], r2[i], r3[i])


a = []
b = []
c = []
n = int(input())
s = input().split(' ')
for i in range(n):
	if s[i] == '1':
		a.append(i + 1)
	if s[i] == '2':
		b.append(i + 1)
	if s[i] == '3':
		c.append(i + 1)
kek = min(len(a), len(b), len(c))
print(kek)
for i in range(kek):
	print(a[i], b[i], c[i])


n = int(input())
t = list(input().split())
a = [0]
b = [0]
c = [0]
for (i, el) in enumerate(t):
	if el == '1':
		a.append(i + 1)
	elif el == '2':
		b.append(i + 1)
	elif el == '3':
		c.append(i + 1)
ans = min(len(a), len(b), len(c)) - 1
print(ans)
if ans >= 1:
	for i in range(1, ans + 1):
		print(a[i], b[i], c[i])


n = int(input())
t = list(map(int, input().split()))
o = []
tw = []
th = []
for i in range(n):
	if t[i] == 1:
		o.append(i + 1)
	elif t[i] == 2:
		tw.append(i + 1)
	else:
		th.append(i + 1)
print(min(len(o), len(tw), len(th)))
for j in range(min(len(o), len(tw), len(th))):
	print(o[j], tw[j], th[j])


n = int(input())
t = list(map(int, input().split()))
count = 0
s3 = []
s2 = []
s1 = []
for i in range(n):
	if t[i] % 3 == 0:
		s3.append(i + 1)
	if t[i] % 3 == 2:
		s2.append(i + 1)
	if t[i] % 3 == 1:
		s1.append(i + 1)
count = min(len(s3), len(s2), len(s1))
print(count)
for i in range(count):
	print(s1[i], s2[i], s3[i])


n = int(input())
t = list(map(int, input().split()))
count1 = 0
count2 = 0
count3 = 0
lst1 = []
lst2 = []
lst3 = []
for i in range(n):
	if t[i] == 1:
		count1 += 1
		lst1.append(i + 1)
	elif t[i] == 2:
		count2 += 1
		lst2.append(i + 1)
	else:
		count3 += 1
		lst3.append(i + 1)
mint = min(count1, count2, count3)
print(mint)
for i in range(mint):
	print(lst1[i], lst2[i], lst3[i])


input()
li = list(map(int, input().split()))
ans = 0
ans_li = []
for i in range(len(li) // 3):
	try:
		l = [str(li.index(1) + 1), str(li.index(2) + 1), str(li.index(3) + 1)]
		ans_li.append(l)
		li[li.index(1)] = 0
		li[li.index(2)] = 0
		li[li.index(3)] = 0
		ans += 1
	except:
		break
print(ans)
for j in ans_li:
	print(' '.join(j))


n = int(input())
skills = [int(c) for c in input().split()]
a = [[i + 1 for i in range(n) if skills[i] == j] for j in range(1, 4)]
teams = list(zip(*a))
print(len(teams))
for t in teams:
	print(*t)


n = int(input())
l = [int(i) for i in input().split()]
one = []
two = []
three = []
for i in range(0, n):
	if l[i] == 1:
		one.append(i + 1)
	elif l[i] == 2:
		two.append(i + 1)
	else:
		three.append(i + 1)
size = min(len(one), len(two), len(three))
print(size)
for i in range(0, size):
	print(str(one[i]) + ' ' + str(two[i]) + ' ' + str(three[i]))


n = int(input())
x = list(map(int, input().split()))
o = x.count(1)
t = x.count(2)
thr = x.count(3)
minn = min(o, t, thr)
print(minn)
for i in range(minn):
	o = x.index(1)
	x.insert(o, -1)
	x.remove(1)
	t = x.index(2)
	x.insert(t, -1)
	x.remove(2)
	th = x.index(3)
	x.insert(th, -1)
	x.remove(3)
	print(o + 1, t + 1, th + 1)


from _collections import defaultdict
input()
l = list(map(int, input().split()))
d = {}
for i in range(len(l)):
	k = l[i]
	if k in d.keys():
		d[k].append(i + 1)
	else:
		d[k] = [i + 1]
flag = False
if 1 in d.keys():
	if 2 in d.keys():
		if 3 in d.keys():
			if len(d[1]) >= 1 and len(d[2]) >= 1 and (len(d[3]) >= 1):
				flag = True
if flag:
	print(min((len(d[1]), len(d[2]), len(d[3]))))
	while len(d[1]) >= 1 and len(d[2]) >= 1 and (len(d[3]) >= 1):
		print(d[1][0], d[2][0], d[3][0])
		d[1].pop(0)
		d[2].pop(0)
		d[3].pop(0)
else:
	print(0)


n = int(input())
arr = list(map(int, input().split()))
one = []
two = []
three = []
l1 = 0
l2 = 0
l3 = 0
for i in range(1, n + 1):
	if arr[i - 1] == 1:
		one.append(i)
		l1 += 1
	elif arr[i - 1] == 2:
		two.append(i)
		l2 += 1
	else:
		three.append(i)
		l3 += 1
if l1 == 0 or l2 == 0 or l3 == 0:
	print(0)
else:
	j = 0
	answer = []
	while 1:
		if l1 == 0 or l2 == 0 or l3 == 0:
			break
		ans = []
		ans.append(one[j])
		ans.append(two[j])
		ans.append(three[j])
		answer.append(ans)
		l1 -= 1
		l2 -= 1
		l3 -= 1
		j += 1
	l = len(answer)
	print(l)
	for i in range(l):
		print(answer[i][0], end=' ')
		print(answer[i][1], end=' ')
		print(answer[i][2])


n = int(input())
ts = input()
t = [int(x) for x in ts.split(' ')]
types = [[], [], [], []]
for i in range(n):
	types[t[i]].append(i + 1)
possible = min(len(types[1]), len(types[2]), len(types[3]))
print(possible)
for i in range(possible):
	print(types[1].pop(), types[2].pop(), types[3].pop())


n = int(input())
ls = [[]]
(*l,) = map(int, input().split())
i = 1
j = 0
if 1 in l and 2 in l and (3 in l):
	while True:
		if len(ls[j]) < 3:
			x = l.index(i)
			ls[j].append(x + 1)
			l[x] = 0
			i += 1
		elif 1 in l and 2 in l and (3 in l):
			i = 1
			j += 1
			ls.append([])
		else:
			break
	print(len(ls))
	for i in range(len(ls)):
		print(*ls[i])
else:
	print(0)


n = int(input())
s = input().split()
td = {1: [], 2: [], 3: []}
for i in range(n):
	td[int(s[i])].append(i + 1)
t = 99999999999
for k in [1, 2, 3]:
	if len(td[k]) < t:
		t = len(td[k])
print(t)
for i in range(t):
	for k in [1, 2, 3]:
		print(td[k].pop(), end=' ')
	print('')


a = int(input())
l = list(map(int, input().split()))
if l.count(1) == 0 or l.count(2) == 0 or l.count(3) == 0:
	print(0)
else:
	w = min(l.count(1), l.count(2), l.count(3))
	print(w)
	for i in range(w):
		a1 = l.index(1)
		a2 = l.index(2)
		a3 = l.index(3)
		print(a1 + 1, a2 + 1, a3 + 1)
		l[a1] = 0
		l[a2] = 0
		l[a3] = 0


n = int(input())
b = [int(i) for i in input().split(' ')]
skill = {1: [], 2: [], 3: []}
for (idx, i) in enumerate(b):
	skill[i].append(idx + 1)
min_result = min(len(skill[1]), len(skill[2]), len(skill[3]))
print(min_result)
for i in range(min_result):
	print(skill[1][i], skill[2][i], skill[3][i])


n = int(input())
pupils = input().split()
times1 = []
times2 = []
times3 = []
cnt1 = cnt2 = cnt3 = 0
for i in range(0, len(pupils), 1):
	if pupils[i] == '1':
		times1.append(i + 1)
		cnt1 += 1
	if pupils[i] == '2':
		times2.append(i + 1)
		cnt2 += 1
	if pupils[i] == '3':
		times3.append(i + 1)
		cnt3 += 1
cnt = min(cnt1, cnt2, cnt3)
print(cnt)
for m in range(cnt):
	print(times1[m], times2[m], times3[m])


def func(n):
	m = list(map(int, input().split()))
	p = []
	math = []
	pe = []
	for i in range(len(m)):
		if m[i] == 1:
			p.append(i + 1)
		elif m[i] == 2:
			math.append(i + 1)
		else:
			pe.append(i + 1)
	print(min(len(p), len(math), len(pe)))
	while p and math and pe:
		print(p.pop(), math.pop(), pe.pop())
n = int(input())
func(n)


from sys import stdin, stdout
n = int(stdin.readline().strip())
skill_lst = stdin.readline().split()
prog = skill_lst.count('1')
math = skill_lst.count('2')
pe = skill_lst.count('3')
team_num = min(prog, math, pe)
stdout.write(str(team_num) + '\n')
if team_num > 0:
	for i in range(team_num):
		prog_ind = skill_lst.index('1')
		skill_lst[prog_ind] = 0
		math_ind = skill_lst.index('2')
		skill_lst[math_ind] = 0
		pe_ind = skill_lst.index('3')
		skill_lst[pe_ind] = 0
		line = str(prog_ind + 1) + ' ' + str(math_ind + 1) + ' ' + str(pe_ind + 1)
		stdout.write(line + '\n')


n = int(input())
ls = [int(u) for u in input().split()]
sp = []
mm = []
pg = []
for i in range(0, n):
	if ls[i] == 1:
		pg.append(i + 1)
	elif ls[i] == 2:
		mm.append(i + 1)
	elif ls[i] == 3:
		sp.append(i + 1)
teams = min(len(pg), len(mm), len(sp))
print(teams)
for i in range(0, teams):
	print(pg[i], mm[i], sp[i])


n = int(input())
l = [int(x) for x in input().split()]
one = l.count(1)
two = l.count(2)
three = l.count(3)
no = min(one, two, three)
print(no)
if no != 0:
	for i in range(no):
		for a in range(1, 4):
			p = l.index(a)
			print(p + 1)
			l[p] = 0


n = int(input())
s = list(map(int, input().split()))
pro = s.count(1)
math = s.count(2)
phy = s.count(3)
team = min(pro, math, phy)
print(team)
if team > 0:
	ppp = []
	mmm = []
	phh = []
	for i in range(len(s)):
		if s[i] == 1:
			ppp.append(i + 1)
		elif s[i] == 2:
			mmm.append(i + 1)
		elif s[i] == 3:
			phh.append(i + 1)
	for i in range(team):
		print(ppp[i], mmm[i], phh[i])


n = int(input())
A = list(map(int, input().split()))
team = min(A.count(1), A.count(2), A.count(3))
print(team)
for i in range(team):
	print(A.index(1) + 1, A.index(2) + 1, A.index(3) + 1)
	A[A.index(1)] = 0
	A[A.index(2)] = 0
	A[A.index(3)] = 0


import sys

def data():
	return sys.stdin.readline().strip()

def sp():
	return map(int, data().split())

def l():
	return list(sp())
n = int(data())
temp = l()
d = {}
a = []
b = []
c = []
for i in range(n):
	a.append(0)
	b.append(0)
	c.append(0)
x = 0
y = 0
z = 0
for i in range(n):
	if temp[i] == 1:
		a[x] = i + 1
		x += 1
	elif temp[i] == 2:
		b[y] = i + 1
		y += 1
	elif temp[i] == 3:
		c[z] = i + 1
		z += 1
w = min(x, y)
s = min(w, z)
if s > 0:
	print(s)
	for i in range(w):
		if a[i] != 0 and b[i] != 0 and (c[i] != 0):
			print(a[i], b[i], c[i])
else:
	print(s)
	exit()


n = int(input())
l = list(map(int, input().split()))
one = []
two = []
three = []
m = min(l.count(1), l.count(2), l.count(3))
if m == 0:
	print(m)
else:
	print(m)
	for i in range(n):
		if l[i] == 1:
			one.append((l[i], i + 1))
		elif l[i] == 2:
			two.append((l[i], i + 1))
		elif l[i] == 3:
			three.append((l[i], i + 1))
	for _ in range(m):
		print(one[_][1], two[_][1], three[_][1], end='\n')


n = int(input())
t = list(map(int, input().split()))
t1 = []
t2 = []
t3 = []
for i in range(n):
	if t[i] == 1:
		t1.append(i + 1)
	elif t[i] == 2:
		t2.append(i + 1)
	else:
		t3.append(i + 1)
count1 = len(t1)
count2 = len(t2)
count3 = len(t3)
if count1 > 0 and count2 > 0 and (count3 > 0):
	m = 0
	if count1 <= count2:
		if count1 <= count3:
			m = count1
		else:
			m = count3
	elif count2 <= count3:
		m = count2
	else:
		m = count3
	print(m)
	for i in range(m):
		print(t1[i], t2[i], t3[i], sep=' ')
else:
	print('0')


n = int(input())
l = list(map(int, input().split()))
w = min(l.count(1), min(l.count(2), l.count(3)))
print(w)
if w > 0:
	p = []
	m = []
	pe = []
	for i in range(len(l)):
		if l[i] == 1:
			p.append(i + 1)
		elif l[i] == 2:
			m.append(i + 1)
		else:
			pe.append(i + 1)
	for i in range(w):
		print(p[i], m[i], pe[i])


w = int(input())
X = input().split()
x = list(X)
y = [int(i) for i in x]
a = 0
b = 0
c = 0
s = []
d = []
f = []
for i in range(w):
	if y[i] == 1:
		a += 1
		s.append(i + 1)
	elif y[i] == 2:
		b += 1
		d.append(i + 1)
	else:
		c += 1
		f.append(i + 1)
if a <= b and a <= c:
	n = a
elif b <= a and b <= c:
	n = b
else:
	n = c
print(n)
for i in range(n):
	print(s[i], d[i], f[i])


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


s = int(input())
a = [int(x) for x in input().split()]
l = []
p = []
n = []
for i in range(len(a)):
	if a[i] == 1:
		l.append(i)
	elif a[i] == 2:
		p.append(i)
	else:
		n.append(i)
b = min(len(l), len(p), len(n))
if b == 0:
	print(0)
else:
	print(b)
	for i in range(b):
		print(l[i] + 1, p[i] + 1, n[i] + 1)


n = int(input())
A = [int(x) for x in input().split()]
B = []
C = []
D = []
for i in range(n):
	if A[i] == 1:
		B.append(i + 1)
	elif A[i] == 2:
		C.append(i + 1)
	else:
		D.append(i + 1)
w = min(len(B), len(C), len(D))
print(w)
for i in range(w):
	print(B[i], end=' ')
	print(C[i], end=' ')
	print(D[i])


n = int(input())
a = list(map(int, input().split()))
dem = min(a.count(1), a.count(2), a.count(3))
print(dem)
if dem != 0:
	b = set(a)
	vt = [[], [], []]
	for i in b:
		for j in range(n):
			if i == a[j]:
				vt[i - 1].append(j + 1)
	for i in range(dem):
		for j in range(3):
			print(vt[j][i], end=' ')
		print()


a = int(input())
b = list(map(int, input().rstrip().split()))
count1 = []
count2 = []
count3 = []
for i in range(len(b)):
	if b[i] == 1:
		count1.append(i)
	elif b[i] == 2:
		count2.append(i)
	else:
		count3.append(i)
x = len(count1)
y = len(count2)
z = len(count3)
if x < y:
	mini = x
else:
	mini = y
if mini < z:
	short = mini
else:
	short = z
print(short)
for i in range(short):
	print(count1[i] + 1, count2[i] + 1, count3[i] + 1)


n = int(input())
t = [int(i) for i in input().split()]
one_count = 0
one_indices = []
two_count = 0
two_indices = []
three_count = 0
three_indices = []
for i in range(n):
	if t[i] == 1:
		one_count += 1
		one_indices.append(i + 1)
	elif t[i] == 2:
		two_count += 1
		two_indices.append(i + 1)
	else:
		three_count += 1
		three_indices.append(i + 1)
w = min(one_count, two_count, three_count)
print(w)
for i in range(w):
	print(one_indices[i], two_indices[i], three_indices[i])


child = int(input())
members = list(map(int, input().split(' ')))
teams = min(members.count(1), members.count(2), members.count(3))
print(teams)
groups = []
for i in range(teams):
	p1 = members.index(1)
	p2 = members.index(2)
	p3 = members.index(3)
	(members[p1], members[p2], members[p3]) = (0, 0, 0)
	groups.append(str(p1 + 1) + ' ' + str(p2 + 1) + ' ' + str(p3 + 1))
for i in groups:
	print(i)


_ = int(input())
a = []
b = []
c = []
xs = [int(x) for x in input().split()]
for (i, x) in enumerate(xs, start=1):
	if x == 1:
		a.append(i)
	elif x == 2:
		b.append(i)
	else:
		c.append(i)
n_commands = min(len(a), len(b), len(c))
print(n_commands)
for (_a, _b, _c) in zip(a, b, c):
	print(_a, _b, _c)


inp = input()
chars = inp.split()
n = int(chars[0])
inp = input()
chars = inp.split()
count = [0, 0, 0]
teams = []
dict1 = {1: [], 2: [], 3: []}
for i in range(n):
	x = int(chars[i])
	count[x - 1] = count[x - 1] + 1
	dict1[x].append(i + 1)
y = int(min(count))
print(y)
for i in range(y):
	print(dict1[1][i], dict1[2][i], dict1[3][i])


n = int(input())
x = 0
y = 0
z = 0
a = []
b = []
c = []
d = []
a = list(map(int, input().split()))
for i in range(0, n):
	if a[i] == 1:
		x = x + 1
		d.append(i + 1)
	elif a[i] == 2:
		y += 1
		b.append(i + 1)
	else:
		z += 1
		c.append(i + 1)
p = min(x, y, z)
print(p)
for i in range(0, p):
	print('%d %d %d' % (d[i], b[i], c[i]))


n = int(input())
a = list(map(int, input().split()))
x = y = z = 0
c = []
c.append(a.count(1))
c.append(a.count(2))
c.append(a.count(3))
c.sort()
if c[0] == 0:
	print(0)
else:
	l = c[0]
	print(l)
	c = []
	c = [[0, 0, 0] for _ in range(l)]
	for i in range(n):
		if a[i] == 1:
			if x == l:
				continue
			else:
				c[x][0] = i + 1
				x = x + 1
		elif a[i] == 2:
			if y == l:
				continue
			else:
				c[y][1] = i + 1
				y = y + 1
		elif a[i] == 3:
			if z == l:
				continue
			else:
				c[z][2] = i + 1
				z = z + 1
	for i in range(l):
		print(*c[i])


n = int(input())
li1 = []
li2 = []
li3 = []
a = [int(i) for i in input().split(' ')]
for i in range(n):
	if a[i] == 1:
		li1.append(i + 1)
	elif a[i] == 2:
		li2.append(i + 1)
	else:
		li3.append(i + 1)
mn = min(len(li1), len(li2), len(li3))
print(mn)
for i in range(mn):
	print(li1[i], li2[i], li3[i])


n = int(input())
array = list(map(int, input().split(' ')))
l = len(set(array))
a = []
e = []
c = []
x = []
q = array.count(1)
w = array.count(2)
s = array.count(3)
t = min(q, w, s)
if l == 3:
	print(t)
	for i in range(t):
		if 1 in array:
			a.append(array.index(1) + 1)
			b = array.index(1)
			array[b] = 0
	for i in range(t):
		if 2 in array:
			e.append(array.index(2) + 1)
			b = array.index(2)
			array[b] = 0
	for i in range(t):
		if 3 in array:
			c.append(array.index(3) + 1)
			b = array.index(3)
			array[b] = 0
	for i in range(t):
		x.append(a[i])
		x.append(e[i])
		x.append(c[i])
		print(*x)
		x.clear()
else:
	print(0)


def Teams(n, arr):
	childrenResult = ''
	children = {1: [], 2: [], 3: []}
	for i in range(len(arr)):
		children[arr[i]].append(i + 1)
	numberOfTeams = min(len(children[1]), len(children[2]), len(children[3]))
	for i in range(numberOfTeams):
		team1 = children[1][i]
		team2 = children[2][i]
		team3 = children[3][i]
		childrenResult += str(team1) + ' ' + str(team2) + ' ' + str(team3) + '\n'
	return str(numberOfTeams) + '\n' + childrenResult
n = int(input())
arr = [int(i) for i in input().split(' ')]
print(Teams(n, arr))


n = int(input())
l = list(map(int, input().split()))
a = l.count(1)
b = l.count(2)
c = l.count(3)
m = min(a, min(b, c))
print(m)
o = [i for (i, x) in enumerate(l) if x == 1]
t = [i for (i, x) in enumerate(l) if x == 2]
th = [i for (i, x) in enumerate(l) if x == 3]
p = min(len(o), min(len(t), len(th)))
for i in range(p):
	print(o[i] + 1, t[i] + 1, th[i] + 1)


schB = int(input())
ts = [int(t) for t in input().split()]
a = min(ts.count(1), ts.count(2), ts.count(3))
(tl1, tl2, tl3) = ([], [], [])
for i in range(schB):
	if ts[i] == 1:
		tl1 += [i + 1]
	elif ts[i] == 2:
		tl2 += [i + 1]
	else:
		tl3 += [i + 1]
print(a)
for q in range(a):
	print(tl1[q], tl2[q], tl3[q])


import sys

def solution(n, ts):
	ones = []
	twos = []
	threes = []
	for (i, t) in enumerate(ts):
		if t == 1:
			ones.append(i + 1)
		elif t == 2:
			twos.append(i + 1)
		else:
			threes.append(i + 1)
	teams = []
	while ones and twos and threes:
		one = str(ones.pop(0))
		two = str(twos.pop(0))
		three = str(threes.pop(0))
		teams.append(one + ' ' + two + ' ' + three)
	print(len(teams))
	for team in teams:
		print(team)
n = sys.stdin.readline()
while n:
	ts = [int(a) for a in sys.stdin.readline().split()]
	solution(int(n), ts)
	n = sys.stdin.readline()


n = int(input())
l = list(map(int, input().split()))
l1 = []
l2 = []
l3 = []
(x, y, z) = (0, 0, 0)
for i in range(n):
	if l[i] == 1:
		l1.append(i + 1)
		x += 1
	elif l[i] == 2:
		l2.append(i + 1)
		y += 1
	else:
		l3.append(i + 1)
		z += 1
a = min(x, y, z)
print(a)
for i in range(a):
	print(l1[i], l2[i], l3[i])


Sindex = []
Mindex = []
Pindex = []
n = input()
students = input().split()
students = [int(student) for student in students]
for i in range(len(students)):
	if students[i] == 1:
		Pindex.append(i)
	elif students[i] == 2:
		Mindex.append(i)
	else:
		Sindex.append(i)
command = min(len(Pindex), len(Mindex), len(Sindex))
print(command)
for i in range(command):
	print(Pindex[i] + 1, Mindex[i] + 1, Sindex[i] + 1)


n = int(input())
vals = [*map(int, input().split())]
ones = []
twos = []
threes = []
for i in range(n):
	if vals[i] == 1:
		ones.append(i)
	elif vals[i] == 2:
		twos.append(i)
	else:
		threes.append(i)
least = min(vals.count(1), vals.count(2), vals.count(3))
print(least)
if least > 0:
	for i in range(least):
		print(ones[i] + 1, twos[i] + 1, threes[i] + 1)


int(input())
a = list(map(int, input().split()))
n = min(a.count(1), a.count(2), a.count(3))
ans = ''
if n != 0:
	print(n)
	for _ in range(n):
		ans = str(a.index(1) + 1) + ' ' + str(a.index(2) + 1) + ' ' + str(a.index(3) + 1)
		a[a.index(1)] = 0
		a[a.index(2)] = 0
		a[a.index(3)] = 0
		print(ans)
else:
	print(0)


n = input()
childInputList = list(map(int, input().split()))
indexList = list(enumerate(childInputList))
container = []
bigContainer = []
while len(indexList) > 0:
	for i in range(len(indexList)):
		item = indexList[i]
		if item[1] == 1:
			container.append(item)
			indexList.remove(item)
			break
	for i in range(len(indexList)):
		item = indexList[i]
		if item[1] == 2:
			container.append(item)
			indexList.remove(item)
			break
	for i in range(len(indexList)):
		item = indexList[i]
		if item[1] == 3:
			container.append(item)
			indexList.remove(item)
			break
	if len(container) == 3:
		indicies = [i + 1 for (i, x) in container]
		bigContainer.append(indicies)
		container.clear()
	else:
		break
print(len(bigContainer))
for item in bigContainer:
	print(item[0], item[1], item[2])


n = int(input())
t = [int(x) for x in input().split()]
tr = min(t.count(1), t.count(2), t.count(3))
triplets = []
print(tr)
if tr:
	k = 0
	i = 0
	while k < tr:
		if k < tr and t[i] == 1:
			triplets.append([i + 1])
			k += 1
		i += 1
	k = 0
	i = 0
	while k < tr:
		if k < tr and t[i] == 2:
			triplets[k].append(i + 1)
			k += 1
		i += 1
	k = 0
	i = 0
	while k < tr:
		if k < tr and t[i] == 3:
			triplets[k].append(i + 1)
			k += 1
		i += 1
	[print(*x) for x in triplets]


def teams(arr):
	ones = []
	twos = []
	threes = []
	for (idx, val) in enumerate(arr):
		if val == 1:
			ones.append(idx + 1)
		elif val == 2:
			twos.append(idx + 1)
		else:
			threes.append(idx + 1)
	result = []
	for i in range(min(len(ones), len(twos), len(threes))):
		result.append((ones[i], twos[i], threes[i]))
	return result
n = int(input())
nums = list(map(int, input().split()))
result = teams(nums)
print(len(result))
for i in range(len(result)):
	print(*result[i])


n = input()
list = list(map(int, input().split()))
l1 = []
l2 = []
l3 = []
for (i, item) in enumerate(list):
	if item == 1:
		l1.append(i + 1)
	if item == 2:
		l2.append(i + 1)
	if item == 3:
		l3.append(i + 1)
if len(l1) < 1 or len(l2) < 1 or len(l3) < 1:
	print(0)
else:
	m = min(len(l1), len(l2), len(l3))
	print(m)
	for k in range(0, m):
		print(l1[k], l2[k], l3[k])


n = int(input())
t = list(map(int, input().strip().split(' ')))
l1 = []
l2 = []
l3 = []
for i in range(n):
	if t[i] == 1:
		l1.append(i + 1)
	elif t[i] == 2:
		l2.append(i + 1)
	else:
		l3.append(i + 1)
k = min(len(l1), len(l2), len(l3))
print(k)
if k > 0:
	for j in range(k):
		print(l1[j], l2[j], l3[j])


n = input()
children = list(map(int, input().split()))
copy = children[:]
ones = []
two = []
three = []
a = []
for i in range(len(copy)):
	if copy[i] == 1:
		ones.append(i)
	elif copy[i] == 2:
		two.append(i)
	else:
		three.append(i)
if len(ones) == 0 or len(three) == 0 or len(three) == 0:
	print(0)
else:
	for i in range(min(len(three), len(ones), len(two))):
		a.append(str(ones[i] + 1) + ' ' + str(two[i] + 1) + ' ' + str(three[i] + 1))
	print(len(a))
	for i in a:
		print(i)


l = [[], [], []]
input()
for (i, j) in enumerate(map(int, input().split()), 1):
	l[j - 1] += [i]
print(min(map(len, l)))
for x in zip(*l):
	print(*x)


n = int(input())
l = list(map(int, input().split()))
setl = set(l)
p = []
a = []
b = []
c = []
if len(setl) != 3:
	print(0)
else:
	for i in setl:
		p.append(l.count(i))
	min1 = min(p)
	print(min1)
	for j in range(len(l)):
		if l[j] == 1:
			a.append(j + 1)
		elif l[j] == 2:
			b.append(j + 1)
		elif l[j] == 3:
			c.append(j + 1)
	for k in range(min1):
		print(a[k], b[k], c[k])


n = int(input())
l = list(map(int, input().split()))
d = {}
d[1] = []
d[2] = []
d[3] = []
for (i, num) in enumerate(l):
	d[num].append(i + 1)
l = list(zip(d[1], d[2], d[3]))
print(len(l))
for team in l:
	print(' '.join(map(str, team)))


from math import *
from copy import *
from string import *
from random import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math

def bin1(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = k ** mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin1(mid + 1, r, k, t, b, val, ans)
		else:
			return bin1(l, mid - 1, k, t, b, val, ans)

def bin2(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = t * k ** mid + b * mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin2(l, mid - 1, k, t, b, val, ans)
		else:
			return bin2(mid + 1, r, k, t, b, val, ans)

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def bin(l, r, ll, val):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		if val >= ll[mid][0] and val <= ll[mid][1]:
			return mid
		elif val < ll[mid][0]:
			return bin(l, mid - 1, ll, val)
		else:
			return bin(mid + 1, r, ll, val)

def deci(n):
	s = ''
	while n != 0:
		if n % 2 == 0:
			n = n // 2
			s = '0' + s
		else:
			n = n // 2
			s = '1' + s
	return s

def diff(s1, s2):
	if len(s1) < len(s2):
		v = len(s1)
		while v != len(s2):
			s1 = '0' + s1
			v = v + 1
	else:
		v = len(s2)
		while v != len(s1):
			s2 = '0' + s2
			v = v + 1
	c = 0
	for i in range(len(s1)):
		if s1[i:i + 1] != s2[i:i + 1]:
			c = c + 1
	return c
from sys import stdin, stdout

def fac(a, b):
	v = a
	while a != b:
		v *= a - 1
		a = a - 1
	return v

def bino(l, r, n):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		val1 = math.log(n / mid + 1, 2)
		val2 = int(val1)
		if val1 == val2:
			return val1
		elif val1 < 1.0:
			return bino(l, mid - 1, n)
		else:
			return bino(mid + 1, r, n)
n = int(input())
l = list(map(int, input().split(' ')))
l1 = []
l2 = []
l3 = []
for i in range(n):
	if l[i] == 1:
		l1.append(i + 1)
	elif l[i] == 2:
		l2.append(i + 1)
	else:
		l3.append(i + 1)
print(min(min(len(l1), len(l2)), len(l3)))
i1 = 0
i2 = 0
i3 = 0
while i1 < len(l1) and i2 < len(l2) and (i3 < len(l3)):
	print(l1[i1], l2[i2], l3[i3])
	i1 += 1
	i2 += 1
	i3 += 1


x = int(input())
p = list(map(int, input().split()))
z = ''
for n in range(x):
	z = z + str(p[n])
a = z.count('1')
b = z.count('2')
c = z.count('3')
if a != 0 and b != 0 and (c != 0):
	if a <= b:
		d = a
	else:
		d = b
	if d <= c:
		w = d
	else:
		w = c
	print(w)
	d = 1
elif a == 0 or b == 0 or c == 0:
	print('0')
	d = 0
if d == 1:
	k = []
	kk = []
	kkk = []
	for n in range(x):
		if p[n] == 1:
			k.append(n + 1)
	for n in range(x):
		if p[n] == 2:
			kk.append(n + 1)
	for n in range(x):
		if p[n] == 3:
			kkk.append(n + 1)
	for n in range(w):
		print(k[n], kk[n], kkk[n])


n = int(input())
skills = [[], [], []]
pr = 0
mth = 0
ph = 0
line = input()
skill = line.split()
for i in range(n):
	if skill[i] == '1':
		skills[0].append(i + 1)
		pr += 1
	if skill[i] == '2':
		skills[1].append(i + 1)
		mth += 1
	if skill[i] == '3':
		skills[2].append(i + 1)
		ph += 1
groups = min(pr, mth, ph)
if groups == 0:
	print('0')
else:
	print(groups)
	for i in range(groups):
		print(skills[0][i], skills[1][i], skills[2][i], sep=' ')


t = input()
children = int(t)
List1 = []
List2 = []
List3 = []
value = input()
valueList = value.split()
for i in range(children):
	if valueList[i] == '1':
		List1.append(i)
	elif valueList[i] == '2':
		List2.append(i)
	elif valueList[i] == '3':
		List3.append(i)
len1 = len(List1)
len2 = len(List2)
len3 = len(List3)
maximumTeams = min(len1, len2, len3)
print(maximumTeams)
if maximumTeams > 0:
	for i in range(maximumTeams):
		print(List1[i] + 1, List2[i] + 1, List3[i] + 1)


import math
n = int(input())
arr = list(map(int, input().split()))
dic = {1: [], 2: [], 3: []}
for i in range(n):
	dic[arr[i]].append(i + 1)
teams = min(len(dic[1]), len(dic[2]), len(dic[3]))
print(teams)
ans = []
j = 0
for i in range(teams):
	ans.append([dic[1][j], dic[2][j], dic[3][j]])
	j += 1
for i in ans:
	print(*i)


n = int(input())
arr = [int(x) for x in input().split()]
one = []
two = []
three = []
for s in range(len(arr)):
	if arr[s] == 1:
		one.append(s)
	elif arr[s] == 2:
		two.append(s)
	else:
		three.append(s)
ans = min(len(one), len(two), len(three))
print(ans)
ind = 0
while ind < ans:
	print(one[ind] + 1, two[ind] + 1, three[ind] + 1)
	ind += 1


is_debug = False
n = int(input())
t = [int(x) for x in input().split()]
c = [0] * 4
for v in t:
	c[v] = c[v] + 1
w = c[1]
w = w if w < c[2] else c[2]
w = w if w < c[3] else c[3]
print(f'{w}')
u = [False] * n
for c in range(w):
	(u_1, u_2, u_3) = (False, False, False)
	a = []
	for i in range(n):
		if u_1 and u_2 and u_3:
			break
		elif not u[i]:
			is_append = False
			if t[i] == 1 and (not u_1):
				(u_1, is_append) = (True, True)
			elif t[i] == 2 and (not u_2):
				(u_2, is_append) = (True, True)
			elif t[i] == 3 and (not u_3):
				(u_3, is_append) = (True, True)
			if is_append:
				a.append(i + 1)
				u[i] = not u[i]
	print(f"{' '.join([str(s) for s in a])}")


class Student:

	def __init__(self, position, skill):
		self._position = position
		self._skill = skill

	def get_position(self):
		return self._position

	def get_skill(self):
		return self._skill
n = int(input())
t = [int(i) for i in input().split()]
classes = []
for i in range(n):
	classes.append(Student(i + 1, t[i]))

def get_total(n, classes):
	total = 0
	for i in range(len(classes)):
		if Student.get_skill(classes[i]) == n:
			total += 1
	return total
n1 = get_total(1, classes)
n2 = get_total(2, classes)
n3 = get_total(3, classes)
w = min(n1, n2, n3)
print(w)
if w > 0:
	for i in range(w):
		l = 3 * [0]
		s1 = False
		s2 = False
		s3 = False
		for j in range(len(classes)):
			if Student.get_skill(classes[j]) == 1 and (not s1):
				l[0] = classes[j]
				s1 = True
			elif Student.get_skill(classes[j]) == 2 and (not s2):
				l[1] = classes[j]
				s2 = True
			elif Student.get_skill(classes[j]) == 3 and (not s3):
				l[2] = classes[j]
				s3 = True
			if s1 and s2 and s3:
				q = 3 * [0]
				for k in range(3):
					q[k] = str(Student.get_position(l[k]))
					classes.remove(l[k])
				print(' '.join(q))
				break


n = int(input())
abc = list(map(int, input().split()))
count_1 = abc.count(1)
count_2 = abc.count(2)
count_3 = abc.count(3)
w = min(count_1, count_2, count_3)
print(w)
ind_1 = []
ind_2 = []
ind_3 = []
for i in range(n):
	if abc[i] == 1:
		ind_1.append(i + 1)
	elif abc[i] == 2:
		ind_2.append(i + 1)
	elif abc[i] == 3:
		ind_3.append(i + 1)
for i in range(w):
	print(ind_1[0], ind_2[0], ind_3[0])
	ind_1.pop(0)
	ind_2.pop(0)
	ind_3.pop(0)


n = int(input())
children = [int(i) for i in input().split()]
a = [i + 1 for i in range(n) if children[i] == 1]
b = [i + 1 for i in range(n) if children[i] == 2]
c = [i + 1 for i in range(n) if children[i] == 3]
n_team = min(len(a), len(b), len(c))
print(n_team)
for i in range(n_team):
	print(a[i], b[i], c[i])


l = [[], [], []]
n = int(input())
tl = input().split()
x = 0
for i in range(n):
	x = int(tl[i]) - 1
	l[x].append(i + 1)
n = min(len(l[0]), min(len(l[1]), len(l[2])))
print(n)
for i in range(n):
	print(l[0][i], l[1][i], l[2][i])


n = int(input())
x = list(map(int, input().split()))
P = 0
M = 0
PE = 0
H = []
F = []
S = []
i = 1
while i <= len(x):
	if x[i - 1] == 1:
		P += 1
		H.append(i)
	elif x[i - 1] == 2:
		M += 1
		F.append(i)
	elif x[i - 1] == 3:
		PE += 1
		S.append(i)
	i += 1
J = [P, M, PE]
R = sorted(J)
W = R[0]
print(W)
if W > 0:
	for l in range(W):
		print(H[l], F[l], S[l])


n = int(input())
l = list(map(int, input().split()))
c = min(l.count(1), l.count(2), l.count(3))
print(c)
while True:
	if 1 not in l or 2 not in l or 3 not in l:
		break
	x = l.index(1)
	l[x] = 0
	print(x + 1, end=' ')
	y = l.index(2)
	l[y] = 0
	print(y + 1, end=' ')
	z = l.index(3)
	l[z] = 0
	print(z + 1, end=' ')
	print()


n = int(input())
l = list(map(int, input().split()))
m = min(l.count(1), l.count(2), l.count(3))
print(m)
for i in range(m):
	print(l.index(1) + 1, l.index(2) + 1, l.index(3) + 1)
	l.insert(l.index(1), '*')
	l.insert(l.index(2), '*')
	l.insert(l.index(3), '*')
	l.remove(1)
	l.remove(2)
	l.remove(3)


students_number = int(input())
students_skills = list(map(int, input().split(' ')))
students_skills_map = {}
students_good_at_programming = []
students_good_at_math = []
students_good_at_sports = []
for i in range(len(students_skills)):
	if students_skills[i] in students_skills_map:
		students_skills_map[students_skills[i]] += 1
	else:
		students_skills_map[students_skills[i]] = 1
	if students_skills[i] == 1:
		students_good_at_programming.append(i + 1)
	elif students_skills[i] == 2:
		students_good_at_math.append(i + 1)
	else:
		students_good_at_sports.append(i + 1)
if len(students_skills_map) < 3:
	print(0)
else:
	d1 = dict(sorted(students_skills_map.items(), key=lambda x: x[1]))
	teams_can_be_created = list(d1.values())[0]
	print(teams_can_be_created)
	for i in range(teams_can_be_created):
		res = ''
		res += str(students_good_at_programming.pop())
		res += ' '
		res += str(students_good_at_math.pop())
		res += ' '
		res += str(students_good_at_sports.pop())
		print(res)


n = int(input())
nlist = input().split()
list1 = []
list2 = []
list3 = []
for i in range(n):
	if nlist[i] == '1':
		list1.append(i + 1)
	elif nlist[i] == '2':
		list2.append(i + 1)
	else:
		list3.append(i + 1)
x = min(len(list1), len(list2), len(list3))
print(x)
if x != 0:
	for i in range(x):
		print(list1[i], list2[i], list3[i], sep=' ')


n = int(input())
l = list(map(int, input().split()))
min = min(l.count(1), l.count(2), l.count(3))
(k1, k2, k3) = ([], [], [])
print(min)
for i in range(n):
	if l[i] == 1:
		k1.append(i + 1)
	elif l[i] == 2:
		k2.append(i + 1)
	else:
		k3.append(i + 1)
for j in range(min):
	print(k1[j], k2[j], k3[j])


n = int(input())
l = [[] for i in range(3)]
tmp = [int(x) - 1 for x in input().split()]
for i in range(n):
	l[tmp[i]].append(i)
mi = min(len(l[0]), len(l[1]), len(l[2]))
print(mi)
for i in range(mi):
	print(l[0][i] + 1, l[1][i] + 1, l[2][i] + 1)


t = int(input())
p = list(map(int, input().split()))
s1s = []
s2s = []
s3s = []
for i in range(t):
	if p[i] == 1:
		s1s.append(i + 1)
	if p[i] == 2:
		s2s.append(i + 1)
	if p[i] == 3:
		s3s.append(i + 1)
g = min(len(s1s), len(s2s), len(s3s))
if g == 0:
	print(0)
else:
	print(g)
for i in range(g):
	print(f'{s1s[i]} {s2s[i]} {s3s[i]}')


n = int(input())
t = map(int, input().split())
t = list(t)
t1 = []
t2 = []
t3 = []
if 1 not in t or 2 not in t or 3 not in t:
	print(0)
elif 1 in t and 2 in t and (3 in t):
	for i in range(n):
		if t[i] == 1:
			t1 = t1 + [t.index(1) + 1]
			t[i] = 0
		elif t[i] == 2:
			t2 = t2 + [t.index(2) + 1]
			t[i] = 0
		elif t[i] == 3:
			t3 = t3 + [t.index(3) + 1]
			t[i] = 0
	a = [len(t1)] + [len(t2)] + [len(t3)]
	b = min(a)
	print(b)
	for i in range(b):
		print(t1[i], t2[i], t3[i])


n = int(input())
a = list(map(int, input().split()))
l = list(range(1, n + 1))
ml = list(sorted(zip(a, l)))
c1 = a.count(1)
c2 = a.count(2)
c3 = a.count(3)
l1 = ml[:c1]
l2 = ml[c1:c1 + c2]
l3 = ml[c1 + c2:]
w = min(c1, c2, c3)
print(w)
for i in range(w):
	print(l1[i][1], l2[i][1], l3[i][1])


n = int(input())
x = input().split()
a = x.count('1')
b = x.count('2')
c = x.count('3')
if a == 0 or b == 0 or c == 0:
	print('0')
else:
	print(min(a, b, c))
	while a > 0 and b > 0 and (c > 0):
		p1 = x.index('1')
		p2 = x.index('2')
		p3 = x.index('3')
		print(p1 + 1)
		print(p2 + 1)
		print(p3 + 1)
		x[p1] = '0'
		x[p2] = '0'
		x[p3] = '0'
		a = x.count('1')
		b = x.count('2')
		c = x.count('3')


n = 0
m1 = []
m2 = []
m3 = []
a = []
s = []
x = int(input())
if 1 <= x <= 5000:
	z = [int(c) for c in input().split()]
	if len(z) == x:
		for v in z:
			n = n + 1
			if v == 1:
				m1.append(n)
			elif v == 2:
				m2.append(n)
			elif v == 3:
				m3.append(n)
	while len(m1) != 0 and len(m2) != 0 and (len(m3) != 0):
		a.append(m1[0])
		a.append(m2[0])
		a.append(m3[0])
		s.append(a)
		a = []
		m1.remove(m1[0])
		m2.remove(m2[0])
		m3.remove(m3[0])
	print(len(s))
	for d in s:
		print(*d)


n = int(input())
arr = list(map(int, input().split()))
if len(set(arr)) < 3:
	print(0)
else:
	ones = []
	twos = []
	threes = []
	vic = {}
	for i in arr:
		if i in vic:
			vic[i] += 1
		else:
			vic[i] = 1
	for i in range(n):
		if arr[i] == 1:
			ones.append(i + 1)
		if arr[i] == 2:
			twos.append(i + 1)
		if arr[i] == 3:
			threes.append(i + 1)
	min = 10 ** 9
	for i in vic:
		if vic[i] < min:
			min = vic[i]
	print(min)
	for i in range(min):
		print(ones[i], twos[i], threes[i])


n = int(input())
a = list(map(int, input().split()))
b = a.count(1)
c = a.count(2)
d = a.count(3)
i = 0
if min(b, c, d) == 0:
	print(0)
else:
	(e, f, p) = ([], [], min(b, c, d))
	(a1, a2, a3, m, g, s) = ([], [], [], 0, 0, 0)
	while i < p:
		for j in range(len(a)):
			if a[j] == 1 and (not j + 1 in a1) and (m == 0):
				e.append(j + 1)
				a1.append(j + 1)
				m = 1
			elif a[j] == 2 and (not j + 1 in a2) and (g == 0):
				e.append(j + 1)
				a2.append(j + 1)
				g = 1
			elif a[j] == 3 and (not j + 1 in a3) and (s == 0):
				e.append(j + 1)
				a3.append(j + 1)
				s = 1
			if len(e) == 3:
				f.append(e)
				(e, m, g, s) = ([], 0, 0, 0)
				i += 1
	print(p)
	for i in range(p):
		print(*f[i])


import collections
n = int(input())
students = input().split(' ')
m = collections.defaultdict(list)
for (i, s) in enumerate(students):
	m[s].append(str(i + 1))
num_groups = 0
res = []
while len(m['1']) > 0 and len(m['2']) > 0 and (len(m['3']) > 0):
	num_groups += 1
	(one, two, three) = (m['1'].pop(), m['2'].pop(), m['3'].pop())
	res.append([one, two, three])
print(num_groups)
for r in res:
	print(' '.join(r))


n = int(input())
l = list(map(int, input().split()))
p1 = []
p2 = []
p3 = []
for (i, x) in enumerate(l, 1):
	if x == 1:
		p1.append(i)
	elif x == 2:
		p2.append(i)
	else:
		p3.append(i)
c = min(map(len, [p1, p2, p3]))
print(c)
for j in range(c):
	print(p1[j], p2[j], p3[j])


from collections import Counter
(length, team) = (int(input()), list(map(int, input().split())))
if len(set(team)) != 3:
	print(0)
else:
	a = Counter(team)
	ans = min(a.values())
	c = lambda b: [i + 1 for (i, e) in enumerate(team) if e == b]
	(i_a, i_b, i_c) = (c(1), c(2), c(3))
	print(ans)
	for i in range(ans):
		print(i_a[i], i_b[i], i_c[i])


stu = int(input(''))
studata = list(map(int, input('').split()))
final = []
while 1 in studata and 2 in studata and (3 in studata):
	a = studata.index(1)
	final.append(a)
	studata[a] = '/'
	a = studata.index(2)
	final.append(a)
	studata[a] = '/'
	a = studata.index(3)
	final.append(a)
	studata[a] = '/'
print(int(len(final) / 3))
if int(len(final) / 3) != 0:
	for i in range(0, len(final), 3):
		print(final[i] + 1, end=' ')
		print(final[i + 1] + 1, end=' ')
		print(final[i + 2] + 1)


n = int(input())
l = [int(x) for x in input().split()]
s = l
(a, b, c) = (0, 0, 0)
if 1 in l and 2 in l and (3 in l):
	k = min(l.count(1), l.count(2), l.count(3))
	print(k)
	for i in range(k):
		(a, b, c) = (l.index(1, a), l.index(2, b), l.index(3, c))
		a += 1
		b += 1
		c += 1
		print(a, b, c)
else:
	print(0)


n = int(input())
li = list(map(int, input().split()))
(a, b, c) = ([], [], [])
for i in range(len(li)):
	if li[i] == 1:
		a.append(i + 1)
	elif li[i] == 2:
		b.append(i + 1)
	else:
		c.append(i + 1)
print(min(len(a), len(b), len(c)))
while len(a) != 0 and len(b) != 0 and (len(c) != 0):
	print(a[-1], b[-1], c[-1])
	a.pop()
	b.pop()
	c.pop()


n = int(input())
s = list(map(int, input().split()))
(p, m, a) = (s.count(1), s.count(2), s.count(3))
teams = min(p, m, a)
print(teams)
a = []
b = []
c = []
for x in range(n):
	if s[x] == 1:
		a.append(x + 1)
	elif s[x] == 2:
		b.append(x + 1)
	elif s[x] == 3:
		c.append(x + 1)
for j in range(teams):
	print(a[j], b[j], c[j])


n = int(input())
lis = [int(x) for x in input().split()]
(a, b, c) = (0, 0, 0)
for i in lis:
	if i == 1:
		a += 1
	if i == 2:
		b += 1
	if i == 3:
		c += 1
if min(a, b, c) == 0:
	print(0)
else:
	print(min(a, b, c))
	i = []
	j = []
	k = []
	for z in range(n):
		if lis[z] == 1:
			i.append(z + 1)
		if lis[z] == 2:
			j.append(z + 1)
		if lis[z] == 3:
			k.append(z + 1)
	for _ in range(min(a, b, c)):
		print(i[_], j[_], k[_])


n = int(input())
w = 0
students = list(map(int, input().split()))
ones = []
twos = []
threes = []
for (i, e) in enumerate(students):
	if e == 1:
		ones.append([e, i + 1])
	elif e == 2:
		twos.append([e, i + 1])
	else:
		threes.append([e, i + 1])
if len(ones) >= 1 and len(twos) >= 1 and (len(threes) >= 1):
	w = min(len(ones), len(twos), len(threes))
print(w)
if w:
	for i in range(w):
		print(ones[i][1], twos[i][1], threes[i][1])


n = int(input())
s = list(map(int, input().split()))
x = min(s.count(1), s.count(2), s.count(3))
print(x)
w = ''
for y in s:
	w = w + str(y)
if x == 0:
	pass
else:
	(a, b, c) = ('', '', '')
	m = 1
	for i in w:
		if i == '1':
			a = a + str(m) + ' '
		if i == '2':
			b = b + str(m) + ' '
		if i == '3':
			c = c + str(m) + ' '
		m += 1
	try:
		a = a.split()
		b = b.split()
		c = c.split()
		p = 0
		for e in a:
			print(a[p], b[p], c[p])
			p += 1
	except:
		pass


n = int(input())
a = list(map(int, input().split()))
(x, y, z) = ([], [], [])
for i in range(n):
	if a[i] == 1:
		x.append(i + 1)
	if a[i] == 2:
		y.append(i + 1)
	if a[i] == 3:
		z.append(i + 1)
print(min(len(x), len(y), len(z)))
w = min(len(x), len(y), len(z))
while len(x) != w or len(y) != w or len(z) != w:
	if len(x) != w:
		x.pop()
	if len(y) != w:
		y.pop()
	if len(z) != w:
		z.pop()
for i in range(w):
	print(x[i], y[i], z[i])


amountOfChildrens = int(input())
childrens = [int(i) for i in input().split(' ')]
typesOfChildrens = [childrens.count(1), childrens.count(2), childrens.count(3)]
maximumTeams = min(typesOfChildrens)
print(maximumTeams)
if maximumTeams > 0:
	i = 0
	teams = []
	while i < maximumTeams:
		if i == 0:
			teams.append([childrens.index(1) + 1, childrens.index(2) + 1, childrens.index(3) + 1])
		else:
			teams.append([childrens.index(1, teams[i - 1][0]) + 1, childrens.index(2, teams[i - 1][1]) + 1, childrens.index(3, teams[i - 1][2]) + 1])
		print(*teams[i], sep=' ')
		i = i + 1


def solve(xs):
	bs = [[], [], []]
	for (i, v) in enumerate(xs):
		bs[v - 1].append(str(i + 1))
	m = min(map(len, bs))
	sol = [str(m)]
	for i in range(m):
		sol.append(' '.join(map(list.pop, bs)))
	print('\n'.join(sol))
input()
xs = list(map(int, input().split()))
solve(xs)


n = int(input())
a = input()
s = [int(i) for i in a.split()]
p = []
m = []
pe = []
for i in range(n):
	if s[i] == 1:
		p.append(i + 1)
	if s[i] == 2:
		m.append(i + 1)
	if s[i] == 3:
		pe.append(i + 1)
min1 = min(len(p), len(pe), len(m))
print(min1)
for i in range(min1):
	print(str(p[i]) + ' ' + str(m[i]) + ' ' + str(pe[i]))


n = int(input())
s = input().split()
(l1, l2, l3) = ([], [], [])
for i in range(n):
	if s[i] == '1':
		l1.append(i)
	elif s[i] == '2':
		l2.append(i)
	else:
		l3.append(i)
ans = min(len(l1), len(l2), len(l3))
print(ans)
for i in range(ans):
	print(l1[i] + 1, l2[i] + 1, l3[i] + 1)


n = int(input())
l = list(map(int, input().split()))
lcs = []
lm = []
lpe = []
math = l.count(2)
cs = l.count(1)
pe = l.count(3)
a = min(cs, math, pe)
if cs == 0 or math == 0 or pe == 0:
	print(0)
else:
	print(a)
for i in range(len(l)):
	if l[i] == 1:
		lcs.append(i)
	if l[i] == 2:
		lm.append(i)
	if l[i] == 3:
		lpe.append(i)
for i in range(a):
	print(lcs[i] + 1, lm[i] + 1, lpe[i] + 1)


n = int(input())
s = list(map(int, input().split()))
s1 = []
s2 = []
s3 = []
if s.count(1) and s.count(2) and s.count(3):
	print(min(min(s.count(1), s.count(2)), s.count(3)))
	for i in range(n):
		if s[i] == 1:
			s1.append(i)
		elif s[i] == 2:
			s2.append(i)
		elif s[i] == 3:
			s3.append(i)
	for i in range(min(min(s.count(1), s.count(2)), s.count(3))):
		print(s1[i] + 1, s2[i] + 1, s3[i] + 1)
else:
	print(0)


n = int(input())
s = list(map(int, input().split()))
s1 = []
s2 = []
s3 = []
k = [s.count(1), s.count(2), s.count(3)]
print(min(k))
c = min(k)
for i in range(n):
	if s[i] == 1:
		s1.append(i + 1)
	elif s[i] == 2:
		s2.append(i + 1)
	if s[i] == 3:
		s3.append(i + 1)
for j in range(c):
	print(s1[j], s2[j], s3[j])


n = int(input())
l = list(map(int, input().split()))
(a, b, c, x, y, z) = (list(), list(), list(), 0, 0, 0)
for i in range(n):
	if l[i] == 1:
		x += 1
		a.append(i + 1)
	elif l[i] == 2:
		y += 1
		b.append(i + 1)
	elif l[i] == 3:
		z += 1
		c.append(i + 1)
if x == 0 or y == 0 or z == 0:
	print('0')
else:
	k = min(x, y, z)
	print(k)
	for i in range(k):
		print(a[i], b[i], c[i])


(_, lst) = (input(), list(map(int, input().split())))
w = min(list(map(lst.count, [1, 2, 3])))
print(w)
for _ in range(w):
	print(lst.index(1) + 1, lst.index(2) + 1, lst.index(3) + 1, sep=' ')
	lst[lst.index(1)] = lst[lst.index(2)] = lst[lst.index(3)] = 0


import sys
inp = sys.stdin
n = int(inp.readline())
a = list(map(int, inp.readline().split()))
c = [0] * 3
b = [[], [], []]
for i in range(n):
	c[a[i] - 1] += 1
	b[a[i] - 1] += [i + 1]
x = min(c[0], c[1], c[2])
print(x)
for i in range(x):
	print('{0} {1} {2}'.format(b[0][i], b[1][i], b[2][i]))


count_stud = int(input())
students = list(map(int, input().split()))
programmers = []
mathematics = []
sportsmen = []
for i in range(count_stud):
	if students[i] == 1:
		programmers.append(i + 1)
	elif students[i] == 2:
		mathematics.append(i + 1)
	else:
		sportsmen.append(i + 1)
full_commands = min(len(programmers), len(mathematics), len(sportsmen))
print(full_commands)
for i in range(full_commands):
	print(programmers[i], mathematics[i], sportsmen[i])


x = int(input())
y = list(map(int, input().split()))
s1 = []
s2 = []
s3 = []
for i in range(len(y)):
	if y[i] == 1:
		s1.append(y.index(y[i]) + 1)
		y[i] = 0
	elif y[i] == 2:
		s2.append(y.index(y[i]) + 1)
		y[i] = 0
	elif y[i] == 3:
		s3.append(y.index(y[i]) + 1)
		y[i] = 0
n = min(len(s1), len(s2), len(s3))
print(n)
for i in range(n):
	print(s1[i], s2[i], s3[i])


n = int(input())
t = input().split()
x = 0
while x < len(t):
	t[x] = int(t[x])
	x = x + 1
a = t.count(1)
b = t.count(2)
c = t.count(3)
q = min(a, b, c)
print(q)
x = 0
y1 = []
y2 = []
y3 = []
z = ''
if q != 0:
	while x < len(t):
		if t[x] == 1:
			y1.append(x + 1)
		elif t[x] == 2:
			y2.append(x + 1)
		elif t[x] == 3:
			y3.append(x + 1)
		x = x + 1
	x = 0
	while q > 0:
		z = str(y1[x]) + ' ' + str(y2[x]) + ' ' + str(y3[x])
		print(z)
		z = ''
		x = x + 1
		q = q - 1


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


n = int(input())
a = list(map(int, input().split()))
(z, x, c) = ([], [], [])
for i in range(len(a)):
	if a[i] == 1:
		z.append(i)
	elif a[i] == 2:
		x.append(i)
	else:
		c.append(i)
q = min(len(z), len(x), len(c))
print(q)
for j in range(q):
	print(z[j] + 1, x[j] + 1, c[j] + 1)


n = int(input())
list1 = list(map(int, input().split()))
list2 = []
list3 = []
list4 = []
for i in range(n):
	if list1[i] == 1:
		list2.append(i + 1)
	elif list1[i] == 2:
		list3.append(i + 1)
	else:
		list4.append(i + 1)
n = min(len(list2), len(list3), len(list4))
print(n)
for i in range(n):
	print(list2[i], list3[i], list4[i])


input()
student_talents = {1: [], 2: [], 3: []}
list_students = list(map(int, input().split(' ')))
for i in range(len(list_students)):
	student = list_students[i]
	student_talents[student].append(i + 1)
min_sub = len(min(student_talents.values(), key=len))
print(min_sub)
for i in range(min_sub):
	print(str(student_talents[1][i]) + ' ' + str(student_talents[2][i]) + ' ' + str(student_talents[3][i]))


n = int(input())
A = input().split()
A = [int(i) for i in A]
a = A.count(1)
b = A.count(2)
c = A.count(3)
d = min(a, b, c)
print(d)
count1 = [0] * n
count2 = [0] * n
count3 = [0] * n
for i in range(0, n):
	if A[i] == 1:
		count1[i] += 1
	elif A[i] == 2:
		count2[i] += 1
	elif A[i] == 3:
		count3[i] += 1
while d > 0:
	first = count1.index(1) + 1
	count1[count1.index(1)] = 0
	second = count2.index(1) + 1
	count2[count2.index(1)] = 0
	third = count3.index(1) + 1
	count3[count3.index(1)] = 0
	d -= 1
	print(first, second, third)


n = int(input())
childs = [[] for _ in range(3)]
for (i, j) in enumerate(map(int, input().split())):
	childs[j - 1].append(i + 1)
teams = list(zip(*childs))
print(len(teams))
for i in teams:
	print(*i)


n = int(input())
t = list(map(int, input().split()))
one = []
two = []
three = []
print(min(t.count(1), t.count(2), t.count(3)))
for i in range(len(t)):
	if t[i] == 1:
		one += [i + 1]
	elif t[i] == 2:
		two += [i + 1]
	else:
		three += [i + 1]
	if one != [] and two != [] and (three != []):
		print(one[0], two[0], three[0])
		one = one[1:]
		two = two[1:]
		three = three[1:]
while one != [] and two != [] and (three != []):
	print(one[0], two[0], three[0])
	one = one[1:]
	two = two[1:]
	three = three[1:]


a = int(input())
n = list(map(int, input().split()))
list1 = []
list2 = []
list3 = []
for i in range(len(n)):
	if n[i] == 1:
		list1.append(i + 1)
	elif n[i] == 2:
		list2.append(i + 1)
	elif n[i] == 3:
		list3.append(i + 1)
m = min(len(list1), len(list2), len(list3))
print(m)
for j in range(m):
	print(str(list1[j]) + ' ' + str(list2[j]) + ' ' + str(list3[j]))


n = int(input())
l = list(map(int, input().split()))
m = []
m = [0] * 3
(p, q, r) = (0, 0, 0)
for i in range(len(l)):
	if l[i] == 1:
		m[0] += 1
	elif l[i] == 2:
		m[1] += 1
	else:
		m[2] += 1
if m[0] != 0 and m[1] != 0 and (m[2] != 0):
	a = min(m)
	print(a)
else:
	print(0)
	a = 0
while a > 0:
	a -= 1
	for i in range(p, n):
		if l[i] == 1:
			print(i + 1, end=' ')
			p = i + 1
			break
	for i in range(q, n):
		if l[i] == 2:
			print(i + 1, end=' ')
			q = i + 1
			break
	for i in range(r, n):
		if l[i] == 3:
			print(i + 1)
			r = i + 1
			break


n = int(input())
(it, math, pe) = ([], [], [])
pupils = input().split()
for i in range(n):
	if pupils[i] == '1':
		it.append(i + 1)
	elif pupils[i] == '2':
		math.append(i + 1)
	else:
		pe.append(i + 1)
m = min(len(it), len(math), len(pe))
print(m)
for i in range(m):
	print(it[i], math[i], pe[i])


In = int(input())
l = list(map(int, input().split()))
pro = []
maths = []
pe = []
for i in range(In):
	if l[i] == 1:
		pro.append(i + 1)
	elif l[i] == 2:
		maths.append(i + 1)
	elif l[i] == 3:
		pe.append(i + 1)
le = min(len(pro), len(maths), len(pe))
print(le)
for j in range(le):
	print(pro[j], maths[j], pe[j])


test = int(input())
arr = input().split()
arr = list(map(int, arr))
brr = [arr.count(1), arr.count(2), arr.count(3)]
print(min(brr))
for i in range(min(brr)):
	print(str(arr.index(1) + 1) + ' ' + str(arr.index(2) + 1) + ' ' + str(arr.index(3) + 1))
	arr[arr.index(1)] = 0.33
	arr[arr.index(2)] = 0.33
	arr[arr.index(3)] = 0.33


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


n = int(input())
skills = [int(c) for c in input().split()]
a = [[i for i in range(n) if skills[i] == j] for j in range(1, 4)]
num_teams = 0
teams = []
for (s1, s2, s3) in zip(a[0], a[1], a[2]):
	num_teams += 1
	teams.append((s1 + 1, s2 + 1, s3 + 1))
print(num_teams)
if teams:
	for t in teams:
		print(*t)


n = int(input())
l = list(map(int, input().split()))
(one, two, three) = ([], [], [])
for i in range(n):
	if l[i] == 1:
		one.append(i)
	elif l[i] == 2:
		two.append(i)
	elif l[i] == 3:
		three.append(i)
x = min(len(one), min(len(two), len(three)))
print(x)
for i in range(x):
	print(one[i] + 1, two[i] + 1, three[i] + 1)


n = int(input())
text = input().split()
talents = [0, 0, 0]
for i in range(0, n):
	talents[ord(text[i]) - ord('1')] += 1
teams = min(talents[0], talents[1], talents[2])
print(teams)
location = [0, 0, 0]
while teams != 0:
	while text[location[0]] != '1':
		location[0] += 1
	print(location[0] + 1, end=' ')
	location[0] += 1
	while text[location[1]] != '2':
		location[1] += 1
	print(location[1] + 1, end=' ')
	location[1] += 1
	while text[location[2]] != '3':
		location[2] += 1
	print(location[2] + 1)
	location[2] += 1
	teams -= 1


n = int(input())
arr = list(map(str, input().split()))
if '1' in arr and '2' in arr and ('3' in arr):
	mydict = {}
	for i in range(len(arr)):
		if arr[i] not in mydict:
			mydict[arr[i]] = [i + 1]
		else:
			mydict[arr[i]].append(i + 1)
	arr3 = []
	teams = n // 2
	for i in range(teams):
		arr2 = []
		if mydict['1'] != []:
			val_1 = mydict['1'].pop()
			arr2.append(val_1)
		if mydict['2'] != []:
			val_2 = mydict['2'].pop()
			arr2.append(val_2)
		if mydict['3'] != []:
			val_3 = mydict['3'].pop()
			arr2.append(val_3)
		if len(arr2) == 3:
			arr3.extend(arr2)
	total_teams = len(arr3) // 3
	print(total_teams)
	j = 0
	for i in range(total_teams):
		print(arr3[j], arr3[j + 1], arr3[j + 2])
		j += 3
else:
	print(0)


n = int(input())
arr = list(map(int, input().split()))
res = [[], [], []]
for (j, i) in enumerate(arr):
	if i:
		res[i - 1].append(j + 1)
x = min(map(len, res))
print(x)
for i in range(x):
	print(res[0][i], res[1][i], res[2][i])


a = input()
arr = input().split(' ')
ones = []
twos = []
threes = []
o = 0
tw = 0
th = 0
for i in range(0, len(arr)):
	if arr[i] == '1':
		ones.append(i)
		o = o + 1
	if arr[i] == '2':
		twos.append(i)
		tw = tw + 1
	if arr[i] == '3':
		threes.append(i)
		th = th + 1
if len(ones) == 0 or len(twos) == 0 or len(threes) == 0:
	print(0)
else:
	common = min(o, tw, th)
	print(common)
	for i in range(0, common):
		print(ones[i] + 1, ' ', twos[i] + 1, ' ', threes[i] + 1)


n = int(input())
l = list(map(int, input().split()))
one = []
two = []
three = []
for i in range(n):
	if l[i] == 1:
		one.append(i + 1)
	if l[i] == 2:
		two.append(i + 1)
	if l[i] == 3:
		three.append(i + 1)
n1 = len(one)
n2 = len(two)
n3 = len(three)
p = min(n1, n2, n3)
print(p)
for i in range(p):
	print(one[i], two[i], three[i])


hat = int(input())
students = list(input().split())
solution = []
if len(set(students)) != 3:
	print(0)
else:
	while hat > 0:
		if '1' in students:
			x = students.index('1') + 1
		else:
			break
		if '2' in students:
			y = students.index('2') + 1
		else:
			break
		if '3' in students:
			z = students.index('3') + 1
		else:
			break
		solution.append(str(x))
		solution.append(str(y))
		solution.append(str(z))
		students[x - 1] = '0'
		students[y - 1] = '0'
		students[z - 1] = '0'
		hat -= 3
	print(int(len(solution) / 3))
	for i in range(0, len(solution), 3):
		print(solution[i], solution[i + 1], solution[i + 2])


n = int(input())
sl = list(map(int, input().split()))
p = []
m = []
pe = []
for i in range(len(sl)):
	if sl[i] == 1:
		p.append(i + 1)
	elif sl[i] == 2:
		m.append(i + 1)
	else:
		pe.append(i + 1)
p.sort(reverse=True)
m.sort(reverse=True)
pe.sort(reverse=True)
team = min(len(p), len(m), len(pe))
if team > 0:
	print(team)
	for i in range(team):
		print(p[i], m[i], pe[i])
else:
	print(team)


n = int(input())
schoolchilds = list(map(int, input().split()))
teams_number = 0
teams = []
while 1 in schoolchilds and 2 in schoolchilds and (3 in schoolchilds):
	first = schoolchilds.index(1)
	second = schoolchilds.index(2)
	third = schoolchilds.index(3)
	teams.append([first, second, third])
	teams_number += 1
	schoolchilds[first] = 0
	schoolchilds[second] = 0
	schoolchilds[third] = 0
if teams_number == 0:
	print(teams_number)
else:
	print(teams_number)
	for i in range(teams_number):
		print(teams[i][0] + 1, teams[i][1] + 1, teams[i][2] + 1)


n = int(input())
t = list(map(int, input().split()))
a = min(t.count(1), t.count(2), t.count(3))
print(a)
l1 = []
l2 = []
l3 = []
for i in range(n):
	if t[i] == 1:
		l1.append(i + 1)
	elif t[i] == 2:
		l2.append(i + 1)
	else:
		l3.append(i + 1)
if a > 0:
	for i in range(a):
		s = [str(l1.pop(0)), str(l2.pop(0)), str(l3.pop(0))]
		print(' '.join(s))


x = input()
x = input().split(' ')
for i in range(len(x)):
	x[i] = int(x[i])
from collections import Counter
y = Counter(x)
if y[1] == 0 or y[2] == 0 or y[3] == 0:
	print(0)
else:
	min = 5000
	for z in y:
		if y[z] < min:
			min = y[z]
	locs = dict()
	for i in range(len(x)):
		if x[i] not in locs:
			locs[x[i]] = [i + 1]
		else:
			locs[x[i]].append(i + 1)
	out = []
	start = 0
	for i in range(min):
		store = [str(locs[1][start]), str(locs[2][start]), str(locs[3][start])]
		out.append(store)
		start += 1
	print(len(out))
	for x in out:
		print(' '.join(x))


def olympiad(n, ni):
	(one, two, three) = ([], [], [])
	for i in range(len(ni)):
		if ni[i] == 1:
			one.append(i + 1)
		if ni[i] == 2:
			two.append(i + 1)
		if ni[i] == 3:
			three.append(i + 1)
	print(min(ni.count(1), ni.count(2), ni.count(3)))
	for i in range(min(ni.count(1), ni.count(2), ni.count(3))):
		print(one[i], two[i], three[i])
n = int(input())
ni = list(map(int, input().split()))
olympiad(n, ni)


n = int(input())
l = list(map(int, input().split()))
(c1, c2, c3) = ([], [], [])
for i in range(n):
	if l[i] == 1:
		c1.append(i + 1)
	elif l[i] == 2:
		c2.append(i + 1)
	else:
		c3.append(i + 1)
k = min(len(c1), len(c2), len(c3))
print(k)
for i in range(k):
	print(c1[i], c2[i], c3[i])


(p, m, k, posp, posm, posk) = ([], [], [], [], [], [])
n = int(input())
s = list(map(int, input().split()))
for i in range(len(s)):
	if s[i] == 1:
		p.append(s[i])
		posp.append(i)
	if s[i] == 2:
		m.append(s[i])
		posm.append(i)
	if s[i] == 3:
		k.append(s[i])
		posk.append(i)
res = min(len(p), min(len(m), len(k)))
print(res)
for i in range(0, res):
	print(str(posp[i] + 1) + ' ' + str(posm[i] + 1) + ' ' + str(posk[i] + 1))


n = int(input())
students = input().split()
it_1 = students.count('1')
it_2 = students.count('2')
it_3 = students.count('3')
print(min([it_1, it_2, it_3]))
if min([it_1, it_2, it_3]) != 0:
	for i in range(min([it_1, it_2, it_3])):
		print(students.index('1') + 1, students.index('2') + 1, students.index('3') + 1)
		students[students.index('1')] = 0
		students[students.index('2')] = 0
		students[students.index('3')] = 0


n = int(input())
l = [int(i) for i in input().split()]
if len(set(l)) < 3:
	print(0)
else:
	z = min(l.count(1), l.count(2), l.count(3))
	print(z)
	for _ in range(z):
		k = l.index(1)
		k1 = l.index(2)
		k2 = l.index(3)
		print(k + 1, k1 + 1, k2 + 1)
		l[k] = l[k1] = l[k2] = -100


k = int(input())
b = [int(b) for b in input().split()]
l1 = []
l2 = []
l3 = []
for i in range(k):
	if b[i] == 1:
		l1.append(i)
	if b[i] == 2:
		l2.append(i)
	if b[i] == 3:
		l3.append(i)
n1 = len(l1)
n2 = len(l2)
n3 = len(l3)
b = [n1, n2, n3]
b.sort()
w = b[0]
print(w)
for i in range(w):
	print(l1[i] + 1, l2[i] + 1, l3[i] + 1)


n = int(input())
l = list(map(int, input().split()))
a = min(l.count(1), l.count(2), l.count(3))
print(a)
for i in range(a):
	for u in range(1, 4):
		print(l.index(u) + 1, end=' ')
		l[l.index(u)] = 0
	print()


t = int(input())
a = [int(x) for x in input().split(' ')]
lst = [[] for x in range(0, 3)]
for i in range(0, len(a)):
	if a[i] == 1:
		lst[0].append(i + 1)
	elif a[i] == 2:
		lst[1].append(i + 1)
	else:
		lst[2].append(i + 1)
w = min(len(lst[0]), len(lst[1]), len(lst[2]))
print(w)
while w:
	w = w - 1
	print(lst[0][0], lst[1][0], lst[2][0])
	del lst[0][0]
	del lst[2][0]
	del lst[1][0]


n = int(input())
a = [int(i) for i in input().split()]
s = []
m = []
o = []
p = min(a.count(3), a.count(2), a.count(1))
print(p)
for i in range(len(a)):
	if a[i] == 1:
		s.append(i + 1)
	if a[i] == 2:
		m.append(i + 1)
	if a[i] == 3:
		o.append(i + 1)
if p > 0:
	for i in range(p):
		print(s[i], m[i], o[i])


a = int(input())
b = list(map(int, input().split()))
c1 = []
c2 = []
c3 = []
for i in range(a):
	if b[i] == 1:
		c1.append(i + 1)
	elif b[i] == 2:
		c2.append(i + 1)
	else:
		c3.append(i + 1)
print(min(len(c1), min(len(c2), len(c3))))
for i in range(min(len(c1), min(len(c2), len(c3)))):
	print(c1[i], c2[i], c3[i])


def least(x, y, z):
	k = x
	if k > y:
		k = y
	if k > z:
		k = z
	return k
n = input()
n = int(n)
t = input()
t = t.split()
pro = []
math = []
pe = []
for i in range(n):
	t[i] = int(t[i])
	if t[i] == 1:
		pro.append(i + 1)
	elif t[i] == 2:
		math.append(i + 1)
	elif t[i] == 3:
		pe.append(i + 1)
l1 = len(pro)
l2 = len(math)
l3 = len(pe)
x = least(l1, l2, l3)
print(x)
if x > 0:
	for i in range(x):
		print(pro[i], math[i], pe[i])


hm = int(input())
skills = list(input().split(' '))
prog = 0
proglis = []
math = 0
mathlis = []
pe = 0
pelis = []
i = 0
while i < len(skills):
	skills[i] = int(skills[i])
	if skills[i] == 1:
		prog += 1
		proglis.append(i)
	elif skills[i] == 2:
		math += 1
		mathlis.append(i)
	elif skills[i] == 3:
		pe += 1
		pelis.append(i)
	i += 1
lis = {prog, math, pe}
print(min(lis))
for i in range(min(lis)):
	print(str(proglis[i] + 1) + ' ' + str(mathlis[i] + 1) + ' ' + str(pelis[i] + 1))


from collections import Counter
n = int(input())
a = list(map(int, input().split(' ')))
b = Counter(a)
t = min(b.values())
if a.count(1) > 0 and a.count(2) > 0 and (a.count(3) > 0):
	print(t)
	for i in range(t):
		print(a.index(1) + 1, a.index(2) + 1, a.index(3) + 1)
		a.insert(a.index(1), 0)
		a.pop(a.index(1))
		a.insert(a.index(2), 0)
		a.pop(a.index(2))
		a.insert(a.index(3), 0)
		a.pop(a.index(3))
else:
	print(0)


n = int(input())
l = list(map(int, input().split()))
c1 = 0
c2 = 0
c3 = 0
for i in l:
	if i == 1:
		c1 += 1
	if i == 2:
		c2 += 1
	if i == 3:
		c3 += 1
if c1 == c2 and c2 == c3 and (c3 == c1):
	m = c1
m = min(c1, c2, c3)
print(m)
for i in range(m):
	print(l.index(1) + 1, end=' ')
	l[l.index(1)] = 0
	print(l.index(2) + 1, end=' ')
	l[l.index(2)] = 0
	print(l.index(3) + 1, end='\n')
	l[l.index(3)] = 0


n = int(input())
L = list(map(int, input().split()))
A = [[], [], []]
for i in range(len(L)):
	A[L[i] - 1] += [i + 1]
w = min(len(A[0]), len(A[1]), len(A[2]))
print(w)
for i in range(w):
	print(str(A[0][i]) + ' ' + str(A[1][i]) + ' ' + str(A[2][i]))


n = input()
l = input().split()
code = [index + 1 for (index, item) in enumerate(l) if item == '1']
math = [index + 1 for (index, item) in enumerate(l) if item == '2']
sport = [index + 1 for (index, item) in enumerate(l) if item == '3']
print(min(len(code), len(math), len(sport)))
for (x, y, z) in zip(code, math, sport):
	print(x, y, z)


n = int(input())
boys = list(map(int, input().split()))
c_1 = boys.count(1)
c_2 = boys.count(2)
c_3 = boys.count(3)
if c_1 > 0 and c_2 > 0 and (c_3 > 0):
	minimal = min(c_1, c_2, c_3)
else:
	minimal = 0
print(minimal)
for i in range(minimal):
	a = boys.index(1)
	b = boys.index(2)
	c = boys.index(3)
	print(a + 1, b + 1, c + 1)
	(boys[a], boys[b], boys[c]) = (0, 0, 0)


d = {'1': [], '2': [], '3': []}
n = input()
l = input().split()
i = 1
for e in l:
	d[e].append(i)
	i = i + 1
m = min(len(d['1']), len(d['2']), len(d['3']))
print(m)
for i in range(m):
	print('{} {} {}'.format(d['1'].pop(), d['2'].pop(), d['3'].pop()))


n = int(input())
l = list(map(int, input().split()))
l1 = []
l2 = []
l3 = []
d = dict(zip(range(1, n + 1), l))
r = min(l.count(1), l.count(2), l.count(3))
for (p, q) in d.items():
	if q == 1:
		l1.append(p)
	elif q == 2:
		l2.append(p)
	elif q == 3:
		l3.append(p)
if r == 0:
	print('0')
else:
	print(r)
	for i in range(r):
		print(l1[i], l2[i], l3[i])


n = int(input())
ls = list(map(int, input().split(' ')))
c1 = ls.count(1)
c2 = ls.count(2)
c3 = ls.count(3)
if c1 == 0 or c2 == 0 or c3 == 0:
	print(0)
else:
	teamsFormed = min(c1, c2, c3)
	res = []
	s = set(ls)
	b = list(s)
	while teamsFormed > 0:
		for i in range(len(b)):
			x = b[i]
			res.append(ls.index(x) + 1)
		ls[ls.index(1)] = '*'
		ls[ls.index(2)] = '*'
		ls[ls.index(3)] = '*'
		teamsFormed -= 1
	print(min(c1, c2, c3))
	for j in range(min(c1, c2, c3)):
		print(*res[j * 3:j * 3 + 3])


n = int(input())
t = list((int(x) for x in input().split()))
teams = {'1': [], '2': [], '3': []}
for i in range(len(t)):
	if t[i] == 1:
		teams['1'].append(i + 1)
		continue
	elif t[i] == 2:
		teams['2'].append(i + 1)
		continue
	else:
		teams['3'].append(i + 1)
w = min(len(teams['1']), len(teams['2']))
w = min(w, len(teams['3']))
print(w)
for i in range(w):
	print(teams['1'][i], teams['2'][i], teams['3'][i])


n = int(input())
L = list(map(int, input().split()))
L1 = []
L2 = []
L3 = []
for i in range(len(L)):
	if L[i] == 1:
		L1 = L1 + [i + 1]
	elif L[i] == 2:
		L2 = L2 + [i + 1]
	else:
		L3 = L3 + [i + 1]
a = min(len(L1), len(L2), len(L3))
print(a)
for i in range(a):
	print(L1[i], L2[i], L3[i])


N = int(input())
t_data = input().split()
if t_data.count('1') == 0 or t_data.count('2') == 0 or t_data.count('3') == 0:
	print('0')
	exit
else:
	t_cpy = t_data.copy()
	teams = []
	teams_count = 0
	counter = 0
	while True:
		if counter == N - 1 or counter == N or t_cpy.count('1') == 0 or (t_cpy.count('2') == 0) or (t_cpy.count('3') == 0):
			break
		t1 = t_cpy.index('1')
		t2 = t_cpy.index('2')
		t3 = t_cpy.index('3')
		t_cpy[t1] = ''
		t_cpy[t2] = ''
		t_cpy[t3] = ''
		teams.append([t1 + 1, t2 + 1, t3 + 1])
		counter += 3
		teams_count += 1
	print(teams_count)
	print('\n'.join((' '.join(map(str, line)) for line in teams)))


n = int(input())
a = list(map(int, input().split()))
if 1 not in a or 2 not in a or 3 not in a:
	print(0)
else:
	one = a.count(1)
	two = a.count(2)
	thr = a.count(3)
	w = min(one, two, thr)
	print(w)
	for i in range(w):
		x = a.index(1)
		y = a.index(2)
		z = a.index(3)
		print(x + 1, y + 1, z + 1)
		a[x] = 0
		a[y] = 0
		a[z] = 0


n = int(input())
a = [int(i) for i in input().split()]
h = k = l = x = 0
for i in range(n):
	if a[i] == 1:
		h += 1
	elif a[i] == 2:
		k += 1
	else:
		l += 1
if h > k:
	if k > l:
		print(l)
		for i in range(n):
			if a[i] == 3:
				print(i + 1, end=' ')
				a[i] = 0
				for j in range(n):
					if a[j] == 2:
						print(j + 1, end=' ')
						a[j] = 0
						break
				for j in range(n):
					if a[j] == 1:
						print(j + 1)
						a[j] = 0
						break
	else:
		print(k)
		for i in range(n):
			if a[i] == 2:
				print(i + 1, end=' ')
				a[i] = 0
				for j in range(n):
					if a[j] == 3:
						print(j + 1, end=' ')
						a[j] = 0
						break
				for j in range(n):
					if a[j] == 1:
						print(j + 1)
						a[j] = 0
						break
elif h > l:
	print(l)
	for i in range(n):
		if a[i] == 3:
			print(i + 1, end=' ')
			a[i] = 0
			for j in range(n):
				if a[j] == 2:
					print(j + 1, end=' ')
					a[j] = 0
					break
			for j in range(n):
				if a[j] == 1:
					print(j + 1)
					a[j] = 0
					break
else:
	print(h)
	for i in range(n):
		if a[i] == 1:
			print(i + 1, end=' ')
			a[i] = 0
			for j in range(n):
				if a[j] == 3:
					print(j + 1, end=' ')
					a[j] = 0
					break
			for j in range(n):
				if a[j] == 2:
					print(j + 1)
					a[j] = 0
					break


n_students = int(input())
scores = [int(x) for x in input().split()]
one = []
two = []
three = []
for i in range(n_students):
	if scores[i] == 1:
		one.append(i + 1)
	elif scores[i] == 2:
		two.append(i + 1)
	else:
		three.append(i + 1)
n_teams = min(len(one), min(len(two), len(three)))
print(n_teams)
for i in range(n_teams):
	print(one[i], two[i], three[i])


coders = []
mathematicians = []
athletes = []
input()
people = map(int, input().split())
for (num, person) in enumerate(people):
	if person == 1:
		coders.append(num + 1)
	elif person == 2:
		mathematicians.append(num + 1)
	else:
		athletes.append(num + 1)
amount_of_teams = min(map(len, (coders, mathematicians, athletes)))
print(amount_of_teams)
if amount_of_teams > 0:
	for _ in range(amount_of_teams):
		team = map(str, (coders.pop(), mathematicians.pop(), athletes.pop()))
		print(' '.join(team))


def answer():
	a = int(input())
	b = input().split()
	(c, d, e) = ([], [], [])
	i = 0
	while i < len(b):
		x = b[i]
		if x == '1':
			c.append(i)
		elif x == '2':
			d.append(i)
		else:
			e.append(i)
		i += 1
	l = min(len(c), len(d), len(e))
	if l == 0:
		print(0)
	else:
		c = c[:l]
		d = d[:l]
		e = e[:l]
		i = 0
		print(l)
		while i < len(c):
			print(c[i] + 1, d[i] + 1, e[i] + 1)
			i += 1
answer()


n = int(input())
i = 1
l = [[], [], []]
countL = [0, 0, 0]
for x in input().split():
	x = int(x) - 1
	l[x].append(i)
	countL[x] += 1
	i += 1
w = min(countL)
print(w)
for i in range(w):
	print(l[0].pop(), l[1].pop(), l[2].pop())


n = int(input())
s = list(map(int, input().split()))
ans = min(s.count(1), s.count(2), s.count(3))
print(ans)
for i in range(ans):
	(a, b, c) = (s.index(1), s.index(2), s.index(3))
	print(a + 1, b + 1, c + 1)
	s[a] = s[b] = s[c] = 0


m = int(input())
lt = list(map(int, input().split()))
a = min(lt.count(1), lt.count(2), lt.count(3))
print(a)
for i in range(a):
	x = lt.index(1)
	y = lt.index(2)
	z = lt.index(3)
	lt[x] = lt[y] = lt[z] = 0
	print(x + 1, y + 1, z + 1)


n = int(input())
l = list(map(int, input().split()))
l1 = l.count(1)
l2 = l.count(2)
l3 = l.count(3)
nt = min(l1, l2, l3)
if nt == 0:
	print(0)
	exit()
print(nt)
li1 = []
li2 = []
li3 = []
for i in range(n):
	if l[i] == 1:
		li1.append(i + 1)
	elif l[i] == 2:
		li2.append(i + 1)
	else:
		li3.append(i + 1)
for i in range(nt):
	print(li1[i], li2[i], li3[i])


n = int(input())
t = list(map(int, input().split()))
s1 = 0
s2 = 0
s3 = 0
t1 = []
t2 = []
t3 = []
for i in range(len(t)):
	if t[i] == 1:
		t1.append(str(i + 1))
		s1 += 1
	elif t[i] == 2:
		t2.append(str(i + 1))
		s2 += 1
	else:
		t3.append(str(i + 1))
		s3 += 1
k = min(s1, s2, s3)
if k == 0:
	print(0)
else:
	print(k)
	for i in range(k):
		k = [t1[i], t2[i], t3[i]]
		print(' '.join(k))


n = int(input())
students = list(map(int, input().split()))
count_commands = str(students)
min_ = min(count_commands.count('1'), count_commands.count('2'), count_commands.count('3'))
print(0) if count_commands.count('1') == 0 or count_commands.count('2') == 0 or count_commands.count('3') == 0 else print(min_)
for i in range(min_):
	print(students.index(1) + 1, students.index(2) + 1, students.index(3) + 1)
	students[students.index(1)] = 0
	students[students.index(2)] = 0
	students[students.index(3)] = 0


n = int(input())
t1 = list(map(int, input().split()))
t = sorted(t1)
(x, y, z) = (-1, -1, -1)
(cnt1, cnt2, cnt3) = (0, 0, 0)
for i in range(n):
	if t[i] == 1:
		cnt1 += 1
		if x == -1:
			x = i
	if t[i] == 2:
		cnt2 += 1
		if y == -1:
			y = i
	if t[i] == 3:
		cnt3 += 1
		if z == -1:
			z = i
if cnt1 == 0 or cnt2 == 0 or cnt3 == 0:
	print(0)
else:
	l = [[] for i in range(min(cnt1, cnt2, cnt3))]
	lk = min(cnt1, cnt2, cnt3) - 1
	print(lk + 1)
	tmp = 0
	for j in range(n):
		if t1[j] == 1:
			if tmp <= lk:
				l[tmp].append(j + 1)
				tmp += 1
	tmp = 0
	for j in range(n):
		if t1[j] == 2:
			if tmp <= lk:
				l[tmp].append(j + 1)
				tmp += 1
	tmp = 0
	for j in range(n):
		if t1[j] == 3:
			if tmp <= lk:
				l[tmp].append(j + 1)
				tmp += 1
	for j in range(len(l)):
		print(*l[j])


n = int(input())
t = list(map(int, input().split()))
i1 = []
i2 = []
i3 = []
for i in range(n):
	if t[i] == 1:
		i1.append(i)
	elif t[i] == 2:
		i2.append(i)
	elif t[i] == 3:
		i3.append(i)
ai1 = len(i1)
ai2 = len(i2)
ai3 = len(i3)
if ai1 <= ai2 and ai1 <= ai3:
	mn = ai1
elif ai2 <= ai1 and ai2 <= ai3:
	mn = ai2
elif ai3 <= ai1 and ai3 <= ai2:
	mn = ai3
print(mn)
while i1 != [] and i2 != [] and (i3 != []):
	print(i1[0] + 1, i2[0] + 1, i3[0] + 1)
	i1.remove(i1[0])
	i2.remove(i2[0])
	i3.remove(i3[0])


n = int(input())
st = list(map(int, input().split()))
(a, b, c) = ([], [], [])
for i in range(1, len(st) + 1):
	if st[i - 1] == 1:
		a.append(i)
	elif st[i - 1] == 2:
		b.append(i)
	else:
		c.append(i)
out = list(zip(a, b, c))
print(len(out))
for i in out:
	for j in i:
		print(j, sep=' ', end=' ')
	print()


input()
b = {1: [0], 2: [0], 3: [0]}
j = 1
for i in list(map(int, input().split())):
	b[i].append(j)
	b[i][0] += 1
	j += 1
k = 1
print(min(b[1][0], b[2][0], b[3][0]))
for i in range(min(b[1][0], b[2][0], b[3][0])):
	print(b[1][k], b[2][k], b[3][k])
	k += 1


n = int(input())
arr = list(map(int, input().split()))
programming = arr.count(1)
maths = arr.count(2)
pe = arr.count(3)
temp = min(programming, maths, pe)
print(temp)
for i in range(temp):
	programming_index = arr.index(1)
	math_index = arr.index(2)
	pe_index = arr.index(3)
	arr[programming_index] = 'X'
	arr[math_index] = 'X'
	arr[pe_index] = 'X'
	print(programming_index + 1, math_index + 1, pe_index + 1)


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


n = int(input())
first = []
second = []
third = []
a = input().split()
for i in range(n):
	if a[i] == '1':
		first.append(i + 1)
	elif a[i] == '2':
		second.append(i + 1)
	else:
		third.append(i + 1)
print(min(len(first), len(second), len(third)))
for i in range(min(len(first), len(second), len(third))):
	print(first[i], end=' ')
	print(second[i], end=' ')
	print(third[i])


n = int(input())
s = [int(i) for i in input().split()]
a = min([s.count(1), s.count(2), s.count(3)])
print(a)
for i in range(a):
	c = (s.index(1) + 1, s.index(2) + 1, s.index(3) + 1)
	s[s.index(1)] = s[s.index(2)] = s[s.index(3)] = 0
	print(*c)


i = int(input())
kids = [int(i) for i in str(input()).split(' ')]
j = [[] for _ in range(3)]
for (index, value) in enumerate(kids):
	j[value - 1].append(index + 1)
y = min(j, key=lambda x: len(x))
print(len(y))
for i in range(len(y)):
	tempStr = ''
	for q in range(3):
		tempStr = tempStr + str(j[q].pop()) + ' '
	print(tempStr[0:-1])


n = int(input())
t = list(map(int, input().split()))
n1 = list()
n2 = list()
n3 = list()
nteams = 0
count1 = 0
count2 = 0
count3 = 0
for i in range(n):
	if t[i] == 1:
		count1 += 1
		n1.append(i)
	elif t[i] == 2:
		count2 += 1
		n2.append(i)
	else:
		count3 += 1
		n3.append(i)
nmin = min(count1, count2, count3)
if nmin == 0:
	print(nmin)
else:
	print(nmin)
	for i in range(nmin):
		print(n1[i] + 1, n2[i] + 1, n3[i] + 1)


n = int(input())
a = list(map(int, input().split()))
b1 = []
b2 = []
b3 = []
k1 = 0
k2 = 0
k3 = 0
for i in range(n):
	if a[i] == 1:
		b1.append(i + 1)
		k1 += 1
	if a[i] == 2:
		b2.append(i + 1)
		k2 += 1
	if a[i] == 3:
		b3.append(i + 1)
		k3 += 1
x = min(k1, k2, k3)
print(x)
for i in range(x):
	print(b1[i], b2[i], b3[i])


n = int(input())
m = [int(i) for i in input().split()]
mm = {}
for (i, value) in enumerate(m):
	if value in mm:
		mm[value][0] += 1
		mm[value][1].append(i + 1)
	else:
		mm[value] = []
		mm[value].append(1)
		mm[value].append([i + 1])
if 1 in mm and 2 in mm and (3 in mm):
	iter = min(mm[1][0], mm[2][0], mm[3][0])
	print(iter)
	for i in range(iter):
		print(mm[1][1][i], mm[2][1][i], mm[3][1][i])
else:
	print(0)


n = int(input())
k = input().split()
a = 0
b = 0
c = 0
A = []
B = []
C = []
for i in range(n):
	if k[i] == '1':
		a += 1
		A.append(i + 1)
	elif k[i] == '2':
		b += 1
		B.append(i + 1)
	else:
		c += 1
		C.append(i + 1)
ans = min(a, b, c)
if ans == 0:
	print(0)
else:
	print(ans)
	for i in range(ans):
		print(A[i], B[i], C[i])


input()
n = list(map(int, input().split(' ')))
m = [[], [], []]
for i in range(len(n)):
	m[n[i] - 1].append(i + 1)
print(min(map(len, m)))
for i in zip(*m):
	print(*i)


n = int(input())
k = [int(x) for x in input().split()]
o0 = []
o1 = []
o2 = []
for i in range(0, n):
	if k[i] == 1:
		o0.append(i + 1)
	elif k[i] == 2:
		o1.append(i + 1)
	else:
		o2.append(i + 1)
l0 = len(o0)
l1 = len(o1)
l2 = len(o2)
j = min(l0, l1, l2)
print(j)
for i in range(0, j):
	print(str(o0[j - i - 1]) + ' ' + str(o1[j - i - 1]) + ' ' + str(o2[j - i - 1]))


n = int(input())
x = list(map(int, input().split()))
j = 0
w = min(x.count(3), x.count(2), x.count(1))
print(w)
for i in range(w + 1):
	if j == 1:
		print(x.index(j) + 1, end=' ')
		x[x.index(j)] = -1
		j += 1
	if j == 2:
		print(x.index(j) + 1, end=' ')
		x[x.index(j)] = -1
		j += 1
	if j == 3:
		print(x.index(j) + 1, end='\n')
		x[x.index(j)] = -1
	j = 1


import os
import sys
from io import BytesIO, IOBase

def solve():
	n = int(input())
	g = list(map(int, input().split()))
	one = g.count(1)
	two = g.count(2)
	thr = g.count(3)
	ans = min(one, two, thr)
	print(ans)
	for i in range(ans):
		cnt = 0
		flag1 = 0
		flag2 = 0
		flag3 = 0
		for j in range(n):
			if g[j] == 1 and flag1 == 0:
				print(j + 1, end=' ')
				flag1 = 1
				g[j] = 0
				cnt = cnt + 1
			elif g[j] == 2 and flag2 == 0:
				print(j + 1, end=' ')
				flag2 = 1
				g[j] = 0
				cnt = cnt + 1
			elif g[j] == 3 and flag3 == 0:
				print(j + 1, end=' ')
				flag3 = 1
				g[j] = 0
				cnt = cnt + 1
			if cnt == 3:
				print()
				break
	return

def main():
	solve()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


a = int(input())
b = list(map(int, input().split()))
d = {1: 0, 2: 0, 3: 0}
for i in b:
	d[i] += 1
print(min(d.values()))
flag = min(d.values())
while flag > 0:
	print(str(b.index(1) + 1) + ' ' + str(b.index(2) + 1) + ' ' + str(b.index(3) + 1))
	b[b.index(1)] = -99
	b[b.index(2)] = -99
	b[b.index(3)] = -99
	flag -= 1


n = int(input())
l = list(map(int, input().split()))
(a, b, c) = (0, 0, 0)
for i in range(len(l)):
	if l[i] == 1:
		a += 1
	if l[i] == 2:
		b += 1
	if l[i] == 3:
		c += 1
t = min(a, min(b, c))
print(t)
while t > 0:
	s = ''
	q = 0
	for i in range(len(l)):
		if l[i] == 1:
			s += str(i + 1) + ' '
			l[i] = 0
			for j in range(len(l)):
				if l[j] == 2:
					s += str(j + 1) + ' '
					l[j] = 0
					for k in range(len(l)):
						if l[k] == 3:
							s += str(k + 1)
							l[k] = 0
							q = 1
							break
					if q == 1:
						break
		if q == 1:
			break
	t -= 1
	print(s)


n = int(input())
t = [[], [], [], []]
for (i, j) in enumerate(input()[::2], 1):
	t[int(j)].append(str(i))
k = min(len(t[1]), len(t[2]), len(t[3]))
print(k)
for q in zip(t[1][:k], t[2][:k], t[3][:k]):
	print(' '.join(q))


n = int(input())
arr = list(map(int, input().split()))
one = arr.count(1)
two = arr.count(2)
three = arr.count(3)
minn = min(one, two, three)
print(minn)
val1 = val2 = val3 = -1
for i in range(minn):
	val1 = arr.index(1, val1 + 1, len(arr))
	val2 = arr.index(2, val2 + 1, len(arr))
	val3 = arr.index(3, val3 + 1, len(arr))
	print(val1 + 1, val2 + 1, val3 + 1)


n = int(input())
student_value = list(map(int, input().split()))
ti1 = []
ti2 = []
ti3 = []
for i in range(0, len(student_value)):
	if student_value[i] == 1:
		ti1.append(i + 1)
	elif student_value[i] == 2:
		ti2.append(i + 1)
	else:
		ti3.append(i + 1)
maxgroups = min(len(ti1), len(ti2), len(ti3))
print(maxgroups)
for i in range(0, maxgroups):
	print(ti1[i], ti2[i], ti3[i])


n = int(input())
l = list(map(int, input().split()))
(a, b, c) = (0, 0, 0)
al = []
bl = []
cl = []
for i in range(0, n):
	if l[i] == 1:
		a = a + 1
		al.append(i + 1)
	elif l[i] == 2:
		b = b + 1
		bl.append(i + 1)
	else:
		c = c + 1
		cl.append(i + 1)
mc = min(a, min(b, c))
print(mc)
for i in range(0, mc):
	print(str(al[i]) + ' ' + str(bl[i]) + ' ' + str(cl[i]))


def inplst():
	return list(map(int, input().split()))

def getindex(l, ind, n, a, b, c):
	for i in range(a + 1, n):
		if l[i] == 1 and i not in ind:
			a = i
			ind.append(i)
			break
	for i in range(b + 1, n):
		if l[i] == 2 and i not in ind:
			b = i
			ind.append(i)
			break
	for i in range(c + 1, n):
		if l[i] == 3 and i not in ind:
			c = i
			ind.append(i)
			break
	return (a, b, c)
n = int(input())
l = inplst()
r = min(l.count(1), l.count(2), l.count(3))
print(r)
ind = list()
(a, b, c) = (-1, -1, -1)
while r != 0:
	(a, b, c) = getindex(l, ind, n, a, b, c)
	r -= 1
	print(a + 1, b + 1, c + 1)


import sys

def f(n, array):
	w = 0
	teams = []
	t1 = []
	t2 = []
	t3 = []
	for (i, a) in enumerate(array):
		if a == 1:
			t1.append(i + 1)
		elif a == 2:
			t2.append(i + 1)
		else:
			t3.append(i + 1)
	n1 = len(t1)
	n2 = len(t2)
	n3 = len(t3)
	w = min(n1, n2, n3)
	for n in range(w):
		teams.append([t1[n], t2[n], t3[n]])
	return (w, teams)
for line in sys.stdin:
	n = int(line)
	array = [int(a) for a in sys.stdin.readline().split()]
	(w, teams) = f(n, array)
	print(w)
	if w > 0:
		for team in teams:
			str_team = [str(t) for t in team]
			print(' '.join(str_team))


def olympiad(t):
	n = len(t)
	g = list()
	g.append(list())
	g.append(list())
	g.append(list())
	for i in range(n):
		g[t[i] - 1].append(i)
	r1 = min(len(g[0]), len(g[1]), len(g[2]))
	r2 = list()
	for i in range(r1):
		r2.append([g[0][i] + 1, g[1][i] + 1, g[2][i] + 1])
	return [r1, r2]
n = int(input().strip())
t = list(map(int, input().strip().split()))
assert len(t) == n
r = olympiad(t)
print(r[0])
for i in range(r[0]):
	print(r[1][i][0], r[1][i][1], r[1][i][2])


from sys import stdin

def solution():
	n = int(stdin.readline().strip())
	ls = [int(x) for x in stdin.readline().strip().split()]
	t = (ls.count(1), ls.count(2), ls.count(3))
	if t[0] == 0 or t[1] == 0 or t[2] == 0:
		return (0, None)
	else:
		m = min(t)
		l1 = list()
		l2 = list()
		l3 = list()
		for (i, x) in enumerate(ls):
			if x == 1:
				l1.append(i + 1)
			elif x == 2:
				l2.append(i + 1)
			else:
				l3.append(i + 1)
		res = list()
		for i in range(0, m):
			res.append([l1[i], l2[i], l3[i]])
	return (m, res)
(count, res) = solution()
if res == None:
	print(count)
else:
	print(count)
	for x in res:
		print('%d %d %d' % (x[0], x[1], x[2]))


n = int(input())
a = input().split()
b = []
for i in a:
	b.append(int(i))
if 3 not in b or 2 not in b or 1 not in b:
	print('0')
	exit()
c = {}
for i in b:
	if i not in c:
		c[i] = 1
	else:
		c[i] += 1
teams = min(c.values())
print(teams)
a1 = []
a2 = []
a3 = []
for i in range(n):
	if b[i] == 1:
		a1.append(i + 1)
	if b[i] == 2:
		a2.append(i + 1)
	if b[i] == 3:
		a3.append(i + 1)
for i in range(teams):
	print('{} {} {}'.format(a1[i], a2[i], a3[i]))


n = int(input())
a = list(map(int, input().split()))
(list1, list2, list3) = ([], [], [])
count = min(a.count(1), a.count(2), a.count(3))
print(count)
for i in range(n):
	if a[i] == 1:
		list1.append(i + 1)
	elif a[i] == 2:
		list2.append(i + 1)
	else:
		list3.append(i + 1)
for i in range(count):
	print(list1[i], list2[i], list3[i])


x = int(input())
s = [int(n) for n in input().split()]
p = s.count(1)
m = s.count(2)
pe = s.count(3)
z = min(p, m, pe)
print(z)
on = []
tw = []
tr = []
for n in range(x):
	if s[n] == 1:
		on.append(n + 1)
	elif s[n] == 2:
		tw.append(n + 1)
	else:
		tr.append(n + 1)
op = []
for n in range(z):
	op.append([on[n], tw[n], tr[n]])

def f(n):
	for k in range(3):
		print(op[n][k], end=' ')
	print('\n')
for n in range(z):
	f(n)


n = int(input())
arr = [int(i) for i in input().split(' ')]
(lst1, lst2, lst3) = ([], [], [])
for i in range(n):
	if arr[i] == 1:
		lst1.append(i + 1)
	if arr[i] == 2:
		lst2.append(i + 1)
	if arr[i] == 3:
		lst3.append(i + 1)
mini_lenth = min(len(lst1), len(lst2), len(lst3))
print(mini_lenth)
if mini_lenth:
	for i in range(mini_lenth):
		print(lst1[i], lst2[i], lst3[i])


l = []
r = []
p = []
n = int(input())
tl = list(input().split())
x = 0
for i in range(n):
	x = int(tl[i])
	if x == 1:
		l.append(i)
	elif x == 2:
		r.append(i)
	else:
		p.append(i)
n = min(len(l), min(len(r), len(p)))
print(n)
for i in range(n):
	print(l[i] + 1, r[i] + 1, p[i] + 1)


from collections import Counter as C
n = int(input())
A = input().split()
k = C(A).most_common()[-1][1]
if not '1' in A or not '2' in A or (not '3' in A):
	print(0)
else:
	print(k)
	for i in range(k):
		print(A.index('1') + 1, A.index('2') + 1, A.index('3') + 1)
		A[A.index('1')] = '0'
		A[A.index('2')] = '0'
		A[A.index('3')] = '0'


n = int(input())
nums = list(map(int, input().split()))
ones = []
twos = []
threes = []
for i in range(n):
	if nums[i] == 1:
		ones.append(i + 1)
	if nums[i] == 2:
		twos.append(i + 1)
	if nums[i] == 3:
		threes.append(i + 1)
ans = min(len(ones), len(twos), len(threes))
print(ans)
for i in range(ans):
	print(ones[i], twos[i], threes[i])


from collections import Counter
n = int(input())
A = [int(i) for i in input().split()]
b = Counter(A)
b = b.values()
if len(b) == 3:
	print(min(b))
	for i in range(min(b)):
		a = [1, 2, 3]
		for j in range(i, n):
			if A[j] in a:
				print(j + 1, end=' ')
				a.remove(A[j])
				A[j] = 0
			elif a == []:
				break
		print()
else:
	print(0)


n = int(input())
arr = list(map(int, input().split()))
p = []
m = []
f = []
for i in range(n):
	if arr[i] == 1:
		p.append(i + 1)
	elif arr[i] == 2:
		m.append(i + 1)
	else:
		f.append(i + 1)
count = 0
teams = []
while p and m and f:
	team = [p.pop(), m.pop(), f.pop()]
	teams.append(team)
	count += 1
print(count)
for t in teams:
	print(*t)


n = int(input())
t = input().split()
d = {'1': [], '2': [], '3': []}
for i in range(n):
	d[t[i]].append(i + 1)
min_length = min(len(d['1']), len(d['2']), len(d['3']))
if min_length == 0:
	print(0)
else:
	print(min_length)
	for i in range(min_length):
		print(d['1'][i], d['2'][i], d['3'][i])


n = int(input(''))
a = input('')
l = list(a.split())
l1 = []
max_list = []
for i in l:
	l1.append(int(i, 10))
for i in range(1, 4):
	max_list.append(l1.count(i))
mm = min(max_list)
print(mm)
c = 1
while c <= mm:
	c = c + 1
	print(l1.index(1) + 1, l1.index(2) + 1, l1.index(3) + 1)
	l1[l1.index(1)] = 0
	l1[l1.index(2)] = 0
	l1[l1.index(3)] = 0


if 1 < 2:
	n = int(input())
	l = list(map(int, input().split()))
	o = []
	t = []
	m = []
	for i in range(n):
		if l[i] == 1:
			o.append(i + 1)
		elif l[i] == 2:
			t.append(i + 1)
		else:
			m.append(i + 1)
	mi = o
	if len(t) < len(o):
		mi = t
		if len(m) < len(t):
			mi = m
	elif len(m) < len(o):
		mi = m
	s = [len(o), len(t), len(m)]
	print(min(s))
	if min(s) != 0:
		for i in range(len(mi)):
			print(o[i], t[i], m[i])


n = int(input())
a = list(map(int, input().split()))
m = min(a.count(1), a.count(2), a.count(3))
if m == 0:
	print(0)
	exit()
print(m)
for i in range(m):
	a1 = a.index(1)
	a2 = a.index(2)
	a3 = a.index(3)
	a[a1] = 0
	a[a2] = 0
	a[a3] = 0
	print(a1 + 1, a2 + 1, a3 + 1)


input()
s = [int(i) for i in input().split()]
t = min(s.count(1), s.count(2), s.count(3))
print(t)
for i in range(t):
	print(s.index(1) + 1, s.index(2) + 1, s.index(3) + 1)
	s[s.index(1)] = s[s.index(2)] = s[s.index(3)] = 0


n = int(input())
t = list(map(int, input().split()))
first = []
second = []
third = []
if len(set(t)) < 3:
	print(0)
else:
	a = t.count(1)
	b = t.count(2)
	c = t.count(3)
	q = min(a, b, c)
	t.insert(0, 0)
	print(min(a, b, c))
	while len(first) != q and len(second) != q and (len(third) != q):
		for i in range(len(t)):
			if t[i] == 1:
				first.append(i)
			if t[i] == 2:
				second.append(i)
			if t[i] == 3:
				third.append(i)
	for i in range(q):
		print(first[i], second[i], third[i])


n = int(input())
k = list(map(int, input().split()))
oi = []
to = []
tho = []
for i in range(n):
	if k[i] == 1:
		oi.append(i + 1)
	if k[i] == 2:
		to.append(i + 1)
	if k[i] == 3:
		tho.append(i + 1)
oi = sorted(oi)
to = sorted(to)
tho = sorted(tho)
if len(oi) == 0 or len(to) == 0 or len(tho) == 0:
	print(0)
else:
	print(min(len(oi), len(to), len(tho)))
	for i in range(min(len(oi), len(to), len(tho))):
		print(oi[i], to[i], tho[i])


n = int(input())
skill = [int(x) for x in input().split()]
pro = skill.count(1)
math = skill.count(2)
PE = skill.count(3)
w = min(pro, math, PE)
print(w)
if w != 0:
	for i in range(w):
		one = skill.index(1)
		two = skill.index(2)
		three = skill.index(3)
		print(one + 1, two + 1, three + 1)
		skill[one] = 0
		skill[two] = 0
		skill[three] = 0


n = int(input())
a = list(map(int, input().split()))
lst = []
a1 = a.count(1)
a2 = a.count(2)
a3 = a.count(3)
lst.append(a1)
lst.append(a2)
lst.append(a3)
x = min(lst)
print(x)
for i in range(x):
	print(a.index(1) + 1, a.index(2) + 1, a.index(3) + 1)
	a[a.index(1)] = 0
	a[a.index(2)] = 0
	a[a.index(3)] = 0


n = int(input())
min_count = float('inf')
talent_dict = {1: [], 2: [], 3: []}
talent_list = map(int, input().split())
j = 1
for i in talent_list:
	talent_dict[i].append(j)
	j += 1
for (key, values) in talent_dict.items():
	if len(values) < min_count:
		min_count = len(values)
print(min_count)
for i in range(min_count):
	for (key, values) in talent_dict.items():
		print(values[i], end=' ')
	print()


n = int(input())
students = list(map(int, input().split()))
a = min(students.count(1), students.count(2), students.count(3))
print(a)
if a != 0:
	uno = []
	dos = []
	tres = []
	for x in range(n):
		if students[x] == 1:
			uno.append(x + 1)
		elif students[x] == 2:
			dos.append(x + 1)
		else:
			tres.append(x + 1)
	for i in range(a):
		print(uno[i], dos[i], tres[i])


u = int(input())
a = [int(x) for x in input().split()]
count1 = count2 = count3 = 0
m = []
n = []
g = []
for i in range(0, u):
	if a[i] == 1:
		count1 += 1
		m.append(i)
	elif a[i] == 2:
		count2 += 1
		n.append(i)
	else:
		count3 += 1
		g.append(i)
w = min(count1, count2, count3)
t = min(len(m), len(n), len(g))
print(w)
for i in range(0, t):
	print(m[i] + 1, n[i] + 1, g[i] + 1, end='\n')


n = input()
s = ''.join(input().split())
(c, i, j, k) = (0, 0, 0, 0)
l = ('1', '2', '3')
ans = []
while True:
	i = s.find('1', i) + 1
	j = s.find('2', j) + 1
	k = s.find('3', k) + 1
	if not i * j * k:
		break
	c += 1
	ans.append(' '.join([str(i), str(j), str(k)]))
if c:
	print(c)
	for y in ans:
		print(y)
else:
	print('0')


n = int(input())
tmp = list(map(int, input().split()))
m = min(tmp.count(1), tmp.count(2), tmp.count(3))
print(m)
if m != 0:
	for i in range(m):
		s = ''
		id_1 = tmp.index(1)
		id_2 = tmp.index(2)
		id_3 = tmp.index(3)
		s += str(id_1 + 1) + ' '
		tmp[id_1] = -1
		s += str(id_2 + 1) + ' '
		tmp[id_2] = -1
		s += str(id_3 + 1)
		tmp[id_3] = -1
		print(s)


n = int(input())
L = [int(x) for x in input().split()]
count = 0
s1 = set()
s2 = set()
s3 = set()
counter = 1
for x in L:
	if x == 1:
		s1.add(counter)
	elif x == 2:
		s2.add(counter)
	else:
		s3.add(counter)
	counter += 1
l1 = len(s1)
l2 = len(s2)
l3 = len(s3)
if l1 == 0 or l2 == 0 or l3 == 0:
	print(0)
else:
	x = min(l1, l2, l3)
	print(x)
	while x > 0:
		x -= 1
		print(s1.pop(), s2.pop(), s3.pop())


a = int(input())
b = list(map(int, input().split()))
x = []
y = []
z = []
j = 0
for i in range(a):
	j += 1
	if b[i] == 3:
		z.append(j)
	elif b[i] == 2:
		y.append(j)
	else:
		x.append(j)
p = [len(x), len(y), len(z)]
p.sort()
if p[0] == 0:
	print(0)
else:
	print(p[0])
	for j in range(p[0]):
		q = [x[j], y[j], z[j]]
		print(*q)


n = int(input())
std = list(map(int, input().split()))
t1 = []
t2 = []
t3 = []
for i in range(len(std)):
	if std[i] == 1:
		t1.append(i + 1)
	elif std[i] == 2:
		t2.append(i + 1)
	elif std[i] == 3:
		t3.append(i + 1)
team = min(len(t1), len(t2), len(t3))
print(team)
if team != 0:
	for i in range(team):
		print(t1[i], t2[i], t3[i])


n = int(input())
st = [int(i) for i in input().split()]
f = []
s = []
t = []
for i in range(n):
	if st[i] == 1:
		f.append(i + 1)
	elif st[i] == 2:
		s.append(i + 1)
	else:
		t.append(i + 1)
m = min(len(f), len(s), len(t))
if m == 0:
	print(0)
else:
	print(m)
	for i in range(m):
		print(f[i], s[i], t[i])


t = int(input())
l = list(map(int, input().split()))
(cnt1, cn2, cnt3) = (0, 0, 0)
a = l.count(1)
b = l.count(2)
c = l.count(3)
lst1 = []
lst2 = []
lst3 = []
res = min(a, min(b, c))
print(res)
i = 0
while i < t:
	if l[i] == 1:
		lst1.append(i + 1)
	if l[i] == 2:
		lst2.append(i + 1)
	if l[i] == 3:
		lst3.append(i + 1)
	i += 1
for i in range(res):
	print(lst1[i], lst2[i], lst3[i])


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


input()
students = [int(x) for x in input().split()]
(t1, t2, t3) = ([], [], [])
for i in range(0, len(students)):
	if students[i] == 1:
		t1.append(i)
	if students[i] == 2:
		t2.append(i)
	if students[i] == 3:
		t3.append(i)
mi = min((len(t1), len(t2), len(t3)))
print(mi)
for i in range(0, mi):
	print(t1[i] + 1, t2[i] + 1, t3[i] + 1)


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

def f(k, t):
	ik = []
	for x in range(n):
		if len(ik) < t:
			if a[x] == k:
				ik.append(x + 1)
	return ik
l = sorted(a)
c1 = l.count(1)
l = l[c1:]
c2 = l.count(2)
c3 = n - (c1 + c2)
t = min(c1, c2, c3)
print(t)
if t != 0:
	i1 = f(1, t)
	i2 = f(2, t)
	i3 = f(3, t)
	for x in range(t):
		print(i1[x], i2[x], i3[x])


n = int(input())
ins = list(input().split())
progs = ins.count('1')
math = ins.count('2')
pe = ins.count('3')
teams = min(progs, math, pe)
print(teams if teams > 0 else 0)
for i in range(teams):
	row = []
	index = ins.index('1')
	row.append(index + 1)
	ins[index] = ''
	index = ins.index('2')
	row.append(index + 1)
	ins[index] = ''
	index = ins.index('3')
	row.append(index + 1)
	ins[index] = ''
	print(' '.join((str(x) for x in row)))


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


n = int(input())
t = [int(x) for x in input().split()]
a = b = c = 0
for i in range(n):
	if t[i] == 1:
		a += 1
	elif t[i] == 2:
		b += 1
	else:
		c += 1
w = min(a, b, c)
print(w)
if w != 0:
	for i in range(1, w + 1):
		q = t.index(1)
		t[q] = 0
		w = t.index(2)
		t[w] = 0
		e = t.index(3)
		t[e] = 0
		print(str(q + 1) + ' ' + str(w + 1) + ' ' + str(e + 1))


n_child = int(input())
take = input().split(' ')
countone = take.count('1')
counttwo = take.count('2')
countthree = take.count('3')
max_teams = min(countone, counttwo, countthree)
print(max_teams)
for i in range(max_teams):
	one = take.index('1')
	two = take.index('2')
	three = take.index('3')
	team = [one, two, three]
	take[one] = ''
	take[two] = ''
	take[three] = ''
	print(one + 1, two + 1, three + 1)


n = int(input())
(a, b, c) = ([], [], [])
i = 1
for x in map(int, input().split()):
	if x == 1:
		a += [i]
	if x == 2:
		b += [i]
	if x == 3:
		c += [i]
	i += 1
print(min(map(len, [a, b, c])))
for (x, y, z) in zip(a, b, c):
	print(x, y, z)


import sys
n = int(sys.stdin.readline())
a = []
b = []
c = []
cnt = 1
for x in sys.stdin.readline().split():
	if x == '1':
		a.append(cnt)
	elif x == '2':
		b.append(cnt)
	else:
		c.append(cnt)
	cnt += 1
x = len(a)
y = len(b)
z = len(c)
print(min(x, y, z))
for i in range(min(x, y, z)):
	print(a[i], b[i], c[i])


n = input('')
list = [int(i) for i in input().split()]
a = list.count(1)
b = list.count(2)
c = list.count(3)
x = min(a, b, c)
print(x)
for i in range(x):
	s1 = list.index(1)
	s2 = list.index(2)
	s3 = list.index(3)
	list[s1] = 0
	list[s2] = 0
	list[s3] = 0
	print(s1 + 1, s2 + 1, s3 + 1)


def teams(li):
	d = {1: [], 2: [], 3: []}
	teams = min(li.count(1), li.count(2), li.count(3))
	print(teams)
	for i in range(len(li)):
		d[li[i]].append(i + 1)
	for i in range(teams):
		print(d[1][i], d[2][i], d[3][i])
	if len(d) < 3:
		print(0)
n = int(input())
li = [int(x) for x in input().split()]
teams(li)


n = int(input())
L = list(map(int, input().split()))
Count1 = []
Count2 = []
Count3 = []
for i in range(n):
	if L[i] == 1:
		Count1.append(i + 1)
	elif L[i] == 2:
		Count2.append(i + 1)
	else:
		Count3.append(i + 1)
k = min(len(Count1), len(Count2), len(Count3))
print(k)
for i in range(k):
	print(Count1[i], Count2[i], Count3[i])


n = int(input())
n_list = list(map(int, input().split()))
(group, group_list) = ([], [])
while all([i in n_list for i in [1, 2, 3]]):
	group = []
	for i in [1, 2, 3]:
		for k in range(len(n_list)):
			if n_list[k] == i:
				n_list[k] = 0
				group.append(k + 1)
				break
	group_list.append(group)
print(len(group_list))
for i in group_list:
	print(' '.join(map(str, i)))


n = int(input())
t = list(map(int, input().split()))
(p, m, e) = (t.count(1), t.count(2), t.count(3))
teams = min(p, m, e)
(p, m, e) = ([], [], [])
for (index, i) in enumerate(t):
	if i == 1 and len(p) < teams:
		p.append(str(index + 1))
	elif i == 2 and len(m) < teams:
		m.append(str(index + 1))
	elif i == 3 and len(e) < teams:
		e.append(str(index + 1))
	elif len(p + m + e) == teams * 3:
		break
print(teams)
for i in range(teams):
	print(p[i], m[i], e[i])


def printlist(a):
	for i in a:
		if i % 3 == 0:
			print('\n')
		print(i, end=' ')
n = int(input())
l = list(map(int, input().split()))
ans = []
l1 = []
l2 = []
l3 = []
for i in range(len(l)):
	if l[i] == 1:
		l1.append(i + 1)
	elif l[i] == 2:
		l2.append(i + 1)
	elif l[i] == 3:
		l3.append(i + 1)
temp = min(len(l1), len(l2), len(l3))
for i in range(temp):
	ans.append(l1[i])
	ans.append(l2[i])
	ans.append(l3[i])
print(temp)
printlist(ans)


n = int(input())
m = 0
p = 0
o = 0
b = []
c = []
d = []
a = input().split(' ')
for i in range(n):
	a[i] = int(a[i])
for i in range(n):
	if a[i] == 1:
		m += 1
		b.append(i)
	if a[i] == 2:
		p += 1
		c.append(i)
	if a[i] == 3:
		o += 1
		d.append(i)
k = min(m, p, o)
print(k)
if k != 0:
	for i in range(k):
		print(b[i] + 1, c[i] + 1, d[i] + 1)


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


t = int(input())
array = [int(i) for i in input().strip().split()]
d = {}
cnt = 0
for i in array:
	if i not in d:
		d[i] = 1
	else:
		d[i] += 1
cnt = min(list(d.values()))
a1 = []
a2 = []
a3 = []
for i in range(t):
	if array[i] == 1:
		a1.append(i + 1)
	if array[i] == 2:
		a2.append(i + 1)
	if array[i] == 3:
		a3.append(i + 1)
if len(a1) == 0 or len(a2) == 0 or len(a3) == 0:
	print(0)
else:
	print(cnt)
	for i in range(cnt):
		print(a1[i], a2[i], a3[i])


n = eval(input())
x = input().split()
a = 0
while a < len(x):
	x[a] = int(x[a])
	a += 1
ones = 0
twos = 0
threes = 0
i = 0
index1 = []
index2 = []
index3 = []
while i < n:
	if x[i] == 1:
		ones += 1
		index1 = index1 + [i + 1]
	elif x[i] == 2:
		twos += 1
		index2 = index2 + [i + 1]
	else:
		threes += 1
		index3 = index3 + [i + 1]
	i = i + 1
j = 0
print(min(ones, twos, threes))
while j < min(len(index1), len(index2), len(index3)):
	print(index1[j], index2[j], index3[j])
	j = j + 1


n = int(input().strip())
ins = input().strip().split(' ')
t1 = []
t2 = []
t3 = []
for i in range(n):
	if int(ins[i]) == 1:
		t1.append(i + 1)
	elif int(ins[i]) == 2:
		t2.append(i + 1)
	else:
		t3.append(i + 1)
max_teams = min(len(t1), len(t2), len(t3))
print(max_teams)
for i in range(max_teams):
	print(t1[i], t2[i], t3[i])


n = int(input())
tmp = list(map(int, input().split()))
m = min(tmp.count(1), tmp.count(2), tmp.count(3))
print(m)
if m != 0:
	prog = []
	math = []
	PE = []
	for e in tmp:
		if e == 1:
			prog.append(tmp.index(e) + 1)
			tmp[tmp.index(e)] = -1
		if e == 2:
			math.append(tmp.index(e) + 1)
			tmp[tmp.index(e)] = -1
		if e == 3:
			PE.append(tmp.index(e) + 1)
			tmp[tmp.index(e)] = -1
	for i in range(m):
		print(str(prog[i]) + ' ' + str(math[i]) + ' ' + str(PE[i]))


n = int(input())
t = list(map(int, input().split()))
lst = []
for i in range(3):
	l = []
	lst += [l]
for i in range(n):
	lst[t[i] - 1] += [i + 1]
mx = min(len(lst[0]), len(lst[1]), len(lst[2]))
print(mx)
for i in range(mx):
	print(lst[0][i], lst[1][i], lst[2][i])


from sys import stdin, stdout, exit
from collections import defaultdict as dd

def Main():
	n = int(stdin.readline().rstrip())
	l = list(map(int, stdin.readline().split()))
	d = dd(list)
	for i in range(len(l)):
		d[l[i]].append(i + 1)
	a = []
	for i in d:
		a.append(len(d[i]))
	m = min(a)
	for i in range(1, 4):
		if len(d[i]) == 0:
			print(0)
			exit()
	print(m)
	for i in range(m):
		for j in d:
			print(str(d[j][i]) + ' ', end='')
		print()
Main()


n = int(input(''))
arr = list(map(int, input().split()))
a = 0
b = 0
c = 0
for i in arr:
	if i == 1:
		a = a + 1
	elif i == 2:
		b = b + 1
	else:
		c = c + 1
print(min(a, b, c))
for i in range(0, min(a, b, c)):
	t = 0
	for j in range(1, 4):
		t = t + 1
		a = arr.index(t)
		arr[a] = 0
		print(a + 1, end=' ')
	print('')


n = int(input())
l = list(map(int, input().split()))
p = []
m = []
e = []
for i in range(n):
	if l[i] == 1:
		p.append(i + 1)
	elif l[i] == 2:
		m.append(i + 1)
	else:
		e.append(i + 1)
x = [len(m), len(e), len(p)]
s = min(x)
print(s)
for j in range(s):
	print(p[j], m[j], e[j])


stud = {1: [], 2: [], 3: []}
int(input())
j = 0
for i in map(int, input().split()):
	j += 1
	stud[i] += [j]
r = min(len(stud[1]), len(stud[2]), len(stud[3]))
print(r)
for i in range(r):
	print(stud[1][i], stud[2][i], stud[3][i])


n = int(input())
l = [int(i) for i in str(input()).split()]
l1 = [(j, i + 1) for (i, j) in enumerate(l) if j == 1]
l2 = [(j, i + 1) for (i, j) in enumerate(l) if j == 2]
l3 = [(j, i + 1) for (i, j) in enumerate(l) if j == 3]
print(min(len(l1), len(l2), len(l3)))
if min(len(l1), len(l2), len(l3)) != 0:
	for i in range(min(len(l1), len(l2), len(l3))):
		print(l1[i][1], l2[i][1], l3[i][1])


n = int(input())
(m, p, s) = ([], [], [])
tt = [int(x) for x in input().split()]
for i in range(n):
	if tt[i] == 1:
		p.append(i + 1)
	elif tt[i] == 2:
		m.append(i + 1)
	else:
		s.append(i + 1)
w = min([len(s), len(m), len(p)])
if w == 0:
	print(0)
else:
	print(w)
	for i in range(w):
		ans = [s[i], m[i], p[i]]
		print(*ans)


input()
a = [[], [], [], []]
for (i, x) in enumerate(map(int, input().split())):
	a[x] += [i + 1]
k = min((len(x) for x in [a[1], a[2], a[3]]))
print(k)
for i in range(k):
	print(a[1][i], a[2][i], a[3][i])


def solve():
	n = int(input())
	list_of_students = [i for i in input().split()]
	one_list = [z + 1 for z in range(len(list_of_students)) if list_of_students[z] == '1']
	two_list = [z + 1 for z in range(len(list_of_students)) if list_of_students[z] == '2']
	three_list = [z + 1 for z in range(len(list_of_students)) if list_of_students[z] == '3']
	first_output = min(len(one_list), len(two_list), len(three_list))
	if first_output == 0:
		print('0')
	else:
		print(first_output)
		for i in range(first_output):
			print(f'{one_list[i]} {two_list[i]} {three_list[i]}')
solve()


one = []
two = []
three = []
n = input()
temp = input()
l = temp.split(' ')
for q in range(int(n)):
	if int(l[q]) == 1:
		one.append(q + 1)
	elif int(l[q]) == 2:
		two.append(q + 1)
	else:
		three.append(q + 1)
temp = min(len(one), min(len(two), len(three)))
print(temp)
for q in range(int(temp)):
	print(str(one[q]) + ' ' + str(two[q]) + ' ' + str(three[q]))


input()
kids = input().replace(' ', '')
teams = 0
results = []
while True:
	if '1' in kids and '2' in kids and ('3' in kids):
		teams += 1
		string_results = str(kids.find('1') + 1) + ' '
		string_results += str(kids.find('2') + 1) + ' '
		string_results += str(kids.find('3') + 1)
		kids = kids.replace('1', '0', 1).replace('2', '0', 1).replace('3', '0', 1)
		results.append(string_results)
	else:
		break
print(teams)
for x in results:
	print(x)


t1 = []
t2 = []
t3 = []
input()
for (i, ti) in enumerate(list(map(int, input().split()))):
	if ti == 1:
		t1.append(i + 1)
	elif ti == 2:
		t2.append(i + 1)
	else:
		t3.append(i + 1)
m = min(len(t1), len(t2), len(t3))
print(m)
for i in range(m):
	print(t1[i], t2[i], t3[i])


input()
a = list(map(int, input().split()))
n = len(a)
a = [[i + 1 for i in range(n) if a[i] == 1], [i + 1 for i in range(n) if a[i] == 2], [i + 1 for i in range(n) if a[i] == 3]]
mn = min(len(a[0]), min(len(a[1]), len(a[2])))
print(mn)
for i in range(mn):
	print(*[a[_][i] for _ in range(3)])


n = int(input())
p = input()
h = p.split()
t = 0
count1 = 0
count2 = 0
count3 = 0
i1 = []
i2 = []
i3 = []
l = 0
for i in h:
	l = l + 1
	t = t + 1
	if i == '1':
		count1 = count1 + 1
		i1.append(l)
	if i == '2':
		count2 = count2 + 1
		i2.append(l)
	if i == '3':
		count3 = count3 + 1
		i3.append(l)
print(min(count1, count2, count3))
g = 0
while g < min(count1, count2, count3):
	print(i1[g], i2[g], i3[g])
	g = g + 1


input()
line = input()
L = [int(s) for s in line.split()]
c = 0
output = list()
while True:
	try:
		first = L.index(1)
		second = L.index(2)
		third = L.index(3)
		L[first] = 0
		L[second] = 0
		L[third] = 0
		output.append(str(first + 1) + ' ' + str(second + 1) + ' ' + str(third + 1))
		c += 1
	except:
		print(c)
		for line in output:
			print(line)
		break


def solve():
	n = int(input())
	p = [int(x) for x in input().split()]
	f = []
	s = []
	t = []
	for (i, x) in enumerate(p):
		if x == 1:
			f.append(i + 1)
		elif x == 2:
			s.append(i + 1)
		else:
			t.append(i + 1)
	t_max = min(min(len(f), len(s)), len(t))
	print(t_max)
	for i in range(0, t_max):
		print(f[i], s[i], t[i])
solve()


t = int(input())
s = list(map(int, input().split()))
(ct1, ct2, ct3) = ([], [], [])
for i in range(len(s)):
	if s[i] == 1:
		ct1.append(i)
	elif s[i] == 2:
		ct2.append(i)
	elif s[i] == 3:
		ct3.append(i)
mini = min(len(ct1), len(ct2), len(ct3))
print(mini)
for i in range(mini):
	print(ct1[i] + 1, ct2[i] + 1, ct3[i] + 1)


input()
a = [[], [], []]
for (i, s) in enumerate(map(int, input().split())):
	a[s - 1].append(i + 1)
print(min((len(a[i]) for i in (0, 1, 2))))
while all((len(a[i]) > 0 for i in (0, 1, 2))):
	print(a[0].pop(), a[1].pop(), a[2].pop())


n = int(input())
T = input()
T = T.replace(' ', '')
t = []
for i in range(0, n):
	t.append(int(T[i]))
t1 = []
t2 = []
t3 = []
for j in range(0, n):
	if t[j] == 1:
		t1.append(j)
	elif t[j] == 2:
		t2.append(j)
	else:
		t3.append(j)
a = min(len(t1), len(t2), len(t3))
print(a)
for i in range(0, a):
	print(str(t1[i] + 1) + ' ' + str(t2[i] + 1) + ' ' + str(t3[i] + 1))


n = int(input())
t = list(map(int, input().split()))
programmer = []
mathematician = []
sportsman = []
for i in range(n):
	if t[i] == 1:
		programmer.append(i + 1)
	elif t[i] == 2:
		mathematician.append(i + 1)
	elif t[i] == 3:
		sportsman.append(i + 1)
lp = len(programmer)
lm = len(mathematician)
ls = len(sportsman)
lmin = min([lp, lm, ls])
if lmin == 0:
	print(0)
else:
	print(lmin)
	for j in range(lmin):
		print(programmer[j], mathematician[j], sportsman[j])


n = int(input())
l = list(map(int, input().split()))
print(min(l.count(1), l.count(2), l.count(3)))
for _ in range(min(l.count(1), l.count(2), l.count(3))):
	print(l.index(1) + 1, ' ', l.index(2) + 1, ' ', l.index(3) + 1)
	l[l.index(1)] = 0
	l[l.index(2)] = 0
	l[l.index(3)] = 0


n = int(input())
l = list(map(int, input().split()))
if n < 3:
	print(0)
else:
	a = []
	b = []
	c = []
	l1 = [0] * (n + 1)
	for i in range(len(l)):
		l1[l[i]] += 1
		if l[i] == 1:
			a.append(i + 1)
		elif l[i] == 2:
			b.append(i + 1)
		else:
			c.append(i + 1)
	(x, y, z) = (l1[1], l1[2], l1[3])
	xx = min(x, y, z)
	print(xx)
	for i in range(xx):
		print(a[i], b[i], c[i])


n = input()
l1 = []
l2 = []
l3 = []
type = input()
type = type.split()
for i in range(0, int(n)):
	t = int(type[i])
	if t == 1:
		l1.append(i + 1)
	elif t == 2:
		l2.append(i + 1)
	else:
		l3.append(i + 1)
print(min(len(l1), len(l2), len(l3)))
for i in range(min(len(l1), len(l2), len(l3))):
	print(l1[i], l2[i], l3[i])


N = int(input())
S = list(map(int, input().split()))
I = [[index + 1 for index in range(N) if S[index] == x] for x in [1, 2, 3]]
C = list(zip(*I))
print(len(C))
for c in C:
	print(' '.join(list(map(str, c))))


n = int(input())
l = list(map(int, input().split()))
map = {}
map[1] = []
map[2] = []
map[3] = []
count = 0
for (i, el) in enumerate(l):
	map[el].append(i + 1)
ln = []
m_l = 50001
for (k, v) in map.items():
	m_l = min(m_l, len(v))
if m_l == 0:
	print(0)
else:
	print(m_l)
	for i in range(m_l):
		print(map[1][i], map[2][i], map[3][i])


t = int(input())
a = map(int, input().split())
a = list(a)
a_1 = []
a_2 = []
a_3 = []
for i in range(t):
	if a[i] == 1:
		a_1.append(i)
	elif a[i] == 2:
		a_2.append(i)
	else:
		a_3.append(i)
d1 = len(a_1)
d2 = len(a_2)
d3 = t - (d1 + d2)
minn = min(d1, d2, d3)
print(minn)
for k in range(minn):
	print(a_1[k] + 1, a_2[k] + 1, a_3[k] + 1)


n = int(input())
L = [int(x) for x in input().split()]
x = L.count(1)
y = L.count(2)
z = L.count(3)
t = min(x, y, z)
print(t)
for i in range(t):
	m = L.index(1)
	n = L.index(2)
	p = L.index(3)
	print(m + 1, n + 1, p + 1)
	L[m] = 4
	L[n] = 4
	L[p] = 4


n = int(input())
a = list(map(int, input().split()))
b = sorted(a)
if len(list(set(b))) < 3:
	print(0)
else:
	x = []
	y = []
	z = []
	for i in range(n):
		if a[i] == 1:
			x.append(i + 1)
		elif a[i] == 2:
			y.append(i + 1)
		else:
			z.append(i + 1)
	c = min(len(x), len(y), len(z))
	print(c)
	for i in range(c):
		print(x[i], y[i], z[i])


n = int(input())
(o, t, th) = (0, 0, 0)
(ol, tl, thl) = ([], [], [])
l = list(map(int, input().split()))
for i in range(len(l)):
	if l[i] == 1:
		o += 1
		ol.append(i)
	elif l[i] == 2:
		t += 1
		tl.append(i)
	elif l[i] == 3:
		th += 1
		thl.append(i)
	else:
		continue
p = min(o, t, th)
print(min(o, t, th))
for i in range(p):
	print(ol[i] + 1, tl[i] + 1, thl[i] + 1)


n = int(input())
l = list(map(int, input().split()))
h = min(l.count(1), min(l.count(2), l.count(3)))
print(h)
if h > 0:
	a = []
	b = []
	ab = []
	for i in range(len(l)):
		if l[i] == 1:
			a.append(i + 1)
		elif l[i] == 2:
			b.append(i + 1)
		else:
			ab.append(i + 1)
	for i in range(h):
		print(a[i], b[i], ab[i])


n = int(input())
array = list(map(int, input().split()))
array_1 = []
array_2 = []
array_3 = []
count = min(array.count(1), array.count(2), array.count(3))
for i in range(len(array)):
	if array[i] == 1:
		array_1.append(i)
	elif array[i] == 2:
		array_2.append(i)
	elif array[i] == 3:
		array_3.append(i)
print(count)
for i in range(count):
	print(array_1[i] + 1, array_2[i] + 1, array_3[i] + 1)


from itertools import *

def main(n, t):
	a = list(filter(lambda x: x[0] == 0, t))
	b = list(filter(lambda x: x[0] == 1, t))
	c = list(filter(lambda x: x[0] == 2, t))
	print(min(len(a), len(b), len(c)))
	for x in zip(a, b, c):
		print(x[0][1], x[1][1], x[2][1])

def main_input(info=0):
	n = int(input())
	t = [(int(x) - 1, i + 1) for (i, x) in enumerate(input().split())]
	main(n, t)
main_input()


n = int(input())
ls = list(map(int, input().split()))
ls = [(i + 1, ls[i]) for i in range(len(ls))]
ls.sort(key=lambda x: x[1])
ls1 = []
ls2 = []
ls3 = []
i = 0
try:
	while ls[i][1] == 1:
		ls1.append(ls[i][0])
		i += 1
	while ls[i][1] == 2:
		ls2.append(ls[i][0])
		i += 1
	while ls[i][1] == 3:
		ls3.append(ls[i][0])
		i += 1
except:
	pass
ans = min(map(len, [ls1, ls2, ls3]))
print(ans)
for i in range(ans):
	print(ls1[i], ls2[i], ls3[i])


n = int(input())
sp = list(map(int, input().split()))
one = sp.count(1)
two = sp.count(2)
three = sp.count(3)
team = min(one, two, three)
if one != 0 or two != 0 or three != 0:
	print(team)
	for i in range(team):
		print(sp.index(1) + 1, sp.index(2) + 1, sp.index(3) + 1)
		sp.insert(sp.index(1), 0)
		sp.remove(1)
		sp.insert(sp.index(2), 0)
		sp.remove(2)
		sp.insert(sp.index(3), 0)
		sp.remove(3)
else:
	print(0)


a = input()
b = list(map(int, input().split()))
result = min(b.count(1), b.count(2), b.count(3))
print(result)
for i in range(result):
	(c, d, e) = (b.index(1), b.index(2), b.index(3))
	(b[c], b[d], b[e]) = (4, 4, 4)
	print(c + 1, d + 1, e + 1)


n = int(input())
l = [int(i) for i in input().split()]
(x, y, z) = ([], [], [])
for i in range(n):
	if l[i] == 1:
		x.append(i + 1)
	elif l[i] == 2:
		y.append(i + 1)
	else:
		z.append(i + 1)
(q, w, e) = (len(x), len(y), len(z))
k = min(q, w, e)
print(k)
for i in range(k):
	print(x[i], y[i], z[i])


n = int(input())
l = list(map(int, input().split()))
a = b = c = -1
m = min(l.count(1), l.count(2), l.count(3))
print(m)
for i in range(m):
	a = l.index(1, a + 1, n)
	print(a + 1, end=' ')
	b = l.index(2, b + 1, n)
	print(b + 1, end=' ')
	c = l.index(3, c + 1, n)
	print(c + 1, end=' ')
	print()


x = int(input())
y = input().split()
a = 0
b = 0
c = 0
lst1 = []
lst2 = []
lst3 = []
for i in range(x):
	if y[i] == '1':
		a += 1
		lst1.append(i + 1)
	elif y[i] == '2':
		b += 1
		lst2.append(i + 1)
	else:
		c += 1
		lst3.append(i + 1)
lst = [a, b, c]
lst.sort()
print(lst[0])
for j in range(lst[0]):
	print(lst1[j], lst2[j], lst3[j])


n = int(input())
a = list(map(int, input().split()))
a1 = a.count(1)
a2 = a.count(2)
a3 = a.count(3)
a11 = list()
a22 = list()
a33 = list()
i = 0
while i < len(a):
	if a[i] == 1:
		a11.append(i + 1)
	elif a[i] == 2:
		a22.append(i + 1)
	elif a[i] == 3:
		a33.append(i + 1)
	i = i + 1
m = min(a1, a2, a3)
d = dict()
print(m)
if m != 0:
	for i in range(m):
		print(a11[i], a22[i], a33[i])


n = int(input())
l = list(map(int, input().split()))
l1 = []
l2 = []
l3 = []
for f in range(n):
	if l[f] == 1:
		l1.append(f + 1)
	if l[f] == 2:
		l2.append(f + 1)
	if l[f] == 3:
		l3.append(f + 1)
print(min(len(l1), len(l2), len(l3)))
for f in range(min(len(l1), len(l2), len(l3))):
	print(l1[f], l2[f], l3[f])


n = int(input())
students = list(map(int, input().split()))
(programmer, mathematician, sportsman) = ([], [], [])
count_teams = min(students.count(1), students.count(2), students.count(3))
if count_teams == 0:
	print(count_teams)
else:
	for i in range(n):
		if students[i] == 1:
			programmer.append(i + 1)
		elif students[i] == 2:
			mathematician.append(i + 1)
		else:
			sportsman.append(i + 1)
	print(count_teams)
	for i in range(count_teams):
		print(programmer[i], mathematician[i], sportsman[i])


n = int(input())
a = list(map(int, input().split()))
m = min(a.count(1), a.count(2), a.count(3))
print(m)
b = [-1] * 3
for j in range(m):
	for i in range(b[-3] + 1, n):
		if a[i] == 1:
			print(i + 1, end=' ')
			b.append(i)
			break
	for i in range(b[-3] + 1, n):
		if a[i] == 2:
			print(i + 1, end=' ')
			b.append(i)
			break
	for i in range(b[-3] + 1, n):
		if a[i] == 3:
			print(i + 1)
			b.append(i)
			break


N = int(input())
L = [int(x) for x in input().split()]
ListOne = []
ListTwo = []
ListThree = []
for i in range(len(L)):
	if L[i] == 1:
		ListOne.append(i + 1)
	elif L[i] == 2:
		ListTwo.append(i + 1)
	else:
		ListThree.append(i + 1)
NoOfTeams = min(len(ListOne), len(ListTwo), len(ListThree))
Teams = []
for i in range(NoOfTeams):
	Teams.append([ListOne[i], ListTwo[i], ListThree[i]])
if NoOfTeams == 0:
	print(NoOfTeams)
else:
	print(NoOfTeams)
	for i in Teams:
		print(*i)


import math
n = int(input())
arr = input().split()
la = []
lb = []
lc = []
a = b = c = 0
for i in range(n):
	ch = arr[i]
	if ch == '1':
		a += 1
		la.append(str(i + 1))
	elif ch == '2':
		b += 1
		lb.append(str(i + 1))
	else:
		c += 1
		lc.append(str(i + 1))
n = min(a, b, c)
print(str(n))
for i in range(n):
	print(la[i] + ' ' + lb[i] + ' ' + lc[i])


n = int(input())
l = [int(x) for x in input().split(' ')]
l1 = []
a = l.count(1)
b = l.count(2)
c = l.count(3)
l1.append(a)
l1.append(b)
l1.append(c)
m = min(l1)
print(m)
for i in range(m):
	print(l.index(1) + 1, l.index(2) + 1, l.index(3) + 1, sep=' ', end=' ')
	l[l.index(1)] = 0
	l[l.index(2)] = 0
	l[l.index(3)] = 0
	print()


n1 = input()
n = list(map(int, input().split()))
(progr, matem, fizra) = ([], [], [])
for i in range(len(n)):
	if n[i] % 3 == 1:
		progr.append(i + 1)
	elif n[i] % 3 == 2:
		matem.append(i + 1)
	else:
		fizra.append(i + 1)
command = min(len(progr), len(matem), len(fizra))
print(command)
for i in range(command):
	print(progr.pop(), matem.pop(), fizra.pop())


n = int(input())
arr = input().split()
for i in range(len(arr)):
	arr[i] = int(arr[i])
count = [0, 0, 0]
indexes = [[], [], []]
for (index, i) in enumerate(arr):
	count[i - 1] += 1
	indexes[i - 1].append(index + 1)
possible = min(count)
print(possible)
for i in range(possible):
	print(indexes[0][i], indexes[1][i], indexes[2][i])


input()
w = list(input().split())
if len(set(w)) != 3:
	print(0)
else:
	w1 = [str(idx + 1) for (idx, val) in enumerate(w) if val == '1']
	w2 = [str(idx + 1) for (idx, val) in enumerate(w) if val == '2']
	w3 = [str(idx + 1) for (idx, val) in enumerate(w) if val == '3']
	zipped = zip(w1, w2, w3)
	print(min(len(w1), len(w2), len(w3)))
	for i in zipped:
		print(' '.join(i))


def solve(n, s):
	d = {}
	for j in range(n):
		if s[j] not in d:
			d[s[j]] = list()
		d[s[j]].append(j + 1)
	if len(d) < 3:
		print(0)
		return None
	else:
		m = min([len(d[j]) for j in d])
		print(m)
		for i in range(m):
			ans = [str(d[j][i]) for j in d]
			print(' '.join(ans))
n = int(input())
s = list(map(int, input().split()))
solve(n, s)


def findMaxTeams(students):
	teams = 0
	threes = []
	twos = []
	ones = []
	index = 1
	teamsIndex = []
	for student in students:
		if int(student) == 1:
			ones.append([int(student), index])
		if int(student) == 2:
			twos.append([int(student), index])
		if int(student) == 3:
			threes.append([int(student), index])
		index += 1
	minCategory = min(len(ones), len(twos), len(threes))
	for i in range(minCategory):
		if len(ones) != 0:
			if len(threes) != 0:
				if len(twos) != 0:
					teamsIndex.append([ones[0][1], twos[0][1], threes[0][1]])
					ones.pop(0)
					twos.pop(0)
					threes.pop(0)
					teams += 1
	return [teams, teamsIndex]
nums = int(input())
listOfInputs = input().split()
packet = findMaxTeams(listOfInputs)
print(packet[0])
for i in range(int(packet[0])):
	for j in packet[1][i]:
		if j == len(packet[1][i]) - 1:
			print(j)
			continue
		print(j, end=' ')


n = int(input())
t = [int(s) for s in input().split(' ')]
w = min([t.count(j) for j in range(1, 4)])
indexes = [[i + 1 for (i, x) in enumerate(t) if x == j] for j in range(1, 4)]
print(w)
for team in range(w):
	ind = [indexes[j][team] for j in range(3)]
	print(' '.join([str(a) for a in ind]))


n = int(input())
inp = input().split()
d = dict()
for index in range(len(inp)):
	if inp[index] not in d:
		d[inp[index]] = [1]
		d[inp[index]].append(index + 1)
	else:
		d[inp[index]][0] += 1
		d[inp[index]].append(index + 1)
l = list(d.values())
if len(l) != 3:
	print('0')
else:
	o = l.copy()
	t = [o[0][0], o[1][0], o[2][0]]
	w = min(t)
	print(w)
	ind = t.index(w)
	lis = []
	for index in range(1, len(o[ind])):
		lis.extend([str(o[0][index]), str(o[1][index]), str(o[2][index])])
		print(' '.join(lis))
		lis = []


n = int(input())
students = [[], [], [], []]
student = [int(i) for i in input().split()]
for i in range(n):
	students[student[i]].append(i + 1)
teams = min(len(students[1]), len(students[2]), len(students[3]))
print(teams)
for i in range(teams):
	print(students[1][i], students[2][i], students[3][i])


n = int(input())
children = [int(x) for x in input().split()]
minimum = min(children.count(1), children.count(2), children.count(3))
print(minimum)
i = 0
while i < minimum:
	print(children.index(1) + 1, children.index(2) + 1, children.index(3) + 1)
	children[children.index(1)] = 4
	children[children.index(2)] = 4
	children[children.index(3)] = 4
	i += 1


n = int(input())
l = list(map(int, input().split()))
pgr = []
math = []
pe = []
for i in range(n):
	if l[i] == 1:
		pgr.append(i + 1)
	elif l[i] == 2:
		math.append(i + 1)
	else:
		pe.append(i + 1)
(s, seta, setb, setc) = (set(), set(), set(), set())
ans = min(len(pgr), len(math), len(pe))
print(ans)
for i in range(ans):
	print(pgr[i], math[i], pe[i])


t = int(input())
n = list(map(int, input().split()))
(a, b, c) = (n.count(1), n.count(2), n.count(3))
final = min(min(a, b), min(b, c))
print(final)
(one, two, three) = ([], [], [])
for (i, j) in enumerate(n):
	if j == 1:
		one.append(i + 1)
	elif j == 2:
		two.append(i + 1)
	elif j == 3:
		three.append(i + 1)
for inx in range(final):
	print(one[inx], two[inx], end=' ')
	print(three[inx])


import math
e = end = ' '
a = []
b = []
c = []
n = int(input())
s = input().split()
t = int(1)
for i in s:
	x = int(i)
	if x == 1:
		a.append(t)
	elif x == 2:
		b.append(t)
	else:
		c.append(t)
	t += 1
f = int(min(min(len(a), len(b)), len(c)))
print(f)
for i in range(f):
	print(a.pop(), e, b.pop(), e, c.pop())


n = int(input())
l = [int(x) for x in input().split()]
s = set(l)
l1 = []
if len(s) == 3:
	for i in s:
		l1.append(l.count(i))
	print(min(l1))
	for j in range(min(l1)):
		for i in s:
			print(l.index(i) + 1, end=' ')
			l[l.index(i)] = '*'
		if j < min(l1) - 1:
			print()
else:
	print(0)


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])))


import sys
students = int(sys.stdin.readline())
tendencies = sys.stdin.readline().strip().split()
groupBySkills = [[], [], []]
for student_pos in range(students):
	student_tendency = int(tendencies[student_pos])
	groupBySkills[student_tendency - 1].append(student_pos + 1)
maxTeams = min(len(groupBySkills[0]), len(groupBySkills[1]), len(groupBySkills[2]))
print(maxTeams)
for team in range(maxTeams):
	print(groupBySkills[0][team], groupBySkills[1][team], groupBySkills[2][team])


n = int(input())
a = list(map(int, input().split()))
p = []
q = []
r = []
for i in range(n):
	if a[i] == 1:
		p.append(i + 1)
	elif a[i] == 2:
		q.append(i + 1)
	else:
		r.append(i + 1)
w = min([len(p), len(q), len(r)])
print(w)
if w != 0:
	for i in range(w):
		print(str(p[i]) + ' ' + str(q[i]) + ' ' + str(r[i]))


x = int(input())
y = input().split()
team = min(y.count('1'), y.count('2'), y.count('3'))
print(team)
for i in range(team):
	a = y.index('1')
	b = y.index('2')
	c = y.index('3')
	print(a + 1, b + 1, c + 1)
	(y[a], y[b], y[c]) = (0, 0, 0)


pocet = int(input())
deti = list(map(int, input().split()))
teams = []
ts = [[], [], []]
for (i, dieta) in enumerate(deti):
	ts[dieta - 1].append(i + 1)
maxi = min(map(len, ts))
print(maxi)
for team in range(maxi):
	print(' '.join([str(ts[i][team]) for i in range(len(ts))]))


import functools
n = int(input())
lis = list(map(int, input().split()))
prog = set()
maths = set()
phy = set()
for i in range(len(lis)):
	if lis[i] == 1:
		prog.add(i + 1)
	elif lis[i] == 2:
		maths.add(i + 1)
	else:
		phy.add(i + 1)
val = functools.reduce(lambda x, y: x if x < y else y, [len(prog), len(maths), len(phy)])
if val == 0:
	print(0)
else:
	print(val)
	for i in range(val):
		print(str(prog.pop()) + ' ' + str(maths.pop()) + ' ' + str(phy.pop()))


l = int(input())
s = input().split()
one = s.count('1')
two = s.count('2')
thr = s.count('3')
j = [one, two, thr]
f = min(j)
o = []
tw = []
th = []
b = 0
while b < l:
	if s[b] == '1':
		o.append(b + 1)
	elif s[b] == '2':
		tw.append(b + 1)
	else:
		th.append(b + 1)
	b = b + 1
print(f)
for i in range(f):
	h = str(o[i]) + ' ' + str(tw[i]) + ' ' + str(th[i])
	print(h)


a = input()
b = [int(d) for d in input().split()]
c = min(b.count(1), b.count(2), b.count(3))
print(c)
for i in range(c):
	print(b.index(1) + 1, b.index(2) + 1, b.index(3) + 1)
	b[b.index(1)] = 0
	b[b.index(2)] = 0
	b[b.index(3)] = 0


ones = list()
twos = list()
threes = list()
teams = 0
n = int(input())
l = list(map(int, input().split()))
for i in range(0, len(l)):
	if l[i] == 1:
		ones.append(i + 1)
	elif l[i] == 2:
		twos.append(i + 1)
	else:
		threes.append(i + 1)
teams = min(len(ones), len(twos), len(threes))
if teams < 1:
	print(0)
else:
	print(teams)
	for i in range(0, teams):
		print(ones[i], ' ', twos[i], ' ', threes[i])


n = int(input())
l = list(map(int, input().split()))
i1 = []
i2 = []
i3 = []
for i in range(n):
	if l[i] == 1:
		i1.append(i + 1)
	elif l[i] == 2:
		i2.append(i + 1)
	else:
		i3.append(i + 1)
c = min(len(i1), len(i2), len(i3))
print(c)
for i in range(c):
	print(i1[i], i2[i], i3[i])


kids = input()
inp = list(map(int, input().rstrip().split()))
teams = min(inp.count(1), inp.count(2), inp.count(3))
list_teams = []

def form_team(inp):
	temp = ''
	temp += str(inp.index(1) + 1) + ' '
	inp[inp.index(1)] = 0
	temp += str(inp.index(2) + 1) + ' '
	inp[inp.index(2)] = 0
	temp += str(inp.index(3) + 1) + ' '
	inp[inp.index(3)] = 0
	return temp
for i in range(0, teams):
	t = form_team(inp)
	list_teams.append(t)
print(teams)
for i in list_teams:
	print(i)


n = int(input())
entrance = input().split(' ')
cont = min(entrance.count('1'), entrance.count('2'))
cont = entrance.count('3') if entrance.count('3') < cont else cont
print(cont)
while entrance.count('1') >= 1 and entrance.count('2') >= 1 and (entrance.count('3') >= 1):
	print(str(entrance.index('1') + 1) + ' ' + str(entrance.index('2') + 1) + ' ' + str(entrance.index('3') + 1))
	entrance[entrance.index('1')] = '0'
	entrance[entrance.index('2')] = '0'
	entrance[entrance.index('3')] = '0'


le = int(input())
li = list(map(int, input().split()))
lj = [li.count(1), li.count(2), li.count(3)]
l = min(lj)
print(l)
while l:
	lx = []
	for x in range(1, 4):
		ind = li.index(x)
		lx.append(ind + 1)
		li[ind] = -99
	print(*lx)
	l -= 1


count_student = int(input())
D = {'1': [], '2': [], '3': []}
type = [str(a) for a in input().strip().split(' ')]
for index in range(count_student):
	if type[index] == '1':
		D['1'].append(index)
	elif type[index] == '2':
		D['2'].append(index)
	else:
		D['3'].append(index)
maxx = min(map(len, (D['1'], D['2'], D['3'])))
print(maxx)
for i in range(maxx):
	print(D['1'][i] + 1, D['2'][i] + 1, D['3'][i] + 1)


import math
from fractions import Fraction as frac
MOD = 1000000000.0 + 7

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def no():
	print('NO')
	return

def yes():
	print('YES')
	return

def solve(case_no):
	n = int(input())
	cnt = [[] for i in range(4)]
	a = list(map(int, input().split()))
	for i in range(n):
		cnt[a[i]].append(i + 1)
	print(min(len(cnt[1]), len(cnt[2]), len(cnt[3])))
	for i in range(min(len(cnt[1]), len(cnt[2]), len(cnt[3]))):
		print(cnt[1][i], cnt[2][i], cnt[3][i])
t = 1
for i in range(1, t + 1):
	solve(i)


n = int(input())
stds = list(map(int, input().split()))
t1 = []
t2 = []
t3 = []
for i in range(len(stds)):
	if stds[i] == 1:
		t1.append(i + 1)
	elif stds[i] == 2:
		t2.append(i + 1)
	else:
		t3.append(i + 1)
max_teams = min(len(t1), len(t2), len(t3))
print(max_teams)
if not max_teams == 0:
	for i in range(max_teams):
		print(t1[i], t2[i], t3[i])


a = int(input())
b1 = input().split()
b = []
for x in b1:
	b += [int(x)]
p = b.count(1)
m = b.count(2)
f = b.count(3)
d = min(p, m, f)
print(d)
K = [[], [], []]
for i in range(a):
	K[b[i] - 1] += [i + 1]
if d != 0:
	for i in range(d):
		print(K[0][i], K[1][i], K[2][i])


n = int(input())
s = list(map(int, input().split()))
w = min(s.count(1), s.count(2), s.count(3))
print(w)
if w != 0:
	for i in range(w):
		t1 = s.index(1)
		s[t1] = 0
		t2 = s.index(2)
		s[t2] = 0
		t3 = s.index(3)
		s[t3] = 0
		print(t1 + 1, t2 + 1, t3 + 1)


n = int(input())
a = input().split(' ')
a = [int(i) for i in a]
total_teams = n // 3
result = []
for i in range(total_teams):
	if 1 in a and 2 in a and (3 in a):
		index1 = a.index(1)
		a[index1] = 0
		index2 = a.index(2)
		a[index2] = 0
		index3 = a.index(3)
		a[index3] = 0
		result.append('' + str(index1 + 1) + ' ' + str(index2 + 1) + ' ' + str(index3 + 1))
len_result = len(result)
print(len_result)
if len_result > 0:
	[print(i) for i in result]


n = int(input())
t = list(map(int, input().split()))
t2 = list(enumerate(t))
programmers = [x[0] + 1 for x in t2 if x[1] == 1]
math = [x[0] + 1 for x in t2 if x[1] == 2]
pe = [x[0] + 1 for x in t2 if x[1] == 3]
w = min(len(programmers), len(math), len(pe))
print(w)
for i in range(w):
	print(programmers[i], math[i], pe[i])


n = int(input())
t = list(map(int, input().split()))
p = [[], [], [], []]
for i in range(n):
	p[t[i]].append(i + 1)
w = int(min(len(p[1]), len(p[2]), len(p[3])))
if w == 0:
	print(0)
else:
	print(w)
	for i in range(w):
		print(str(p[1][i]) + ' ' + str(p[2][i]) + ' ' + str(p[3][i]))


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())
t = list(map(int, input().split()))
if n == 1 or n == 2:
	print(0)
else:
	one = t.count(1)
	two = t.count(2)
	three = t.count(3)
	team = min(one, two, three)
	print(team)
	for i in range(team):
		r1 = t.index(1)
		r2 = t.index(2)
		r3 = t.index(3)
		print(r1 + 1, r2 + 1, r3 + 1)
		t[r1] = 4
		t[r2] = 4
		t[r3] = 4


n = int(input())
t = [int(i) for i in input().split()]
skills = [1, 2, 3]
grp_by_skill = []
for s in skills:
	grp_by_skill.append([i + 1 for i in range(n) if t[i] == s])
c = min([len(g) for g in grp_by_skill])
print(c)
if c > 0:
	for i in range(c):
		print(f'{grp_by_skill[0][i]} {grp_by_skill[1][i]} {grp_by_skill[2][i]}')


n = int(input())
ls = [int(x) for x in input().split()]
arr = [[0] * n for _ in range(3)]
for i in range(n):
	arr[ls[i] - 1][i] = 1
teams = []
while True:
	if 1 in arr[0] and 1 in arr[1] and (1 in arr[2]):
		ind1 = arr[0].index(1)
		arr[0][ind1] = 0
		ind2 = arr[1].index(1)
		arr[1][ind2] = 0
		ind3 = arr[2].index(1)
		arr[2][ind3] = 0
		team = [ind1 + 1, ind2 + 1, ind3 + 1]
		teams.append(team)
	else:
		break
print(len(teams))
for team in teams:
	for i in team:
		print(i, end=' ')
	print()


n = int(input())
students = [int(x) for x in input().split()]
index1 = []
index2 = []
index3 = []
one = two = three = 0
for i in range(0, len(students)):
	if students[i] == 1:
		one = one + 1
		index1.append(i + 1)
	elif students[i] == 2:
		two = two + 1
		index2.append(i + 1)
	elif students[i] == 3:
		three = three + 1
		index3.append(i + 1)
lenn = [len(index1), len(index2), len(index3)]
lenn.sort()
print(lenn[0])
if lenn[0] == 0:
	lenn = lenn
else:
	for i in range(0, lenn[0]):
		output = []
		print(index1[i], index2[i], index3[i])


def teams(n, x):
	c = {}
	counter = 0
	for i in range(0, n):
		if x[i] in c:
			c[x[i]] += [i]
		else:
			c[x[i]] = [i]
	if len(c.keys()) < 3:
		print(0)
		return
	for i in c:
		if len(c[i]) == 0:
			print(0)
			return
		if counter == 0:
			counter = len(c[i])
		counter = min(counter, len(c[i]))
	print(counter)
	while counter > 0:
		for i in c:
			print(c[i].pop() + 1, end=' ')
		print('')
		counter = counter - 1
	return
n = int(input())
x = [int(x) for x in input().split()]
teams(n, x)


i = int(input())
people = list(map(int, input().split()))
n_l = []
for __ in range(i // 3):
	tmp = []
	for _ in range(1, 4):
		if _ in people:
			ind = people.index(_)
			tmp.append(ind + 1)
			people[ind] = 0
		else:
			break
	if len(tmp) == 3:
		n_l.append(tmp)
print(len(n_l))
for _ in n_l:
	print(' '.join(map(str, _)))


import sys
from sys import stdin, stdout
import bisect
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
from collections import Counter
import collections
import math
import heapq
import re

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def most_frequent(list):
	return max(set(list), key=list.count)

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def Convert(string):
	li = list(string.split(''))
	return li

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
prime = []
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j

def leastFrequent(arr, n):
	Hash = dict()
	for i in range(n):
		if arr[i] in Hash.keys():
			Hash[arr[i]] += 1
		else:
			Hash[arr[i]] = 1
	min_count = n + 1
	res = -1
	for i in Hash:
		if min_count >= Hash[i]:
			res = i
			min_count = Hash[i]
	return min_count

def main():
	n = inin()
	a = ain()
	b = set(a)
	if len(b) < 3:
		print(0)
	else:
		temp = leastFrequent(a, n)
		print(temp)
		for i in range(temp):
			print(a.index(1) + 1, end=' ')
			print(a.index(2) + 1, end=' ')
			print(a.index(3) + 1)
			a[a.index(1)] = 0
			a[a.index(2)] = 0
			a[a.index(3)] = 0
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


test = int(input())
skills = list(map(int, input().split()))
programming_skill = skills.count(1)
math_skill = skills.count(2)
physics_skill = skills.count(3)
res = ''
teams = 0
if programming_skill == 0 or math_skill == 0 or physics_skill == 0:
	print('0')
	exit()
else:
	teams = min(programming_skill, math_skill, physics_skill)
	res += str(teams) + '\n'
student_of_programming = []
student_of_math = []
student_of_physics = []
for i in range(test):
	if skills[i] == 1:
		student_of_programming.append(i + 1)
	elif skills[i] == 2:
		student_of_math.append(i + 1)
	else:
		student_of_physics.append(i + 1)
student_of_programming = student_of_programming[len(student_of_programming) - teams:]
student_of_math = student_of_math[len(student_of_math) - teams:]
student_of_physics = student_of_physics[len(student_of_math) - teams:]
for i in range(teams):
	res += str(student_of_programming[i]) + ' ' + str(student_of_math[i]) + ' ' + str(student_of_physics[i]) + '\n'
print(res, end='')


z = input
mod = 10 ** 9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)
for _ in range(1):
	x = int(z())
	l = list(map(int, z().split()))
	one = []
	tw = []
	th = []
	o = 0
	t = 0
	te = 0
	for i in range(x):
		if l[i] == 1:
			one.append(i + 1)
			o += 1
		if l[i] == 2:
			tw.append(i + 1)
			t += 1
		if l[i] == 3:
			th.append(i + 1)
			te += 1
	p = min(o, t, te)
	print(p)
	for i in range(p):
		print(one[i], tw[i], th[i])


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
n = int(input())
arr = get_array()
dic = {1: 0, 2: 0, 3: 0}
one = []
two = []
three = []
for (idx, i) in enumerate(arr):
	dic[i] += 1
	if i == 1:
		one.append(idx + 1)
	elif i == 2:
		two.append(idx + 1)
	else:
		three.append(idx + 1)
c = min(dic[1], dic[2], dic[3])
print(c)
for i in range(0, c):
	print(one[i], two[i], three[i])


def team(n, children):
	(arr1, arr2, arr3) = ([], [], [])
	for i in range(n):
		if children[i] == 1:
			arr1.append(i + 1)
		elif children[i] == 2:
			arr2.append(i + 1)
		else:
			arr3.append(i + 1)
	print(min(len(arr1), len(arr2), len(arr3)))
	while all((arr1, arr2, arr3)):
		print(arr1.pop(0), arr2.pop(0), arr3.pop(0))
n = int(input())
children = list(map(int, input().split()))
team(n, children)


l = []
n = int(input())
l = input().split(' ')
l = [int(i) for i in l]
(l1, l2, l3) = ([], [], [])
for i in range(0, len(l)):
	if l[i] == 1:
		l1.append(i)
	elif l[i] == 2:
		l2.append(i)
	else:
		l3.append(i)
re = min(len(l1), len(l2), len(l3))
if re == 0:
	print('0')
else:
	print(re)
	while re:
		print(l1[re - 1] + 1, l2[re - 1] + 1, l3[re - 1] + 1)
		re = re - 1


n = int(input())
students = input().split()
pro = students.count('1')
math = students.count('2')
pe = students.count('3')
pro = math = pe = min(pro, math, pe)
if pro == 0 or math == 0 or pe == 0:
	print(0)
elif pro == math == pe:
	print(pro)
	for i in range(pro):
		print(students.index('1') + 1, students.index('2') + 1, students.index('3') + 1)
		students.insert(students.index('1'), '0')
		students.remove('1')
		students.insert(students.index('2'), '0')
		students.remove('2')
		students.insert(students.index('3'), '0')
		students.remove('3')


from sys import stdin
n = int(input())
t = list(map(int, stdin.readline().split()))
a = []
b = []
c = []
p = t.count(1)
m = t.count(2)
pe = t.count(3)
if min(p, m, pe) == 0:
	print(0)
else:
	for i in range(len(t)):
		if t[i] == 1:
			a.append(i + 1)
		elif t[i] == 2:
			b.append(i + 1)
		else:
			c.append(i + 1)
	print(min(p, m, pe))
	for i in range(min(p, m, pe)):
		print('{} {} {}'.format(a[i], b[i], c[i]))


n = int(input())
res = [[], [], []]
ar = list(map(int, input().split()))
for (ind, item) in enumerate(ar):
	if item:
		res[item - 1].append(ind + 1)
x = min(map(len, res))
print(x)
for i in range(x):
	print(res[0][i], res[1][i], res[2][i])


import sys
n = sys.stdin.readline()
n = int(n)
arr = sys.stdin.readline().split()
arr = [int(x) for x in arr]
ones = []
twos = []
trees = []
for i in range(n):
	if arr[i] == 1:
		ones.append(i + 1)
	elif arr[i] == 2:
		twos.append(i + 1)
	else:
		trees.append(i + 1)
res = []
while ones and twos and trees:
	(x, y, z) = (ones.pop(0), twos.pop(0), trees.pop(0))
	res.append([x, y, z])
print(len(res))
if res:
	for i in range(len(res)):
		temp = res[i]
		print(' '.join([str(x) for x in temp]))


n = int(input())
a = list(map(int, input().split()))
a1 = a.count(1)
c1 = []
a2 = a.count(2)
c2 = []
a3 = a.count(3)
c3 = []
b = min(a1, a2, a3)
print(b)
d = []
if b > 0:
	for i in range(len(a)):
		if a[i] == 1:
			c1.append(i + 1)
		if a[i] == 2:
			c2.append(i + 1)
		if a[i] == 3:
			c3.append(i + 1)
	for i in range(b):
		print(c1[i], c2[i], c3[i])


n = int(input())
arr = list(map(int, input().split()))
a = [1, 2, 3]
ans = ''
mans = ''
cnt = 0
i = 0
j = 0
flag = True
while flag:
	try:
		ans += str(arr.index(a[i]) + 1) + ' '
		j = arr.index(a[i])
		arr[j] = 0
		i += 1
	except ValueError:
		flag = False
	if i == 3:
		cnt += 1
		i = 0
		mans += ans + '\n'
		ans = ''
print(cnt)
print(mans)


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


n = int(input())
s = (1, 2, 3)
l = list(map(int, input().split()))
d = {i: l.count(i) for i in s}
m = 1000000000.0
for i in s:
	m = min(m, d[i])
print(m)
dp = [[], [], []]
for i in range(n):
	if l[i] == 1:
		dp[0] += [i + 1]
	elif l[i] == 2:
		dp[1] += [i + 1]
	else:
		dp[2] += [i + 1]
for i in range(m):
	print(dp[0][i], dp[1][i], dp[2][i])


n = int(input())
input = input().split()
stu = [[], [], []]
for i in range(n):
	if input[i] == '1':
		stu[0].append(i + 1)
	elif input[i] == '2':
		stu[1].append(i + 1)
	else:
		stu[2].append(i + 1)
x = min(len(stu[0]), min(len(stu[1]), len(stu[2])))
print(x)
for i in range(x):
	print(stu[0][i], stu[1][i], stu[2][i])


teams = [[], [], []]
n = int(input())
count1 = 0
count2 = 0
count3 = 0
children = list(map(int, input().split()))
for x in range(len(children)):
	if children[x] == 1:
		teams[0].append(x + 1)
		count1 += 1
	elif children[x] == 2:
		teams[1].append(x + 1)
		count2 += 1
	else:
		teams[2].append(x + 1)
		count3 += 1
decide = min(count1, count2, count3)
if decide != 0:
	print(decide)
	for y in range(decide):
		print(teams[0][y], teams[1][y], teams[2][y])
else:
	print(0)


n = int(input())
std = list(map(int, input().split()))
t1 = []
t2 = []
t3 = []
for i in range(n):
	if std[i] == 1:
		t1.append(i + 1)
	elif std[i] == 2:
		t2.append(i + 1)
	else:
		t3.append(i + 1)
print(min(len(t1), len(t2), len(t3)))
for (a, b, c) in zip(t1, t2, t3):
	print(a, b, c)


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	n = I()
	l = LI()
	a = []
	b = []
	c = []
	for (i, x) in enumerate(l):
		if x == 1:
			a.append(i + 1)
		elif x == 2:
			b.append(i + 1)
		else:
			c.append(i + 1)
	mn = min(len(a), len(b), len(c))
	print(mn)
	for i in range(mn):
		print(a[i], b[i], c[i])
main()


n = int(input())
students = list(map(int, input().split()))
subjects = [list() for _ in range(4)]
for i in range(n):
	subjects[students[i]].append(i + 1)
ans = min([len(subjects[i]) for i in range(1, 4)])
print(ans)
for i in range(ans):
	for j in range(1, 4):
		print(subjects[j][i], end=' ')
	print()


input()
pupils = input().split()
l = [[], [], []]
for (i, pupil) in enumerate(pupils, start=1):
	l[int(pupil) - 1].append(i)
a = list(zip(*l))
print(len(a))
for b in a:
	print(*b)


n = int(input())
children = list(map(int, input().split()))
teams = {1: [], 2: [], 3: []}
for (i, child) in enumerate(children):
	teams[child].append(i + 1)
w = len(teams[min(teams, key=lambda key: len(teams[key]))])
print(w)
for i in range(w):
	print(teams[1][i], teams[2][i], teams[3][i])


n = int(input())
a = input().split()
a1 = []
a2 = []
a3 = []
t1 = 0
t2 = 0
t3 = 0
for i in range(n):
	a[i] = int(a[i])
	if a[i] == 1:
		a1 += [i + 1]
		t1 += 1
	if a[i] == 2:
		a2 += [i + 1]
		t2 += 1
	if a[i] == 3:
		a3 += [i + 1]
		t3 += 1
min = t1
if t2 < min:
	min = t2
if t3 < min:
	min = t3
print(min)
for i in range(min):
	print(a1[i], a2[i], a3[i])


n = int(input())
students = list(input().split())
num = min(students.count('1'), students.count('2'), students.count('3'))
print(num)
(stu1, stu2, stu3) = (0, 0, 0)
for i in range(num):
	while students[stu1] != '1':
		stu1 += 1
	while students[stu2] != '2':
		stu2 += 1
	while students[stu3] != '3':
		stu3 += 1
	print(str(stu1 + 1) + ' ' + str(stu2 + 1) + ' ' + str(stu3 + 1))
	stu1 += 1
	stu2 += 1
	stu3 += 1


n = int(input())
a = list(map(int, input().split()))
one = a.count(1)
two = a.count(2)
three = a.count(3)
ans = min(one, two, three)
print(ans)
arr = []
if ans != 0:
	j = 0
	c = 0
	while True:
		if a[j] == 1:
			arr.append(j + 1)
			c += 1
		if c == ans:
			break
		j += 1
	j = 0
	c = 0
	while True:
		if a[j] == 2:
			arr.append(j + 1)
			c += 1
		if c == ans:
			break
		j += 1
	j = 0
	c = 0
	while True:
		if a[j] == 3:
			arr.append(j + 1)
			c += 1
		if c == ans:
			break
		j += 1
	for i in range(ans):
		print(arr[i], arr[i + ans], arr[i + ans + ans])


n = int(input())
st = [int(i) for i in input().split()]
math = []
phy = []
pe = []
for i in range(n):
	if st[i] == 1:
		math.append(i + 1)
	if st[i] == 2:
		phy.append(i + 1)
	if st[i] == 3:
		pe.append(i + 1)
sol = min(len(math), len(phy), len(pe))
if sol > 0:
	print(sol)
	for k in range(sol):
		print(math[k], phy[k], pe[k])
else:
	print(sol)


n = int(input(''))
ti = input('')
ti_string = list(ti.split())
lis_1 = []
lis_2 = []
lis_3 = []
c = 0
for i in ti_string:
	if i == '1':
		lis_1.append(c + 1)
		c += 1
	elif i == '2':
		lis_2.append(c + 1)
		c += 1
	elif i == '3':
		lis_3.append(c + 1)
		c += 1
	else:
		continue
m = min(len(lis_1), len(lis_2), len(lis_3))
if m == 0:
	print(0)
else:
	print(m)
	for j in range(m):
		print(lis_1[j], lis_2[j], lis_3[j])


n = int(input())
s = [i for i in input().split()]
c = []
m = []
p = []
for i in range(n):
	if s[i] == '1':
		c.append(i + 1)
	elif s[i] == '2':
		m.append(i + 1)
	elif s[i] == '3':
		p.append(i + 1)
b = len(c)
for i in [c, m, p]:
	if len(i) < b:
		b = len(i)
print(b)
for i in range(b):
	print(c[i], m[i], p[i])


n = int(input())
l = list(map(int, input().split()))
p = min(l.count(1), l.count(2), l.count(3))
print(p)
while p > 0:
	j = l.index(1)
	print(j + 1, end=' ')
	l[j] = 0
	h = l.index(2)
	print(h + 1, end=' ')
	l[h] = 0
	f = l.index(3)
	print(f + 1)
	l[f] = 0
	p = p - 1


n = int(input())
li = list(map(int, input().split(' ')))
l1 = []
l2 = []
l3 = []
count = 0
for i in li:
	if i == 1:
		l1.append(count + 1)
	elif i == 2:
		l2.append(count + 1)
	else:
		l3.append(count + 1)
	count += 1
minlen = min(len(l1), len(l2), len(l3))
print(minlen)
count = 0
while count < minlen:
	print(l1[count], l2[count], l3[count], sep=' ')
	count += 1


n = int(input())
s = list(input().split())
teams = min(s.count('1'), s.count('2'), s.count('3'))
a = list()
print(teams)
for i in range(teams):
	a.append(s.index('1'))
	a.append(s.index('2'))
	a.append(s.index('3'))
	print(a[-1] + 1, a[-2] + 1, a[-3] + 1)
	s[a[-1]] = s[a[-2]] = s[a[-3]] = '0'


n = int(input())
c = []
d = []
e = []
a = [int(x) for x in input().split()]
if 1 in a and 2 in a and (3 in a):
	for i in range(len(a)):
		if a[i] == 1:
			c.append(i)
			a[i] == 0
		elif a[i] == 2:
			d.append(i)
			a[i] == 0
		elif a[i] == 3:
			e.append(i)
			a[i] == 0
	print(min(len(c), len(d), len(e)))
	for i in range(min(len(c), len(d), len(e))):
		print(c[i] + 1, end=' ')
		print(d[i] + 1, end=' ')
		print(e[i] + 1)
else:
	print(0)


n = int(input())
t = list(map(int, input().split()))
w = 0
team = []
while 1 in t and 2 in t and (3 in t):
	w += 1
	team.append([t.index(1) + 1, t.index(2) + 1, t.index(3) + 1])
	t[t.index(1)] = 0
	t[t.index(2)] = 0
	t[t.index(3)] = 0
print(w)
for i in team:
	for j in i:
		print(j, end=' ')
	print()


n = int(input())
s = list(map(int, input().split()))
d1 = list()
d2 = list()
d3 = list()
x1 = x2 = x3 = 0
for i in s:
	if i == 1:
		x1 += 1
	elif i == 2:
		x2 += 1
	elif i == 3:
		x3 += 1
for i in range(len(s)):
	if s[i] == 1:
		d1.append(i + 1)
	elif s[i] == 2:
		d2.append(i + 1)
	elif s[i] == 3:
		d3.append(i + 1)
print(min(x1, x2, x3))
for i in range(min(x1, x2, x3)):
	print(d1[i], d2[i], d3[i])


n = int(input())
s = input()
s = s.split()
mylist = []
biglist = []
ilist = []
count = 0
j = 1
while j == 1:
	if '3' not in mylist and '3' not in s or ('2' not in mylist and '2' not in s) or ('1' not in mylist and '1' not in s):
		j = 0
		break
	for i in range(0, len(s)):
		if len(ilist) == 3:
			count = count + 1
			biglist.append(ilist)
			mylist = []
			ilist = []
		if s[i] not in mylist and s[i] != ' ':
			mylist.append(s[i])
			ilist.append(str(i + 1))
			s[i] = ' '
print(count)
if count != 0:
	for i in biglist:
		print(' '.join(i))


n = int(input())
a = list(map(int, input().split()))
dict = []
if len(set(a)) != 3:
	print(0)
else:
	indA = []
	indB = []
	indC = []
	a1 = a.count(1)
	a2 = a.count(2)
	a3 = a.count(3)
	b = [a1, a2, a3]
	min1 = min(b)
	print(min1)
	for i in range(len(a)):
		if a[i] == 1:
			indA.append(i)
		elif a[i] == 2:
			indB.append(i)
		else:
			indC.append(i)
	i = 0
	while min1 != 0:
		print(indA[i] + 1, end=' ')
		print(indB[i] + 1, end=' ')
		print(indC[i] + 1, end=' ')
		print('')
		i = i + 1
		min1 = min1 - 1


n = int(input())
s = [int(x) for x in input().split()]
a = []
b = []
c = []
for i in range(n):
	if s[i] == 1:
		a.append(i + 1)
	if s[i] == 2:
		b.append(i + 1)
	if s[i] == 3:
		c.append(i + 1)
hh = min(len(a), len(b), len(c))
if hh == 0:
	print(0)
else:
	print(hh)
	for i in range(hh):
		print(a[i], b[i], c[i])


n = int(input())
p = []
ma = []
e = []
m = list(map(int, input().split()))
for i in range(n):
	if m[i] == 1:
		p.append(i + 1)
	elif m[i] == 2:
		ma.append(i + 1)
	elif m[i] == 3:
		e.append(i + 1)
a = min(len(ma), len(p), len(e))
print(a)
if a != 0:
	for i in range(a):
		print(p[i], ma[i], e[i])


s = input()
l = list(map(int, input().split()))
(a, b, c) = ([], [], [])
for i in range(len(l)):
	if l[i] == 1:
		a.append(i + 1)
	elif l[i] == 2:
		b.append(i + 1)
	else:
		c.append(i + 1)
if len(a) > 0 and len(b) > 0 and (len(c) > 0):
	print(min(len(a), len(b), len(c)))
	for i in range(min(len(a), len(b), len(c))):
		print(a[i], b[i], c[i], sep=' ')
else:
	print(0)


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


n = int(input())
t = input().split()
one = []
two = []
three = []
l = []
for i in range(n):
	if t[i] == '1':
		one.append(i + 1)
	if t[i] == '2':
		two.append(i + 1)
	if t[i] == '3':
		three.append(i + 1)
numbers = [one, two, three]
for j in numbers:
	l.append(len(j))
l.sort()
w = l[0]
print(w)
for m in range(w):
	for n in range(3):
		print(numbers[n][m], end=' ')
	print()


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
N = int(input())
A = [int(x) for x in input().split()]
gift = collections.defaultdict(list)
for (i, v) in enumerate(A):
	gift[v].append(i + 1)
t = min(len(gift[1]), len(gift[2]), len(gift[3]))
print(t)
if t > 0:
	for i in range(t):
		print(gift[1][i], gift[2][i], gift[3][i])


aaa = int(input())
n = list(map(int, input().split()))
a = 0
b = 0
c = 0
teams = 0
index = 1
posicion_a = []
posicion_b = []
posicion_c = []
final = []
rpta = []
for i in n:
	if i == 1:
		a = a + 1
		posicion_a.append(index)
	elif i == 2:
		b = b + 1
		posicion_b.append(index)
	elif i == 3:
		c = c + 1
		posicion_c.append(index)
	if a >= 1 and b >= 1 and (c >= 1):
		a = a - 1
		b = b - 1
		c = c - 1
		teams = teams + 1
		final.append(posicion_a[0])
		final.append(posicion_b[0])
		final.append(posicion_c[0])
		posicion_a.pop(0)
		posicion_b.pop(0)
		posicion_c.pop(0)
		rpta.append(final)
		final = []
	index = index + 1
print(teams)
for jjj in rpta:
	bbb = jjj
	for asdfg in bbb:
		print(asdfg, end=' ')
	print()


n = int(input())
li = [int(i) for i in input().split()]
(one, two, three) = ([], [], [])
for i in range(n):
	if li[i] == 1:
		one.append(i + 1)
	if li[i] == 2:
		two.append(i + 1)
	if li[i] == 3:
		three.append(i + 1)
k = min([len(one), len(two), len(three)])
print(k)
for i in range(k):
	print(one[i], two[i], three[i])


n = int(input())
students = input().split()
minimum = min(students.count('1'), students.count('2'), students.count('3'))
if not minimum:
	print(0)
else:
	print(minimum)
	for i in range(minimum):
		print(students.index('1') + 1, students.index('2') + 1, students.index('3') + 1)
		students[students.index('1')] = '0'
		students[students.index('2')] = '0'
		students[students.index('3')] = '0'


l = int(input())
t = list(map(int, input().split()))
cou1 = 0
cou3 = 0
cou2 = 0
for i in range(l):
	if t[i] == 1:
		cou1 += 1
	if t[i] == 3:
		cou3 += 1
	if t[i] == 2:
		cou2 += 1
m = min(cou2, cou3, cou1)
print(m)
vis = []
for i in range(m):
	a = t.index(1)
	t[a] = -1
	print(a + 1, end=' ')
	a2 = t.index(2)
	t[a2] = -1
	print(a2 + 1, end=' ')
	a3 = t.index(3)
	t[a3] = -1
	print(a3 + 1, end='')
	print()


n = int(input())
l = list(map(int, input().split()))
one = l.count(1)
two = l.count(2)
three = l.count(3)
w = min(one, two, three)
ol = []
tl = []
thl = []
for i in range(0, len(l)):
	if l[i] == 1:
		ol.append(i + 1)
	elif l[i] == 2:
		tl.append(i + 1)
	elif l[i] == 3:
		thl.append(i + 1)
print(w)
for i in range(0, w):
	print(ol[i], tl[i], thl[i])


n = int(input())
data = [int(i) for i in input().split()]
w = min(data.count(1), data.count(2), data.count(3))
print(w)
if w > 0:
	for i in range(w):
		print(data.index(1) + 1, data.index(2) + 1, data.index(3) + 1)
		data[data.index(1)] = 0
		data[data.index(2)] = 0
		data[data.index(3)] = 0


n = int(input())
ch = input()
t = [int(x) for x in ch.split()]
t1 = [int(x) for x in ch.split()]
j = 0
while t1.count(1) != 0 and t1.count(2) != 0 and (t1.count(3) != 0):
	k1 = t1.index(1)
	t1.remove(t1[k1])
	k2 = t1.index(2)
	t1.remove(t1[k2])
	k3 = t1.index(3)
	t1.remove(t1[k3])
	j = j + 1
print(j)
for i in range(j):
	k1 = t.index(1)
	t[k1] = 0
	k2 = t.index(2)
	t[k2] = 0
	k3 = t.index(3)
	t[k3] = 0
	ch1 = str(k1 + 1) + ' ' + str(k2 + 1) + ' ' + str(k3 + 1)
	print(ch1)


n = int(input())
a = list(map(int, input().split()))
z = []
try:
	while 1 and 2 and (3 in a):
		z.append([a.index(1) + 1, a.index(2) + 1, a.index(3) + 1])
		a[a.index(1)] = -1
		a[a.index(2)] = -1
		a[a.index(3)] = -1
except:
	pass
print(len(z))
if len(z) > 0:
	for i in z:
		print(' '.join(map(str, i)))


n = int(input())
l = input().split()
x = int(l.count('1'))
y = int(l.count('2'))
z = int(l.count('3'))
minim = min(x, y, z)
print(minim)
first = []
second = []
third = []
for i in range(0, len(l)):
	if l[i] == '1':
		first.append(i + 1)
	elif l[i] == '2':
		second.append(i + 1)
	else:
		third.append(i + 1)
for j in range(0, minim):
	print(first[j], second[j], third[j])


n = int(input())
s = [[] for i in range(3)]
j = 0
for (index, val) in enumerate(map(int, input().split()), 1):
	s[val - 1].append(index)
min_s = min(map(len, s))
print(min_s)
for i in zip(*s):
	print(*i)


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


n = int(input())
q1 = 0
u2 = 0
h3 = 0
m = []
c = []
s = []
p = input().split()
for i in range(n):
	p[i] = int(p[i])
for i in range(n):
	if p[i] == 1:
		q1 = q1 + 1
		c.append(i)
	if p[i] == 2:
		u2 = u2 + 1
		m.append(i)
	if p[i] == 3:
		h3 = h3 + 1
		s.append(i)
if q1 == 0 or u2 == 0 or h3 == 0:
	res1 = 0
	print(0)
else:
	res = min(q1, u2)
	res1 = min(res, h3)
	print(res1)
	for i in range(res1):
		print(c[i] + 1, m[i] + 1, s[i] + 1)


import sys

def main(arr):
	if not arr:
		return 0
	arr = list(enumerate(arr))
	arr.sort(key=lambda x: x[1])
	one_pos = None
	two_pos = None
	three_pos = None
	for (e, n) in enumerate(arr):
		num = n[1]
		if one_pos is None and num == 1:
			one_pos = e
		if two_pos is None and num == 2:
			two_pos = e
		if three_pos is None and num == 3:
			three_pos = e
			break
	if one_pos is None or two_pos is None or three_pos is None:
		return (0, [])
	ans = 0
	valid_teams = []
	while three_pos < len(arr) and arr[one_pos][1] == 1 and (arr[two_pos][1] == 2) and (arr[three_pos][1] == 3):
		valid_teams.append(' '.join([str(arr[one_pos][0] + 1), str(arr[two_pos][0] + 1), str(arr[three_pos][0] + 1)]))
		ans += 1
		one_pos += 1
		two_pos += 1
		three_pos += 1
	return (ans, valid_teams)
for (e, line) in enumerate(sys.stdin.readlines()):
	if e == 0:
		continue
	arr = list(map(int, line.strip().split()))
(ans, valid) = main(arr)
print(ans)
list(map(print, valid))


n = int(input())
count1 = 0
count2 = 0
count3 = 0
arr = list(map(int, input().split()))
for i in range(0, n):
	if arr[i] == 1:
		count1 += 1
	elif arr[i] == 2:
		count2 += 1
	elif arr[i] == 3:
		count3 += 1
if count1 == 0 or count2 == 0 or count3 == 0:
	print(0)
else:
	team = min(count1, count2, count3)
	print(team)
	for i in range(0, team):
		index1 = arr.index(1)
		arr[index1] = -1
		index2 = arr.index(2)
		arr[index2] = -1
		index3 = arr.index(3)
		arr[index3] = -1
		print(str(index1 + 1) + ' ' + str(index2 + 1) + ' ' + str(index3 + 1))


from sys import stdin, stdout

def get_ints():
	return map(int, stdin.readline().strip().split())

def get_array():
	return list(map(int, stdin.readline().strip().split()))

def get_string():
	return stdin.readline().strip()

def op(c):
	return stdout.write(str(c))
n = int(input())
a = get_array()
(t1, t2, t3) = ([], [], [])
for i in range(n):
	if a[i] == 1:
		t1.append(i + 1)
	elif a[i] == 2:
		t2.append(i + 1)
	elif a[i] == 3:
		t3.append(i + 1)
w = min(len(t1), len(t2), len(t3))
print(w)
for i in range(w):
	print(t1[i], t2[i], t3[i])


n = int(input())
a = list(map(int, input().split()))
count1 = 0
count2 = 0
count3 = 0
b = []
c = []
d = []
for i in range(len(a)):
	if a[i] == 1:
		count1 += 1
		b.append(i + 1)
	elif a[i] == 2:
		count2 += 1
		c.append(i + 1)
	else:
		count3 += 1
		d.append(i + 1)
print(min(count1, count2, count3))
for i in range(min(count1, count2, count3)):
	print(str(b[i]) + ' ' + str(c[i]) + ' ' + str(d[i]))


n = int(input())
tl = list(map(int, input().split()))
al = [[], [], [], []]
for i in range(n):
	al[tl[i]] += [i + 1]
ans = min([len(al[1]), len(al[2]), len(al[3])])
print(ans)
for i in range(ans):
	print('%d %d %d' % (al[1][i], al[2][i], al[3][i]))


n = int(input())
line = input()
line = line.split()
pro = []
mat = []
pe = []
for i in range(0, n):
	line[i] = int(line[i])
	if line[i] == 1:
		pro.append(i + 1)
	elif line[i] == 2:
		mat.append(i + 1)
	else:
		pe.append(i + 1)
teams = []
while True:
	nteam = []
	if pro:
		nteam.append(pro[0])
		pro.pop(0)
	if pe:
		nteam.append(pe[0])
		pe.pop(0)
	if mat:
		nteam.append(mat[0])
		mat.pop(0)
	if len(nteam) == 3:
		teams.append(nteam)
	else:
		break
print(len(teams))
for k in teams:
	k[0] = str(k[0])
	k[1] = str(k[1])
	k[2] = str(k[2])
	print(k[0] + ' ' + k[1] + ' ' + k[2])


x = int(input())
t = [int(x) for x in input().split(' ')]
num = min(t.count(1), t.count(2), t.count(3))
m = []
l = [1, 2, 3]
i = 0
number = 0
j = 0
while True:
	if len(m) == num * 3:
		break
	elif number == num:
		j += 1
		i = 0
		number = 0
	else:
		if t[i] == l[j] and i + 1 not in m:
			number += 1
			m.append(i + 1)
		i += 1
print(num)
for i in range(num):
	print(m[i::num][0], m[i::num][1], m[i::num][2])


n = int(input())
l = [int(x) for x in input().split()]
a = min(l.count(1), l.count(2), l.count(3))
print(a)
for i in range(a):
	q = l.index(1)
	w = l.index(2)
	e = l.index(3)
	l[q] = 0
	l[w] = 0
	l[e] = 0
	print(q + 1, w + 1, e + 1)


n = int(input())
l = list(map(int, input().split()))
l1 = []
for i in range(1, 4):
	l1.append(l.count(i))
print(min(l1))
k = min(l1)
while k:
	for i in range(n):
		if l[i] == 1:
			print(i + 1, end=' ')
			l[i] = 0
			break
	for i in range(n):
		if l[i] == 2:
			print(i + 1, end=' ')
			l[i] = 0
			break
	for i in range(n):
		if l[i] == 3:
			print(i + 1, end=' ')
			l[i] = 0
			break
	print('')
	k -= 1


n = int(input())
a = list(map(int, input().split()))
p = a.count(1)
m = a.count(2)
f = a.count(3)
print(min([p, m, f]))
for i in range(min([p, m, f])):
	print(' '.join([str(a.index(1) + 1), str(a.index(2) + 1), str(a.index(3) + 1)]))
	a[a.index(1)] = a[a.index(2)] = a[a.index(3)] = 0


a = int(input())
s = input().split()[0:a]
d = {}
mat = []
r = set()
for i in range(a):
	s[i] = int(s[i])
for i in s:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
	r.add(i)
for i in d:
	mat.append(d[i])
i = min(mat)
j = 1
sat = []
mat = []
if len(r) == 3 and i > 0:
	while i != len(mat):
		for k in range(a):
			if s[k] == j:
				sat.append(k + 1)
				j += 1
				s[k] = 0
			if j == 4:
				mat.append(sat)
				sat = []
				j = 1
	print(i)
	for h in mat:
		for g in h:
			print(g, end=' ')
		print()
else:
	print(0)


n = int(input())
b = list(map(int, input().split()))
b.insert(0, 't')
q = b.count(1)
w = b.count(2)
e = b.count(3)
x = 0
print(min(q, w, e))
for i in range(min(q, w, e)):
	print(b.index(1), end=' ')
	b.insert(b.index(1), 't')
	b.remove(1)
	print(b.index(2), end=' ')
	b.insert(b.index(2), 't')
	b.remove(2)
	print(b.index(3), end=' ')
	b.insert(b.index(3), 't')
	b.remove(3)
	print()


from collections import defaultdict

def main():
	n = int(input())
	a = list(map(int, input().split(' ')))
	m = defaultdict(list)
	for (i, ai) in enumerate(a):
		m[ai].append(str(i + 1))
	x = int(100000000.0)
	for i in range(1, 4):
		x = min(len(m[i]), x)
	ret = []
	for i in range(1, 4):
		ret.append(m[i][:x])
	print(x)
	for line in zip(*ret):
		print(' '.join(line))
main()


n = int(input())
kids = list(map(int, input().split()))
list1 = []
programming = []
maths = []
PE = []
for i in range(n):
	list1.append([kids[i], i + 1])
for i in range(n):
	if list1[i][0] == 1:
		programming.append(list1[i])
	elif list1[i][0] == 2:
		maths.append(list1[i])
	else:
		PE.append(list1[i])
print(min(len(programming), len(maths), len(PE)))
for i in range(min(len(programming), len(maths), len(PE))):
	print(programming[i][-1], maths[i][-1], PE[i][-1])


n = int(input())
array = list(map(int, input().split()))
array_1 = []
array_2 = []
array_3 = []
for index in range(n):
	num = array[index]
	index += 1
	if num == 1:
		array_1.append(index)
	elif num == 2:
		array_2.append(index)
	else:
		array_3.append(index)
_min = min(len(array_1), len(array_2), len(array_3))
print(_min)
for i in range(_min):
	print('{} {} {}'.format(array_1[i], array_2[i], array_3[i]))


import sys
from collections import Counter
number = int(sys.stdin.readline().strip())
skill = list(map(int, sys.stdin.readline().strip().split()))
if len(set(skill)) == 3:
	team = min(Counter(skill).values())
else:
	team = 0
Lst = []
for (k, n) in enumerate(skill):
	Lst.append((n, k + 1))
one = []
two = []
three = []
for b in Lst:
	if b[0] == 1:
		one.append(b[1])
	if b[0] == 2:
		two.append(b[1])
	if b[0] == 3:
		three.append(b[1])
print(team)
for k in zip(one, two, three):
	print(' '.join(map(str, k)))


n = int(input())
nums = [int(x) for x in input().split()]
freq = {1: 0, 2: 0, 3: 0}
for num in nums:
	if num not in freq:
		freq[num] = 1
	else:
		freq[num] += 1
teams = min(freq.values())
print(teams)
for i in range(teams):
	for t in range(1, 4):
		index = nums.index(t)
		nums[index] = -1
		print(index + 1, end=' ')
	print()


n = int(input())
a = input().split()
p = []
m = []
pe = []
for i in range(1, n + 1):
	c = a[i - 1]
	if c == '1':
		p.append(i)
	if c == '2':
		m.append(i)
	if c == '3':
		pe.append(i)
w = min(len(p), len(m), len(pe))
print(w)
for i in range(w):
	print('{} {} {}'.format(p[i], m[i], pe[i]))


n = int(input())
N = [int(num) for num in input().split(' ', n - 1)]
A = [0] * n
B = [0] * n
C = [0] * n
i = x = a = b = c = 0
while i < n:
	if N[i] == 1:
		A[i] = i + 1
		a += 1
	elif N[i] == 2:
		B[i] = i + 1
		b += 1
	elif N[i] == 3:
		C[i] = i + 1
		c += 1
	i += 1
x = min(a, b, c)
A.sort(reverse=-1)
B.sort(reverse=-1)
C.sort(reverse=-1)
i = 0
print(x)
while i < x:
	print(A[i], B[i], C[i])
	i += 1


n = int(input())
progr = []
math = []
pe = []
arr = [int(i) for i in input().split()]
for i in range(n):
	if arr[i] == 1:
		progr.append(i + 1)
	elif arr[i] == 2:
		math.append(i + 1)
	else:
		pe.append(i + 1)
mn = min(min(len(progr), len(math)), len(pe))
print(mn)
for i in range(mn):
	print(str(progr[i]) + ' ' + str(math[i]) + ' ' + str(pe[i]))


n = int(input())
l1 = [int(i) for i in input().split()]
if len(list(set(l1))) < 3:
	print(0)
else:
	a = l1.count(1)
	b = l1.count(2)
	c = l1.count(3)
	print(min(a, b, c))
	l1.insert(0, 0)
	l2 = [[], [], []]
	for i in range(1, n + 1):
		if l1[i] == 1:
			l2[0].append(i)
		elif l1[i] == 2:
			l2[1].append(i)
		elif l1[i] == 3:
			l2[2].append(i)
	for i in range(min(a, b, c)):
		print(l2[0][i], l2[1][i], l2[2][i])


n = int(input())
a = list(map(int, input().split()))
d = {1: [], 2: [], 3: []}
for i in range(len(a)):
	if a[i] == 1:
		d[1].append(i + 1)
	elif a[i] == 2:
		d[2].append(i + 1)
	elif a[i] == 3:
		d[3].append(i + 1)
min = min(len(d[1]), len(d[2]), len(d[3]))
print(min)
for i in range(min):
	print(d[1][i], d[2][i], d[3][i], end=' ')
	print()


import math
c = int(input())
a = list(map(int, input().split(' ')))
d = min(a.count(1), a.count(2), a.count(3))
print(d)
if d > 0:
	s = ''
	r = 0
	t = 0
	u = 0
	for k in range(d):
		r = a.index(1, r) + 1
		t = a.index(2, t) + 1
		u = a.index(3, u) + 1
		print(str(r) + ' ' + str(t) + ' ' + str(u))


a = int(input())
b = list(map(int, input().split()))
a1 = []
a2 = []
a3 = []
x = b.count(1)
y = b.count(2)
z = b.count(3)
i = 0
x = y = z = 0
while i < a:
	if b[i] == 1:
		x = x + 1
		a1.append(i + 1)
	elif b[i] == 2:
		y = y + 1
		a2.append(i + 1)
	else:
		z = z + 1
		a3.append(i + 1)
	i = i + 1
m = min(x, y, z)
print(m)
i = int(0)
while i < m:
	print(a1[i], a2[i], a3[i])
	i = i + 1


n = int(input())
x = list(map(int, input().split()))
a = x.count(1)
b = x.count(2)
c = x.count(3)
l = []
l.append(a)
l.append(b)
l.append(c)
k = min(l)
print(k)
for i in range(k):
	p = x.index(1)
	x[p] = 5
	q = x.index(2)
	x[q] = 5
	r = x.index(3)
	x[r] = 5
	print(p + 1, q + 1, r + 1)


n = int(input())
t = [int(element) for element in input() if element != ' ']
ones = []
twos = []
threes = []
for i in range(len(t)):
	if t[i] == 1:
		ones.append(i + 1)
	if t[i] == 2:
		twos.append(i + 1)
	if t[i] == 3:
		threes.append(i + 1)
nGroups = min(len(ones), len(twos), len(threes))
print(nGroups)
for x in range(nGroups):
	print(str(ones[x]) + ' ' + str(twos[x]) + ' ' + str(threes[x]))


n = int(input())
arr = list(map(int, input().split()))
l1 = list()
l2 = list()
l3 = list()
ones = 0
twos = 0
threes = 0
for i in range(n):
	if arr[i] == 1:
		l1.append(i + 1)
		ones += 1
	elif arr[i] == 2:
		l2.append(i + 1)
		twos += 1
	elif arr[i] == 3:
		l3.append(i + 1)
		threes += 1
m = min(ones, twos, threes)
print(m)
for i in range(m):
	print(l1[i], l2[i], l3[i])


n = int(input())
l = list(map(int, input().split()))
a = l.count(1)
b = l.count(2)
c = l.count(3)
m = min(a, b, c)
if m == 0:
	print(0)
	exit()
else:
	print(m)
m = int(3 * m)
la = []
lb = []
lc = []
ca = 0
cb = 0
cc = 0
z = 0
for i in l:
	if i == 1:
		ca = ca + 1
		la.append(z + 1)
	elif i == 2:
		cb = cb + 1
		lb.append(z + 1)
	else:
		cc = cc + 1
		lc.append(z + 1)
	z = z + 1
	if ca > m and cb > m and (cc > m):
		break
for (x, y, z) in zip(la, lb, lc):
	print(str(x) + ' ' + str(y) + ' ' + str(z))


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 = int(input())
t = list(map(int, input().split()))
if t.count(1) > 0 and t.count(2) > 0 and (t.count(3) > 0):
	x = min(t.count(1), t.count(2), t.count(3))
	print(x)
	for i in range(x):
		print(t.index(1) + 1, t.index(2) + 1, t.index(3) + 1)
		a = t.index(1)
		t.remove(1)
		t.insert(a, 0)
		a = t.index(2)
		t.remove(2)
		t.insert(a, 0)
		a = t.index(3)
		t.remove(3)
		t.insert(a, 0)
else:
	print('0')


n = int(input())
n_math = 0
n_prog = 0
n_pe = 0
i_m = []
i_p = []
i_s = []
x = input().split()
x = [int(x) for x in x]
for i in range(n):
	if x[i] == 1:
		n_prog += 1
		i_p.append(i + 1)
	elif x[i] == 2:
		n_math += 1
		i_m.append(i + 1)
	elif x[i] == 3:
		n_pe += 1
		i_s.append(i + 1)
n_teams = min(n_pe, n_math, n_prog)
print(n_teams)
if n_teams != 0:
	for i in range(n_teams):
		print(str(i_s[i]) + ' ' + str(i_m[i]) + ' ' + str(i_p[i]))


n = int(input())
s = [int(x) for x in input().split()]
m = ''.join(str(s))
if s.count(3) == 0 or s.count(2) == 0 or s.count(1) == 0:
	print(0)
else:
	(a, b, c) = map(int, (s.count(1), s.count(2), s.count(3)))
	print(min(a, b, c))
	for i in range(min(a, b, c)):
		(t1, t2, t3) = map(int, (s.index(1), s.index(2), s.index(3)))
		(s[t1], s[t2], s[t3]) = [' ', ' ', ' ']
		print(t1 + 1, t2 + 1, t3 + 1)


n = int(input())
list1 = list(map(int, input().split(' ')))
count = 0
count1 = 0
count2 = 0
list2 = []
list3 = []
list4 = []
num = 1
for i in list1:
	if i == 1:
		count = count + 1
		list2.append(num)
	elif i == 2:
		count1 = count1 + 1
		list3.append(num)
	else:
		count2 = count2 + 1
		list4.append(num)
	num = num + 1
if count <= count1 and count <= count2:
	print(count)
	for i in range(count):
		print(str(list2[i]) + ' ' + str(list3[i]) + ' ' + str(list4[i]))
elif count1 < count and count1 < count2:
	print(count1)
	for i in range(count1):
		print(str(list2[i]) + ' ' + str(list3[i]) + ' ' + str(list4[i]))
else:
	print(count2)
	for i in range(count2):
		print(str(list2[i]) + ' ' + str(list3[i]) + ' ' + str(list4[i]))


N = int(input())
L = list(map(int, input().split()))
D = {}
D[1] = []
D[2] = []
D[3] = []
for i in range(1, N + 1):
	D[L[i - 1]].append(i)
total = min(len(D[1]), len(D[2]), len(D[3]))
print(total)
for i in range(total):
	print(D[1][i], D[2][i], D[3][i])


n = int(input())
t = [int(i) for i in input().strip().split()]
M = [[0] * 3 for i in range(n + 1)]
(x, y, z) = (1,) * 3
for i in range(n):
	if t[i] == 1:
		M[0][0] += 1
		M[x][0] = i + 1
		x += 1
	elif t[i] == 2:
		M[0][1] += 1
		M[y][1] = i + 1
		y += 1
	else:
		M[0][2] += 1
		M[z][2] = i + 1
		z += 1
nbTeam = min(M[0][0], M[0][1], M[0][2])
print(nbTeam)
for i in range(1, nbTeam + 1):
	print(M[i][0], M[i][1], M[i][2])


n = int(input())
skills = []
(programming, maths, PE) = (0, 0, 0)
skills = input().split()
teams = []
for i in range(len(skills)):
	skills[i] = int(skills[i])
	if skills[i] == 1:
		programming += 1
	if skills[i] == 2:
		maths += 1
	if skills[i] == 3:
		PE += 1
w = min(programming, maths, PE)
print(w)
for i in range(w):
	i1 = skills.index(1)
	skills[i1] = str(skills[i1])
	i2 = skills.index(2)
	skills[i2] = str(skills[i2])
	i3 = skills.index(3)
	skills[i3] = str(skills[i3])
	print(i1 + 1, i2 + 1, i3 + 1)


n = int(input())
a = list(map(int, input().split()))
(b, c, d) = ([], [], [])
if 1 not in a or 2 not in a or 3 not in a:
	print(0)
else:
	for i in range(n):
		if a[i] == 1:
			b.append(i + 1)
		elif a[i] == 2:
			c.append(i + 1)
		else:
			d.append(i + 1)
	(b1, c1, d1) = (len(b), len(c), len(d))
	e = min(b1, c1, d1)
	print(e)
	for j in range(e):
		a = ''
		a = a + str(b[j]) + ' ' + str(c[j]) + ' ' + str(d[j])
		print(a)


N = int(input())
L = list(map(int, input().split()))
P = []
M = []
E = []
for i in range(N):
	if L[i] == 1:
		P.append(i)
	elif L[i] == 2:
		M.append(i)
	else:
		E.append(i)
w = min(len(P), len(M), len(E))
if w == 0:
	print(w)
else:
	print(w)
	for i in range(w):
		print(str(P[i] + 1) + ' ' + str(M[i] + 1) + ' ' + str(E[i] + 1))


n = int(input())
l = list(map(int, input().split()))
dic = {1: 0, 2: 0, 3: 0}
one = []
two = []
three = []
for i in range(n):
	dic[l[i]] += 1
	if l[i] == 1:
		one.append(i + 1)
	elif l[i] == 2:
		two.append(i + 1)
	else:
		three.append(i + 1)
m = min(dic.values())
print(m)
for i in range(m):
	print(one[i], two[i], three[i])


from collections import Counter
n = int(input())
(a, b, c) = (0, 0, 0)
num = [int(i) for i in input().split()]
calc = 0
check = Counter(num)
if check[1] == 0 or check[2] == 0 or check[3] == 0:
	print(0)
else:
	calc = min(check[1], check[2])
	calc = min(calc, check[3])
	print(calc)
	for i in range(calc):
		a = num.index(1) + 1
		b = num.index(2) + 1
		c = num.index(3) + 1
		print(a, b, c)
		num[a - 1] = 0
		num[b - 1] = 0
		num[c - 1] = 0


from collections import defaultdict
n = int(input())
x = [int(x) for x in input().split()]
pro = x.count(1)
mat = x.count(2)
pe = x.count(3)
print(min(pro, mat, pe))
teams = min(pro, mat, pe)
d = defaultdict(list)
for (pos, i) in enumerate(x):
	d[i].append(pos + 1)
for i in range(teams):
	for (k, v) in d.items():
		print(v[i], end=' ')
	print()


t = int(input())
l = list(map(int, input().split()))
loop = 0
n1 = l.count(1)
n2 = l.count(2)
n3 = l.count(3)
k1 = []
k2 = []
k3 = []
for i in range(t):
	if l[i] == 1:
		k1.append(i + 1)
	elif l[i] == 2:
		k2.append(i + 1)
	else:
		k3.append(i + 1)
team = min(n1, n2, n3)
if team == 0:
	print(0)
else:
	print(team)
	while loop != team:
		print(k1[loop], k2[loop], k3[loop])
		loop += 1


n = int(input())
temp_list = str(input()).split()
line1 = list()
line2 = list()
line3 = list()
for i in range(n):
	if temp_list[i] == '1':
		line1.append(str(i + 1))
	elif temp_list[i] == '2':
		line2.append(str(i + 1))
	elif temp_list[i] == '3':
		line3.append(str(i + 1))
length = min(len(line1), len(line2), len(line3))
print(length)
for i in range(length):
	print(line1[i] + ' ' + line2[i] + ' ' + line3[i])


n = int(input())
t = list(map(int, input().split()))
p = list()
mat = list()
f = list()
for i in range(n):
	if t[i] == 1:
		p.append(i + 1)
	if t[i] == 2:
		mat.append(1 + i)
	if t[i] == 3:
		f.append(i + 1)
g = min(len(p), len(mat), len(f))
print(g)
d = list()
for i in range(g):
	print(p[i], mat[i], f[i])


foo = input()
dx = [int(x) for x in input().split()]
ones = [x for x in enumerate(dx) if x[1] == 1]
twoes = [x for x in enumerate(dx) if x[1] == 2]
threes = [x for x in enumerate(dx) if x[1] == 3]
possible = min(len(ones), len(twoes), len(threes))
matches = []
for i in range(possible):
	matches.append((ones[i][0] + 1, twoes[i][0] + 1, threes[i][0] + 1))
print(possible)
for x in range(possible):
	print(*matches[x])


n = int(input())
a = list(map(int, input().split()))
g = 1
count = []
b = []
if 1 in a and 2 in a and (3 in a):
	for i in range(1, n + 1):
		c = a.count(g)
		count.append(c)
		if g == 3:
			break
		g += 1
	count = min(count)
	g1 = 1
	g2 = 2
	g3 = 3
	print(count)
	for u in range(count):
		x = a.index(1)
		b.append(x + 1)
		y = a.index(2)
		b.append(y + 1)
		z = a.index(3)
		b.append(z + 1)
		a[x] = 0
		a[y] = 0
		a[z] = 0
		print(*b)
		b = []
else:
	print('0')


l = [[], [], [], []]
n = int(input())
A = input().split()
for i in range(len(A)):
	l[int(A[i])].append(i + 1)
ans = min(len(l[1]), len(l[2]), len(l[3]))
print(ans)
for i in range(0, ans):
	print(l[1][i], l[2][i], l[3][i])


n = int(input())
t = [int(num) for num in input().split()]
(c, m, p) = ([], [], [])
for i in range(n):
	if t[i] == 1:
		c.append(i + 1)
	elif t[i] == 2:
		m.append(i + 1)
	else:
		p.append(i + 1)
ans = min(len(c), len(m), len(p))
print(ans)
if ans != 0:
	for i in range(ans):
		print(c[i], m[i], p[i])


children = int(input())
string = input()
subjects = string.split(' ')
teams = []
w = 0
while True:
	team = ''
	for x in range(1, 4):
		try:
			child = subjects.index(str(x))
			subjects[child] = '0'
			team += str(child + 1) + ' '
		except ValueError:
			team = ''
			break
	if team != '':
		w += 1
		teams.append(team)
	else:
		break
print(w)
for x in teams:
	print(x)


n = int(input())
ts = input().split()
_is = [[], [], []]
for i in range(n):
	if ts[i] == '1':
		_is[0].append(i + 1)
	elif ts[i] == '2':
		_is[1].append(i + 1)
	else:
		_is[2].append(i + 1)
print(min(len(_is[0]), len(_is[1]), len(_is[2])))
i = 0
while True:
	try:
		print(_is[0][i], _is[1][i], _is[2][i])
		i += 1
	except IndexError:
		break


n = int(input())
s1 = input().split(' ')
s1 = [int(i) for i in s1]
r = s1
c = []
c.append(s1.count(1))
c.append(s1.count(2))
c.append(s1.count(3))
c = sorted(c)
if c[0] != 0:
	print(c[0])
	f1 = []
	f2 = []
	f3 = []
	for i in range(n):
		if r[i] == 1:
			f1.append(i + 1)
			r[i] = 4
	for i in range(n):
		if r[i] == 2:
			r[i] = 4
			f2.append(i + 1)
	for i in range(n):
		if r[i] == 3:
			f3.append(i + 1)
			r[i] = 4
	for i in range(c[0]):
		print(f1[i], f2[i], f3[i])
else:
	print('0')


n = int(input())
l = [int(x) for x in input().split()]
d1 = []
d2 = []
d3 = []
for i in range(n):
	if l[i] == 1:
		d1.append(i + 1)
	elif l[i] == 2:
		d2.append(i + 1)
	else:
		d3.append(i + 1)
l1 = len(d1)
l2 = len(d2)
l3 = len(d3)
totalTeams = min(l1, l2, l3)
print(totalTeams)
if totalTeams != 0:
	ans = [[0, 0, 0] for i in range(totalTeams)]
	k = 0
	for i in ans:
		i[0] = d1[k]
		i[1] = d2[k]
		i[2] = d3[k]
		k += 1
	for i in ans:
		for j in i:
			print(j, end=' ')
		print()


n = int(input())
a = list(map(int, input().split()))
b = min(a.count(1), a.count(2), a.count(3))
print(b)
(c1, c2, c3) = ([], [], [])
for i in range(n):
	if a[i] == 1:
		c1.append(i + 1)
	elif a[i] == 2:
		c2.append(i + 1)
	else:
		c3.append(i + 1)
for i in range(b):
	print(c1[i], c2[i], c3[i])


n = int(input())
t = list(map(int, input().split()))
m = []
c = []
p = []
for i in range(len(t)):
	if t[i] == 1:
		c.append(i + 1)
	elif t[i] == 2:
		m.append(i + 1)
	else:
		p.append(i + 1)
mi = min(len(m), len(c), len(p))
print(mi)
for j in range(mi):
	print(str(c[j]) + ' ' + str(m[j]) + ' ' + str(p[j]))


n = int(input())
skill = [int(i) for i in input().split()]
MIN = min(skill.count(1), skill.count(2), skill.count(3))
print(MIN)
t = 0
while t < MIN:
	print(skill.index(1) + 1, skill.index(2) + 1, skill.index(3) + 1)
	skill[skill.index(1)] = 0
	skill[skill.index(2)] = 0
	skill[skill.index(3)] = 0
	t = t + 1


l = int(input())
s = [int(i) for i in input().split()]
(l1, l2, l3) = ([], [], [])
for i in range(l):
	if s[i] == 1:
		l1.append(i + 1)
	elif s[i] == 2:
		l2.append(i + 1)
	else:
		l3.append(i + 1)
k = min(len(l1), len(l2), len(l3))
print(k)
for i in zip(l1, l2, l3):
	print(i[0], i[1], i[2])


n = int(input())
num = input().split()
(a, b, c, d) = ([], [], [], [])
for i in num:
	d.append(int(i))
for i in range(n):
	if int(d[i]) == 1:
		a.append(i + 1)
	elif int(d[i]) == 2:
		b.append(i + 1)
	elif int(d[i]) == 3:
		c.append(i + 1)
ans = min(len(a), len(b), len(c))
if ans == 0:
	print('0')
else:
	print(ans)
	for j in range(ans):
		print('%d %d %d' % (a.pop(), b.pop(), c.pop()))


n = int(input())
d = [[], [], []]
ar = list(map(int, input().split()))
for (i, j) in enumerate(ar):
	d[j - 1].append(i + 1)
print(min(map(len, d)))
for i in zip(*d):
	print(i[0], i[1], i[2])


def main():
	input()
	students = map(int, input().split())

	def how_many_teams(all_students):
		subjects_and_students = {}
		current_index = 1
		for student in all_students:
			if student not in subjects_and_students:
				subjects_and_students[student] = (1, [current_index])
			else:
				(subjects, students) = subjects_and_students[student]
				students.append(current_index)
				subjects_and_students[student] = (subjects + 1, students)
			current_index += 1
		if 1 in subjects_and_students and 2 in subjects_and_students and (3 in subjects_and_students):
			team = subjects_and_students[1][0]
			for current_team in subjects_and_students:
				if team > subjects_and_students[current_team][0]:
					team = subjects_and_students[current_team][0]
			print(team)
			for i in range(team):
				print(f'{subjects_and_students[1][1][i]} {subjects_and_students[2][1][i]} {subjects_and_students[3][1][i]}')
		else:
			print(0)
	how_many_teams(students)
main()


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


m = input()
n = int(m)
g = input().split()
o = g.count('1')
t = g.count('2')
th = g.count('3')
k = min(o, t, th)
r1 = [i + 1 for (i, j) in enumerate(g) if j == '1']
r2 = [i + 1 for (i, j) in enumerate(g) if j == '2']
r3 = [i + 1 for (i, j) in enumerate(g) if j == '3']
print(k)
for i in range(k):
	print(r1[i], r2[i], r3[i])


n = int(input())
l = list(map(int, input().split()))
c1 = l.count(1)
c2 = l.count(2)
c3 = l.count(3)
count = min(min(c1, c2), c3)
print(count)
if count != 0:
	while count > 0:
		i = l.index(1)
		print(i + 1, end=' ')
		l[i] = 0
		i = l.index(2)
		print(i + 1, end=' ')
		l[i] = 0
		i = l.index(3)
		print(i + 1)
		l[i] = 0
		count = count - 1


n = int(input())
a = list(map(int, input().split()))
p = a.count(1)
q = a.count(2)
r = a.count(3)
z = min(p, q, r)
print(z)
for i in range(z):
	print(a.index(1) + 1, a.index(2) + 1, a.index(3) + 1)
	a[a.index(1)] = 5
	a[a.index(2)] = 5
	a[a.index(3)] = 5


n = int(input())
skill = [int(i) for i in input().split()]
team = min(skill.count(1), skill.count(2), skill.count(3))
print(team)
if team > 0:
	for i in range(team):
		print(skill.index(1) + 1, skill.index(2) + 1, skill.index(3) + 1)
		skill[skill.index(1)] = 0
		skill[skill.index(2)] = 0
		skill[skill.index(3)] = 0


n = int(input())
l = input().split(' ')
l1 = list(map(int, l))
l11 = []
l22 = []
l33 = []
for i in range(len(l1)):
	if l1[i] == 1:
		l11.append(i + 1)
	elif l1[i] == 2:
		l22.append(i + 1)
	else:
		l33.append(i + 1)
print(min(len(l11), len(l22), len(l33)))
for i in range(min(len(l11), len(l22), len(l33))):
	print(l11[i], l22[i], l33[i])


input()
l = list(map(int, input().split()))
s = sorted(l)
a = s.count(1)
b = s.count(2)
c = s.count(3)
if a == 0 or b == 0 or c == 0:
	print(0)
else:
	print(min(a, b, c))
	for i in range(min(a, b, c)):
		print(l.index(1) + 1, end=' ')
		l[l.index(1)] = 999
		print(l.index(2) + 1, end=' ')
		l[l.index(2)] = 999
		print(l.index(3) + 1)
		l[l.index(3)] = 999


n = int(input())
l = list(map(int, input().split()))
a = []
b = []
c = []
for i in l:
	if i == 1:
		a.append(i)
	if i == 2:
		b.append(i)
	if i == 3:
		c.append(i)
a.sort()
b.sort()
c.sort()
s = min(len(a), len(b))
s = min(s, len(c))
print(s)
for i in range(s):
	x = l.index(1)
	l[x] = 0
	y = l.index(2)
	l[y] = 0
	z = l.index(3)
	l[z] = 0
	print(x + 1, y + 1, z + 1, end='')
	print()


n = int(input())
mas = [int(x) for x in input().split()]
kolvo = min(mas.count(1), mas.count(2), mas.count(3))
if kolvo == 0:
	print(0)
	raise SystemExit
mas1 = []
mas2 = []
mas3 = []
for i in range(n):
	if mas[i] == 1:
		mas1.append(i + 1)
	if mas[i] == 2:
		mas2.append(i + 1)
	if mas[i] == 3:
		mas3.append(i + 1)
print(kolvo)
for c in range(kolvo):
	z = [str(mas1[c]), str(mas2[c]), str(mas3[c])]
	print(' '.join(z))


n = int(input())
string = str(input())
arr = string.split()
for i in range(n):
	arr[i] = int(arr[i])
one = 0
two = 0
three = 0
for i in arr:
	if i == 1:
		one += 1
	elif i == 2:
		two += 1
	elif i == 3:
		three += 1
team = min(one, two, three)
if team == 0:
	print(0)
else:
	print(team)
	arr2 = []
	for i in range(len(arr)):
		tmp = [i + 1, arr[i]]
		arr2.append(tmp)
	arr2 = sorted(arr2, key=lambda x: x[1])
	teamlist = []
	for i in range(team):
		teamlist.append([])
	for i in range(0, team):
		teamlist[i].append(arr2[i][0])
	for i in range(0, team):
		teamlist[i].append(arr2[i + one][0])
	for i in range(0, team):
		teamlist[i].append(arr2[i + one + two][0])
	for i in teamlist:
		for j in i:
			print(j, end='')
			print(' ', end='')
		print('')


n = int(input())
l = list(map(int, input().split()))
p = []
q = []
r = []
for i in range(len(l)):
	if l[i] == 1:
		p.append(i)
	elif l[i] == 2:
		q.append(i)
	elif l[i] == 3:
		r.append(i)
print(min(l.count(1), l.count(2), l.count(3)))
for i in range(min(l.count(1), l.count(2), l.count(3))):
	print(p[i] + 1, q[i] + 1, r[i] + 1)


n = int(input())
l = list(map(str, input().split()))
S = ''
for i in range(n):
	S = S + l[i]
f1 = S.count('1')
f2 = S.count('2')
f3 = S.count('3')
print(min(f1, f2, f3))
for i in range(min(f1, f2, f3)):
	Z = ''
	f = S.find('1')
	S = S[:f] + '0' + S[f + 1:]
	Z = str(f + 1)
	f = S.find('2')
	S = S[:f] + '0' + S[f + 1:]
	Z = Z + ' ' + str(f + 1)
	f = S.find('3')
	S = S[:f] + '0' + S[f + 1:]
	Z = Z + ' ' + str(f + 1)
	print(Z)


n = int(input())
l = input().split()
(s1, s2, s3) = (0, 0, 0)
(l1, l2, l3) = ([], [], [])
for i in range(n):
	if l[i] == '1':
		s1 += 1
		l1.append(i)
	if l[i] == '2':
		s2 += 1
		l2.append(i)
	if l[i] == '3':
		s3 += 1
		l3.append(i)
h = [s1, s2, s3]
m = n
for i in range(3):
	if m > h[i]:
		m = h[i]
		r = i
print(h[r])
for i in range(h[r]):
	print(l1[i] + 1, l2[i] + 1, l3[i] + 1)


def find_repeat(source, elmt):
	elmt_index = []
	s_index = 0
	e_index = len(source)
	while s_index < e_index:
		try:
			temp = source.index(elmt, s_index, e_index)
			elmt_index.append(temp)
			s_index = temp + 1
		except ValueError:
			break
	return elmt_index
n = int(input())
t = list(map(int, input().split()))
a = find_repeat(t, 1)
b = find_repeat(t, 2)
c = find_repeat(t, 3)
d = min(len(a), len(b), len(c))
if d == 0:
	print(0)
else:
	print(d)
	for i in range(d):
		print(a[i] + 1, b[i] + 1, c[i] + 1)


input()
children = [int(i) for i in input().split(' ')]
a = [i + 1 for i in range(len(children)) if children[i] == 1]
b = [i + 1 for i in range(len(children)) if children[i] == 2]
c = [i + 1 for i in range(len(children)) if children[i] == 3]
ans = []
while a and b and c:
	ans.append(f'{a.pop()} {b.pop()} {c.pop()}')
print(len(ans))
for line in ans:
	print(line)


class Solution:

	def __init__(self):
		self.n = int(input())
		self.t = list(map(int, input().split()))

	def solution(self):
		(l1, l2, l3) = ([], [], [])
		for i in range(len(self.t)):
			if self.t[i] == 1:
				l1.append(i)
			if self.t[i] == 2:
				l2.append(i)
			if self.t[i] == 3:
				l3.append(i)
		mn = min(len(l1), len(l2), len(l3))
		print(mn)
		for i in range(mn):
			print(l1[i] + 1, l2[i] + 1, l3[i] + 1)

def main():
	ob = Solution()
	ob.solution()
main()


n = int(input())
l = list(map(int, input().split()))
x = []
y = []
z = []
for i in range(n):
	if l[i] == 1:
		x.append(i + 1)
	if l[i] == 2:
		y.append(i + 1)
	if l[i] == 3:
		z.append(i + 1)
w = min(len(x), len(y), len(z))
print(w)
for i in range(w):
	print(str(x[i]) + ' ' + str(y[i]) + ' ' + str(z[i]))


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)


def solve(l):
	t = [[] for _ in range(3)]
	for (idx, i) in enumerate(l):
		t[i % 3].append(idx + 1)
	min_length = len(l)
	for i in range(3):
		min_length = min(len(t[i]), min_length)
	print(min_length)
	for i in range(min_length):
		print(t[0][i], t[1][i], t[2][i])
_ = input()
l = [int(x) for x in input().split()]
solve(l)


n = int(input())
l = list(map(int, input().strip().split()))[:n]
p = []
m = []
pe = []
for (x, y) in enumerate(l):
	if y == 1:
		p.append(x + 1)
	elif y == 2:
		m.append(x + 1)
	else:
		pe.append(x + 1)
if len(p) != 0 and len(m) != 0 and (len(pe) != 0):
	mn = min(len(p), len(m), len(pe))
	print(mn)
	for j in range(mn):
		print(p[j], m[j], pe[j])
else:
	print(0)


n = int(input())
li = list(map(int, input().split()))
cnt1 = li.count(1)
cnt2 = li.count(2)
cnt3 = li.count(3)
mins = min(cnt1, cnt3, cnt2)
print(mins)
ones = [i + 1 for i in range(len(li)) if li[i] == 1]
two = [i + 1 for i in range(len(li)) if li[i] == 2]
thre = [i + 1 for i in range(len(li)) if li[i] == 3]
for i in range(mins):
	print(ones[i], two[i], thre[i])


n = input()
A = list(map(int, input().split()))
(A1, A2, A3) = ([], [], [])
for i in range(len(A)):
	if A[i] == 1:
		A1 += [i + 1]
	if A[i] == 2:
		A2 += [i + 1]
	if A[i] == 3:
		A3 += [i + 1]
x = min([len(A1), len(A2), len(A3)])
print(min([len(A1), len(A2), len(A3)]))
for i in range(x):
	print(str(A1[-1]) + ' ' + str(A2[-1]) + ' ' + str(A3[-1]))
	A1.pop()
	A2.pop()
	A3.pop()


n = int(input())
a = list(map(int, input().split()))
m1 = []
m2 = []
m3 = []
for i in range(n):
	if a[i] == 1:
		m1.append(i + 1)
	elif a[i] == 2:
		m2.append(i + 1)
	else:
		m3.append(i + 1)
command = min(len(m1), len(m2), len(m3))
print(command)
for i in range(command):
	print(m1.pop(), m2.pop(), m3.pop())


n = int(input())
l = list(map(int, input().split()))
d = dict()
(d[1], d[2], d[3]) = (0, 0, 0)
for i in l:
	d[i] += 1
print(min(d[1], d[2], d[3]))
i = 0
while i < min(d[1], d[2], d[3]):
	print(l.index(1) + 1, l.index(2) + 1, l.index(3) + 1)
	l[l.index(1)] = 0
	l[l.index(2)] = 0
	l[l.index(3)] = 0
	i += 1


input()
a = list(map(int, input().split()))
q = a.count(1)
w = a.count(2)
r = a.count(3)
t = min(q, w, r)
print(t)
k = lambda : list()
f = k()
g = k()
h = k()
for i in range(q + w + r):
	if a[i] == 1:
		f.append(i + 1)
	elif a[i] == 2:
		g.append(i + 1)
	else:
		h.append(i + 1)
for i in range(t):
	print(f[i], g[i], h[i])


n = int(input())
l = input().split()
(a, b, c) = ([], [], [])
for i in range(n):
	if l[i] == '1':
		a.append(i + 1)
	elif l[i] == '2':
		b.append(i + 1)
	elif l[i] == '3':
		c.append(i + 1)
(a, b, c) = sorted((a, b, c), key=len)
print(len(a))
for i in range(len(a)):
	print(a[i], b[i], c[i])


class CodeforcesTask490ASolution:

	def __init__(self):
		self.result = ''
		self.n = 0
		self.sk = []

	def read_input(self):
		self.n = int(input())
		self.sk = [int(x) for x in input().split(' ')]

	def process_task(self):
		ones = []
		twos = []
		threes = []
		for a in [(x + 1, self.sk[x]) for x in range(self.n)]:
			if a[1] == 1:
				ones.append(a[0])
			elif a[1] == 2:
				twos.append(a[0])
			else:
				threes.append(a[0])
		results = []
		d = min(len(ones), len(twos), len(threes))
		for x in range(d):
			results.append('{0} {1} {2}'.format(ones[x], twos[x], threes[x]))
		self.result = '{0}\n{1}'.format(d, '\n'.join(results))

	def get_result(self):
		return self.result
Solution = CodeforcesTask490ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


a = int(input())
b = list(map(int, input().split()))
x = y = z = r = int(0)
aa = []
bb = []
cc = []
while r < a:
	if b[r] == 1:
		x = x + 1
		aa.append(r + 1)
	elif b[r] == 2:
		y = y + 1
		bb.append(r + 1)
	else:
		z = z + 1
		cc.append(r + 1)
	r = r + 1
m = min(x, y, z)
print(m)
r = int(0)
while r < m:
	print(aa[r], bb[r], cc[r])
	r = r + 1


n = int(input())
li = []
li = input().split()
li1 = []
li2 = []
li3 = []
for i in range(len(li)):
	if li[i] == '1':
		li1.append(i + 1)
	elif li[i] == '2':
		li2.append(i + 1)
	else:
		li3.append(i + 1)
k = min(len(li1), len(li2), len(li3))
print(k)
for i in range(k):
	print(li1[i], li2[i], li3[i])


n = int(input())
t = list(map(int, input().split()))
w = min(t.count(1), t.count(2), t.count(3))
if w == 0:
	print('0')
	exit()
else:
	l = [[], [], []]
	for i in range(n):
		if t[i] == 1:
			l[0].append(i + 1)
		if t[i] == 2:
			l[1].append(i + 1)
		if t[i] == 3:
			l[2].append(i + 1)
print(w)
for i in range(w):
	print(l[0][i], l[1][i], l[2][i])


a = int(input())
oneArr = []
twoArr = []
threeArr = []
arr = input().split()
num = [int(x) for x in arr]
for i in range(len(num)):
	if num[i] == 1:
		oneArr.append(i)
	elif num[i] == 2:
		twoArr.append(i)
	else:
		threeArr.append(i)
maxNum = min(len(oneArr), min(len(twoArr), len(threeArr)))
print(maxNum)
if maxNum:
	for i in range(maxNum):
		print(oneArr[i] + 1, twoArr[i] + 1, threeArr[i] + 1)


n = int(input())
s = [int(i) for i in input().split()]
a = []
b = []
c = []
for i in range(len(s)):
	if s[i] == 1:
		a.append(i + 1)
	elif s[i] == 2:
		b.append(i + 1)
	else:
		c.append(i + 1)
p = min(len(a), len(b), len(c))
print(p)
for j in range(p):
	print(a[j], b[j], c[j])


n = int(input())
seq = [int(x) for x in input().split()]
hashmap = {1: [], 2: [], 3: []}
for i in range(len(seq)):
	hashmap[seq[i]].append(i + 1)
w = min(hashmap.keys(), key=lambda x: len(hashmap[x]))
mincount = len(hashmap[w])
if mincount == 0:
	print(0)
else:
	print(len(hashmap[w]))
	count = mincount
	pos = 0
	while count != 0:
		for values in hashmap.values():
			print(values[pos], end=' ')
		print()
		pos += 1
		count -= 1


n = int(input())
a = list(map(int, input().split()))
s = set(a)
if len(s) < 3:
	print(0)
else:
	diff = [0] * 3
	for i in range(n):
		diff[a[i] - 1] += 1
	x = min(diff)
	l = []
	m = []
	p = []
	for i in range(n):
		if a[i] == 1:
			l.append(i + 1)
		elif a[i] == 2:
			m.append(i + 1)
		elif a[i] == 3:
			p.append(i + 1)
	print(x)
	for i in range(x):
		q = []
		q.append(l[i])
		q.append(m[i])
		q.append(p[i])
		print(*q)


n = int(input())
students = list(map(int, input().split()))
students.insert(0, 0)
print(min(students.count(1), students.count(2), students.count(3)))
for i in range(min(students.count(1), students.count(2), students.count(3))):
	print(students.index(1), students.index(2), students.index(3))
	(students[students.index(1)], students[students.index(2)], students[students.index(3)]) = (0, 0, 0)


n = int(input())
d = {1: [], 2: [], 3: []}
e = {1: 0, 2: 0, 3: 0}
p = [int(x) for x in input().split()]
i = 1
for x in p:
	d[x].append(i)
	e[x] += 1
	i += 1
print(min(len(d[1]), len(d[2]), len(d[3])))
for i in range(min(len(d[1]), len(d[2]), len(d[3]))):
	print(d[1][i], d[2][i], d[3][i], sep=' ')


n = int(input())
l = input().split()
l1 = []
l2 = []
l3 = []
for i in range(n):
	if l[i] == '1':
		l1.append(i + 1)
	elif l[i] == '2':
		l2.append(i + 1)
	elif l[i] == '3':
		l3.append(i + 1)
m = min(len(l1), len(l2), len(l3))
print(m)
for _ in range(m):
	print('{} {} {}'.format(l1.pop(0), l2.pop(0), l3.pop(0)))


n = input()
s = list(input().split())
ones = s.count('1')
twos = s.count('2')
thrs = s.count('3')
teams = min(ones, min(twos, thrs))
print(teams)
for i in range(teams):
	ind1 = s.index('1')
	s[ind1] = ''
	ind2 = s.index('2')
	s[ind2] = ''
	ind3 = s.index('3')
	s[ind3] = ''
	print(ind1 + 1, ind2 + 1, ind3 + 1)


n = int(input())
arr = list(map(int, input().split()))
s = arr.count
teams = min(s(1), s(2), s(3))
print(teams)
d = {i + 1: arr[i] for i in range(len(arr))}
l1 = []
l2 = []
l3 = []
for i in d:
	if d[i] == 1:
		l1.append(i)
	elif d[i] == 2:
		l2.append(i)
	else:
		l3.append(i)
for k in range(teams):
	print(l1[k], l2[k], l3[k])


n = int(input())
t = list(map(int, input().split()))
p = []
m = []
ph = []
number_of_team = min(t.count(1), t.count(2), t.count(3))
gifted = [1, 2, 3]
for i in range(0, n):
	if gifted[0] == t[i]:
		p.append(i)
	elif gifted[1] == t[i]:
		m.append(i)
	elif gifted[2] == t[i]:
		ph.append(i)
print(number_of_team)
for j in range(number_of_team):
	print(p[j] + 1, m[j] + 1, ph[j] + 1)


t = int(input())
nums = list(map(int, input().split()))
teams = [[], [], []]
i = 0
while i < len(nums):
	x = nums[i]
	teams[x - 1].append(i + 1)
	i = i + 1
w = min([len(x) for x in teams])
print(w)
i = 0
while i < w:
	print(teams[0][i], teams[1][i], teams[2][i])
	i = i + 1


n = int(input())
children = input().split()
progs = []
maths = []
pes = []
for (i, child) in enumerate(children):
	if child == '1':
		progs.append(i + 1)
	elif child == '2':
		maths.append(i + 1)
	else:
		pes.append(i + 1)
if progs and maths and pes:
	print(min(len(progs), len(maths), len(pes)))
	for (p1, p2, p3) in zip(progs, maths, pes):
		print('%s %s %s' % (p1, p2, p3))
else:
	print('0')


n = int(input())
num = input()
list = [int(i) for i in num.split()]
l1 = []
l2 = []
l3 = []
l = []
for i in range(n):
	if list[i] == 1:
		l1.append(i + 1)
	elif list[i] == 2:
		l2.append(i + 1)
	elif list[i] == 3:
		l3.append(i + 1)
g = min(len(l1), len(l2), len(l3))
if g == 0:
	print(0)
else:
	print(g)
	for i in range(g):
		l = []
		l.append(l1[i])
		l.append(l2[i])
		l.append(l3[i])
		for m in l:
			print(m, end=' ')


n = int(input())
childs = list(map(int, input().split()))
k = min([childs.count(1), childs.count(2), childs.count(3)])
print(k)
for i in range(k):
	o = childs.index(1)
	childs[o] = -1
	o2 = childs.index(2)
	childs[o2] = -1
	o3 = childs.index(3)
	childs[o3] = -1
	print(o + 1, o2 + 1, o3 + 1)


n = int(input())
a = list(map(int, input().split()))
c1 = a.count(1)
c2 = a.count(2)
c3 = a.count(3)
t = min(c1, c2, c3)
print(t)
if t != 0:
	i1 = []
	i2 = []
	i3 = []
	for i in range(len(a)):
		if a[i] == 1:
			i1.append(i + 1)
		elif a[i] == 2:
			i2.append(i + 1)
		elif a[i] == 3:
			i3.append(i + 1)
	for k in range(t):
		print(i1[k], i2[k], i3[k])


import sys
import math
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
one = [i + 1 for i in range(n) if a[i] == 1]
two = [i + 1 for i in range(n) if a[i] == 2]
thr = [i + 1 for i in range(n) if a[i] == 3]
ans = min(len(one), len(two), len(thr))
print(ans)
for i in range(ans):
	print(one[-1], two[-1], thr[-1])
	one.pop()
	two.pop()
	thr.pop()


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict as dd, deque as dq
import math, string

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	N = getInt()
	A = getInts()
	(ones, twos, threes) = ([], [], [])
	ans = []
	for (i, a) in enumerate(A):
		if a == 1:
			ones.append(i + 1)
		elif a == 2:
			twos.append(i + 1)
		else:
			threes.append(i + 1)
	while ones and twos and threes:
		ans.append((ones.pop(), twos.pop(), threes.pop()))
	print(len(ans))
	for (a, b, c) in ans:
		print(a, b, c)
	return
solve()


n = int(input())
t = [[], [], []]
for (i, x) in enumerate((int(x) for x in input().split())):
	t[x - 1].append(i + 1)
nt = min((len(x) for x in t))
print(nt)
for i in range(nt):
	print(t[0][i], t[1][i], t[2][i])


n = int(input())
seq = list(map(int, input().split()))
ones = []
twos = []
threes = []
for i in range(n):
	if seq[i] == 1:
		ones.append(i + 1)
	elif seq[i] == 2:
		twos.append(i + 1)
	else:
		threes.append(i + 1)
num = min(map(len, [ones, twos, threes]))
print(num)
for i in range(num):
	print(ones[i], twos[i], threes[i])


n = int(input())
arr = input().split()
stu = {'1': [], '2': [], '3': []}
for i in range(n):
	stu[arr[i]].append(i + 1)
num = min([len(stu[str(i)]) for i in stu])
print(num)
for i in range(num):
	print(stu['1'][i], stu['2'][i], stu['3'][i])


n = int(input())
a = [[], [], []]
ct = [0, 0, 0]
L = input().split(' ')
for i in range(n):
	j = int(L[i])
	a[j - 1].append(i + 1)
	ct[j - 1] += 1
m = min(ct)
print(m)
for index in range(m):
	print(str(a[0][index]) + ' ' + str(a[1][index]) + ' ' + str(a[2][index]))


n = input()
a = map(int, input().split())
m = []
s = []
c = []
for (i, it) in enumerate(a):
	if it == 1:
		c.append(i + 1)
	elif it == 2:
		m.append(i + 1)
	else:
		s.append(i + 1)
w = min([len(m), len(s), len(c)])
if w == 0:
	print(0)
else:
	print(w)
	for i in range(w):
		print('%d %d %d' % (c[i], m[i], s[i]))


n = int(input())
T = [int(x) for x in input().split()]
no_teams = min(T.count(1), T.count(2), T.count(3))
print(no_teams)
idx = [[]] * no_teams
if no_teams:
	for i in range(no_teams):
		for j in (1, 2, 3):
			il = T.index(j)
			idx[i].append(il + 1)
			T[il] = None
	ls = [str(x) for x in idx[0]]
	num = 3
	for i in [ls[r * num:(r + 1) * num] for r in range(0, len(ls) // 2)]:
		if i:
			print(' '.join(i))


n = int(input())
ai = list(map(int, input().split()))
lst = sorted([[ai[i], i] for i in range(len(ai))])
(c1, c2, c3) = (ai.count(1), ai.count(2), ai.count(3))
res = min(c1, c2, c3)
print(res)
for j in range(res):
	print(lst[j][1] + 1, lst[j + c1][1] + 1, lst[j + c1 + c2][1] + 1)


n = int(input())
stu = input().split()
dic = {'1': stu.count('1'), '2': stu.count('2'), '3': stu.count('3')}
print(min(dic.values()))
prev1 = 0
prev2 = 0
prev3 = 0
for i in range(min(dic.values())):
	for j in range(prev1, n):
		if stu[j] == '1':
			print(j + 1, end=' ')
			prev1 = j + 1
			break
	for j in range(prev2, n):
		if stu[j] == '2':
			print(j + 1, end=' ')
			prev2 = j + 1
			break
	for j in range(prev3, n):
		if stu[j] == '3':
			print(j + 1, end=' ')
			prev3 = j + 1
			break
	print()


n = int(input())
a = list(map(int, input().split()))
print(min(a.count(1), a.count(2), a.count(3)))
b = []
c = []
d = []
t = min(a.count(1), a.count(2), a.count(3))
for i in range(0, n):
	if a[i] == 1:
		b.append(i + 1)
	elif a[i] == 2:
		c.append(i + 1)
	else:
		d.append(i + 1)
t -= 1
while t >= 0:
	print(b[t - 1], c[t - 1], d[t - 1])
	t -= 1


n = int(input())
arr = list(map(int, input().split()))
one = []
two = []
three = []
for i in range(n):
	if arr[i] == 1:
		one.append(i + 1)
	if arr[i] == 2:
		two.append(i + 1)
	if arr[i] == 3:
		three.append(i + 1)
teams = min(len(one), len(two), len(three))
print(teams)
for i in range(teams):
	print(one[i], end=' ')
	print(two[i], end=' ')
	print(three[i])


n = int(input())
x = [0, 0, 0]
s = list(map(int, input().split()))
for i in range(n):
	if s[i] == 1:
		x[0] += 1
	elif s[i] == 2:
		x[1] += 1
	elif s[i] == 3:
		x[2] += 1
if n >= 3:
	print(min(x))
	while len(s) - s.count(0) > 2:
		if (s.count(1) != 0) & (s.count(2) != 0) & (s.count(3) != 0):
			print(s.index(1) + 1, ' ', s.index(2) + 1, ' ', s.index(3) + 1)
			s[s.index(1)] = 0
			s[s.index(2)] = 0
			s[s.index(3)] = 0
		else:
			break
else:
	print(0)


n = int(input())
student = list(map(int, input().split()))
count1 = student.count(1)
count2 = student.count(2)
count3 = student.count(3)
group = min(count1, count2, count3)
print(group)
team = [[0, 0, 0] for j in range(group)]
a = 0
b = 0
c = 0
for k in range(n):
	if student[k] == 1 and a < group:
		team[a][0] = str(k + 1)
		a += 1
	elif student[k] == 2 and b < group:
		team[b][1] = str(k + 1)
		b += 1
	elif student[k] == 3 and c < group:
		team[c][2] = str(k + 1)
		c += 1
for i in range(group):
	print(' '.join(team[i]))


n = int(input())
k = list(map(int, input().split()))
(count1, count2, count3) = (0, 0, 0)
hash = {1: [], 2: [], 3: []}
for i in range(len(k)):
	if k[i] == 1:
		hash[k[i]].append(i)
		count1 += 1
	if k[i] == 2:
		hash[k[i]].append(i)
		count2 += 1
	if k[i] == 3:
		hash[k[i]].append(i)
		count3 += 1
print(min(count1, count2, count3))
z = min(count1, count2, count3)
for i in range(z):
	print(hash[1][i] + 1, hash[2][i] + 1, hash[3][i] + 1)


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())
l = [int(i) for i in input().split()]
if len(set(l)) != 3:
	print(0)
else:
	z = []
	mini = min(l.count(1), l.count(2), l.count(3))
	print(mini)
	for i in range(mini):
		print(l.index(1) + 1, end=' ')
		l[l.index(1)] = 5
		print(l.index(2) + 1, end=' ')
		l[l.index(2)] = 5
		print(l.index(3) + 1, end=' ')
		l[l.index(3)] = 5
		print()


n = int(input())
li = input().split()
maths = []
pe = []
prog = []
for i in range(n):
	if li[i] == '1':
		prog.append(i + 1)
	elif li[i] == '2':
		maths.append(i + 1)
	else:
		pe.append(i + 1)
if len(maths) == 0 or len(prog) == 0 or len(pe) == 0:
	print(0)
	exit()
print(min(len(maths), len(prog), len(pe)))
for (a, b, c) in zip(prog, maths, pe):
	print(a, b, c)


class Output(object):

	def __init__(self, x=None, y=None, z=None):
		self.x = x
		self.y = y
		self.z = z
x = input()
x = input()
x = list(map(int, x.strip().split()))
countx = 0
county = 0
countz = 0
listOfOutput = []
for i in range(len(x)):
	listOfOutput.append(Output(-1, -1, -1))
	if x[i] == 1:
		listOfOutput[countx].x = i + 1
		countx += 1
	elif x[i] == 2:
		listOfOutput[county].y = i + 1
		county += 1
	elif x[i] == 3:
		listOfOutput[countz].z = i + 1
		countz += 1
listofString = []
countOfTeams = 0
for output in listOfOutput:
	if output.x != -1 and output.y != -1 and (output.z != -1):
		countOfTeams += 1
		listofString.append('%s %s %s' % (output.x, output.y, output.z))
print(str(countOfTeams))
if countOfTeams > 0:
	print(*listofString, sep='\n')


def main():
	n = int(input())
	studs = [int(i) for i in input().split()]
	st1 = []
	st2 = []
	st3 = []
	for i in range(n):
		if studs[i] == 1:
			st1.append(i + 1)
		elif studs[i] == 2:
			st2.append(i + 1)
		else:
			st3.append(i + 1)
	num = min(len(st1), len(st2), len(st3))
	print(str(num))
	if num > 0:
		for i in range(num):
			team = str(st1[i]) + ' ' + str(st2[i]) + ' ' + str(st3[i])
			print(team)
main()


n = int(input())
l = list(map(int, input().split()))
(p, m, pe) = (list(), list(), list())
for c in enumerate(l, 1):
	if c[1] == 1:
		p.append(c[0])
	elif c[1] == 2:
		m.append(c[0])
	else:
		pe.append(c[0])
team = min([len(p), len(m), len(pe)])
print(team)
for i in range(team):
	print(p[-1], m[-1], pe[-1])
	del p[-1]
	del m[-1]
	del pe[-1]


N = int(input())
n = list(map(int, input().split()))
x = []
x1 = []
x2 = []
x3 = []
y1 = []
y2 = []
y3 = []
if n.count(1) == 0 or n.count(2) == 0 or n.count(3) == 0:
	print(0)
	exit()
x.append(n.count(1))
x.append(n.count(2))
x.append(n.count(3))
x.sort()
print(x[0])
for i in range(len(n)):
	if n[i] == 1:
		x1.append(i + 1)
	elif n[i] == 2:
		x2.append(i + 1)
	elif n[i] == 3:
		x3.append(i + 1)
for i in range(x[0]):
	y1.append(x1[i])
	y2.append(x2[i])
	y3.append(x3[i])
for i in range(x[0]):
	print(y1[i], y2[i], y3[i])


n = int(input())
a = list(map(int, input().split()))
if (1 or 2 or 3) not in a:
	print(0)
else:
	i = a.count(1)
	ii = a.count(2)
	iii = a.count(3)
	r = min(i, ii, iii)
	print(r)
	for i in range(r):
		print(a.index(1) + 1, end=' ')
		a[a.index(1)] = '#'
		print(a.index(2) + 1, end=' ')
		a[a.index(2)] = '#'
		print(a.index(3) + 1)
		a[a.index(3)] = '#'


n = int(input())
s = input().split(' ')
s_a = [[], [], []]
for i in range(n):
	if s[i] == '1':
		s_a[0].append(i + 1)
	elif s[i] == '2':
		s_a[1].append(i + 1)
	elif s[i] == '3':
		s_a[2].append(i + 1)
r = len(min(s_a, key=lambda d: len(d)))
print(r)
for i in range(r):
	print(s_a[0][i], s_a[1][i], s_a[2][i])


from collections import defaultdict
input()
d = [[], [], []]
i = 1
for n in input().split():
	d[int(n) - 1].append(i)
	i += 1
(i, m) = (0, min([len(l) for l in d]))
print(m)
while i < m:
	print(d[0][i], d[1][i], d[2][i])
	i += 1


n = int(input())
l = [int(i) for i in input().split()]
res = [[], [], []]
i = 1
for e in l:
	if e == 1:
		res[0].append(i)
	elif e == 2:
		res[1].append(i)
	else:
		res[2].append(i)
	i += 1
m = min(len(res[0]), len(res[1]), len(res[2]))
print(m)
for i in range(m):
	print(res[0][i], end=' ')
	print(res[1][i], end=' ')
	print(res[2][i])


def column(teams, i):
	return [row[i] for row in teams]
n = int(input())
childrens = list(map(int, input().split()))
teams = [[], [], []]
for i in range(n):
	if childrens[i] == 1:
		teams[0].append(i)
	if childrens[i] == 2:
		teams[1].append(i)
	if childrens[i] == 3:
		teams[2].append(i)
teamsNumber = min(map(len, teams))
newTeams = [[x + 1 for x in teams[i]] for i in range(len(teams))]
print(teamsNumber)
for i in range(teamsNumber):
	for index in column(newTeams, i):
		print(index, end=' ')
	print(' ')


t = int(input())
list1 = [int(x) for x in input().split()]
list2 = sorted(list1)
c = list2.count(1)
d = list2.count(2)
e = list2.count(3)
g = []
h = []
j = []
f = min(c, d, e)
print(f)
if f > 0:
	for i in range(0, t):
		if list1[i] == 1:
			g.append(i)
		if list1[i] == 2:
			h.append(i)
		if list1[i] == 3:
			j.append(i)
for k in range(0, f):
	print(str(g[k] + 1), str(h[k] + 1), str(j[k] + 1))


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())
t = input().split()
t_ = t[:]
e1 = []
e2 = []
e3 = []
if t.count('1') == 0 or t.count('2') == 0 or t.count('3') == 0:
	print('0')
else:
	print(min(t.count('1'), t.count('2'), t.count('3')))
	for i in range(len(t)):
		if t[i] == '1':
			e1.append(i + 1)
			t[i] = '_'
		elif t[i] == '2':
			e2.append(i + 1)
			t[i] = '_'
		elif t[i] == '3':
			e3.append(i + 1)
			t[i] = '_'
	for x in range(min(t_.count('1'), t_.count('2'), t_.count('3'))):
		print(e1[x], e2[x], e3[x])


length = int(input())
students = list(input())
for i in range(length):
	if ' ' in students:
		students.remove(' ')
	else:
		break
students = list(map(int, students))
assert len(students) == length
teams = dict()
programmers = 0
math = 0
sports = 0
for i in range(len(students)):
	if students[i] == 1:
		programmers = programmers + 1
		teams[str(students[i])] = programmers
	if students[i] == 2:
		math = math + 1
		teams[str(students[i])] = math
	if students[i] == 3:
		sports = sports + 1
		teams[str(students[i])] = sports
if len(teams) < 3:
	print(0)
else:
	minimum = min(teams.items(), key=lambda x: x[1])[1]
	print(minimum)
	counter = 0
	controlbits = [1] * len(students)
	i = 0
	flag = 0
	triplets = [0] * 4
	triplets[0] = 1
	while counter != minimum:
		if controlbits[i] == 1:
			if triplets[students[i]] == 0:
				triplets[students[i]] = 1
				Cond = all(triplets) == 1
				print(i + 1, end=' ')
				controlbits[i] = 0
		if Cond == True:
			counter = counter + 1
			triplets = [0] * 4
			triplets[0] = 1
			Cond = False
			print()
		if i == len(controlbits) - 1:
			i = 0
		i = i + 1


(n, student) = (int(input()), list(map(int, input().split())))
team = [0, 0, 0]
(i1, i2, i3) = (0, 0, 0)
for i in student:
	team[i - 1] += 1
min_teams = min(team)
print(min_teams)
for i in range(min_teams):
	i1 = student.index(1, i1) + 1
	i2 = student.index(2, i2) + 1
	i3 = student.index(3, i3) + 1
	print(i1, i2, i3)


n = int(input())
arr = [[] for i in range(3)]
z = 1
ans = []
for i in input().split():
	t = int(i) - 1
	arr[t].append(z)
	for j in range(3):
		if len(arr[j]) == 0:
			break
	else:
		ans.append((arr[0][0], arr[1][0], arr[2][0]))
		for j in arr:
			j.remove(j[0])
	z += 1
print(len(ans))
for i in ans:
	for j in i:
		print(j, end=' ')
	print()


n = int(input())
students = input().split()
students = [int(i) for i in students]
p1 = []
m2 = []
pe3 = []
for i in range(len(students)):
	if students[i] == 1:
		p1.append(i + 1)
	elif students[i] == 2:
		m2.append(i + 1)
	elif students[i] == 3:
		pe3.append(i + 1)
num = min([len(p1), len(m2), len(pe3)])
print(num)
if num > 0:
	for i in range(num):
		print(p1[i], m2[i], pe3[i])


n = int(input())
line = input()
pieces = line.split()
list1 = []
list2 = []
list3 = []
for i in range(n):
	list1.append(pieces[i])
	list2.append(pieces[i])
	list3.append(pieces[i])
s1 = list1.count('1')
s2 = list1.count('2')
s3 = list1.count('3')
t = min(s1, s2, s3)
print(t)
list2i = []
list3i = []
list4i = []
for i in range(s1):
	t1 = list1.index('1') + i + 1
	list1.remove('1')
	list2i.append(t1)
for i in range(s2):
	t1 = list2.index('2') + i + 1
	list2.remove('2')
	list3i.append(t1)
for i in range(s3):
	t1 = list3.index('3') + i + 1
	list3.remove('3')
	list4i.append(t1)
for i in range(t):
	t1 = list2i[i]
	t2 = list3i[i]
	t3 = list4i[i]
	print('%d %d %d' % (t1, t2, t3))


a = int(input())
s = list(map(int, input().split()))
(index1, index2, index3) = ([], [], [])
count1 = s.count(1)
count2 = s.count(2)
count3 = s.count(3)
if count1 > 0 and count2 > 0 and (count3 > 0):
	k = min(count1, min(count2, count3))
	for i in range(len(s)):
		if s[i] == 1:
			index1.append(i + 1)
		elif s[i] == 2:
			index2.append(i + 1)
		elif s[i] == 3:
			index3.append(i + 1)
	print(k)
	for i in range(k):
		print(str(index1[i]) + ' ' + str(index2[i]) + ' ' + str(index3[i]))
else:
	print(0)


x = int(input())
y = list(map(int, input().split()))
Sportmans = 0
mathematicians = 0
programmers = 0
for i in y:
	if i == 1:
		programmers += 1
	if i == 2:
		mathematicians += 1
	if i == 3:
		Sportmans += 1
MaxOfTeams = min(Sportmans, mathematicians, programmers)
print(MaxOfTeams)
while MaxOfTeams > 0:
	print()
	for i in range(len(y)):
		if y[i] == 1:
			print(i + 1, end=' ')
			y[i] = 0
			break
	for i in range(len(y)):
		if y[i] == 2:
			print(i + 1, end=' ')
			y[i] = 0
			break
	for i in range(len(y)):
		if y[i] == 3:
			print(i + 1, end=' ')
			y[i] = 0
			break
	MaxOfTeams -= 1


n = int(input())
arr = [None] + list(map(int, input().split()))
ocount = 0
a = []
tcount = 0
b = []
thcount = 0
c = []
ans = []
for i in range(1, len(arr)):
	if arr[i] == 1:
		ocount += 1
		a.append(i)
	elif arr[i] == 2:
		tcount += 1
		b.append(i)
	else:
		thcount += 1
		c.append(i)
count = min(ocount, tcount, thcount)
for i in range(count):
	ans.append([])
	ans[i].append(a[i])
	ans[i].append(b[i])
	ans[i].append(c[i])
print(count)
for i in range(len(ans)):
	for j in ans[i]:
		print(j, end=' ')
	print()


(one, two, three) = (0, 0, 0)
(l, b, s) = ([], [], [])
n = int(input())
p = list(map(int, input().split()))
v = 0
for item in p:
	if item == 1:
		one += 1
		l.append(p[v:].index(item) + v)
		v += 1
	elif item == 2:
		two += 1
		b.append(p[v:].index(item) + v)
		v += 1
	else:
		three += 1
		s.append(p[v:].index(item) + v)
		v += 1
m = min(one, two, three)
if m == 0:
	print(m)
else:
	print(m)
	i = 0
	while i < m:
		z = [l[i] + 1, b[i] + 1, s[i] + 1]
		i += 1
		print(*z, sep=' ')


inp = input()
inp = input().split()
pg = inp.count('1')
mth = inp.count('2')
pe = inp.count('3')
wew = [pg, mth, pe]
print(min(wew))
s1 = 0
s2 = 0
s3 = 0
inp = ' ' + ''.join(inp)
for a in range(min(wew)):
	print(inp.find('1', s1), end=' ')
	s1 = inp.find('1', s1) + 1
	print(inp.find('2', s2), end=' ')
	s2 = inp.find('2', s2) + 1
	print(inp.find('3', s3), end=' ')
	s3 = inp.find('3', s3) + 1
	print()


n = int(input())
d = list(map(int, input().split()))
p = d.count(1)
m = d.count(2)
f = d.count(3)
w = min(p, m, f)
print(w)
for i in range(w):
	a = d.index(1)
	d[a] = 4
	b = d.index(2)
	d[b] = 4
	c = d.index(3)
	d[c] = 4
	print(a + 1, b + 1, c + 1)


def solve():
	n = int(input())
	m = [int(s) for s in input().split()]
	(t1, t2, t3) = ([], [], [])
	for i in range(n):
		if m[i] == 1:
			t1.append(i + 1)
		elif m[i] == 2:
			t2.append(i + 1)
		else:
			t3.append(i + 1)
	k = min(len(t1), len(t2), len(t3))
	print(k)
	for i in range(k):
		print(t1[i], t2[i], t3[i])
solve()


n = int(input())
l = list(map(int, input().split()))
one = []
two = []
thr = []
if 1 not in l or 2 not in l or 3 not in l:
	print('0')
else:
	for (i, j) in enumerate(l):
		if j == 1:
			one.append(i)
		elif j == 2:
			two.append(i)
		else:
			thr.append(i)
	mini = min(len(one), len(two), len(thr))
	print(mini)
	for k in range(mini):
		print(one[k] + 1, two[k] + 1, thr[k] + 1)


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


n = int(input())
lst = list(map(int, input().split()))
n1 = lst.count(1)
n2 = lst.count(2)
n3 = lst.count(3)
n = min(n1, n2, n3)
f = []
for i in range(n):
	f.append([lst.index(1) + 1, lst.index(2) + 1, lst.index(3) + 1])
	lst[lst.index(1)] = 4
	lst[lst.index(2)] = 4
	lst[lst.index(3)] = 4
print(len(f))
for i in f:
	print(*i)


n = int(input())
indices = [[], [], []]
for (i, v) in enumerate(map(int, input().split())):
	indices[v - 1].append(i + 1)
print(min(map(len, indices)))
for ms in zip(*indices):
	print(' '.join(map(str, ms)))


n = int(input())
l = [i for i in input().split()]
p = [i + 1 for i in range(n) if l[i] == '1']
m = [i + 1 for i in range(n) if l[i] == '2']
s = [i + 1 for i in range(n) if l[i] == '3']
w = min(map(len, [p, m, s]))
print(w)
for i in range(w):
	print(p[i], m[i], s[i])


import sys
input = lambda : sys.stdin.readline().rstrip()
n = int(input())
a = [int(i) for i in input().split()]
ans = [0] * 3
ans1 = [[], [], []]
k = 0
for i in a:
	k += 1
	ans[i - 1] += 1
	ans1[i - 1].append(k)
print(min(ans))
for i in range(min(ans)):
	x = []
	for j in ans1:
		x.append(j.pop())
	print(*x)


n = int(input())
inp = input().split()
a1 = []
a2 = []
a3 = []
for i in range(len(inp)):
	if inp[i] == '1':
		a1.append(i + 1)
	elif inp[i] == '2':
		a2.append(i + 1)
	else:
		a3.append(i + 1)
lpn = min(len(a1), len(a2), len(a3))
j = 0
print(lpn)
for i in range(lpn):
	s = str(a1[j]) + ' ' + str(a2[j]) + ' ' + str(a3[j])
	j = j + 1
	print(s)


n = int(input())
a = list(map(int, input().split()))
prog = 0
math = 0
pe = 0
proglist = []
mathlist = []
pelist = []
for i in range(n):
	if a[i] == 1:
		prog += 1
		proglist += [i + 1]
	elif a[i] == 2:
		math += 1
		mathlist += [i + 1]
	elif a[i] == 3:
		pe += 1
		pelist += [i + 1]
minim = min(prog, math, pe)
print(min(prog, math, pe))
for j in range(minim):
	print(proglist[j], mathlist[j], pelist[j])


n = int(input())
a = []
b = []
c = []
p = 0
m = 0
pe = 0
d = list(map(int, input().split(' ')))
for i in range(n):
	x = d[i]
	if x == 1:
		p = p + 1
		a.append(i + 1)
	elif x == 2:
		m = m + 1
		b.append(i + 1)
	else:
		pe = pe + 1
		c.append(i + 1)
if p <= m and p <= pe:
	print(p)
	for i in range(len(a)):
		print(a[i], end=' ')
		print(b[i], end=' ')
		print(c[i])
elif m <= p and m <= pe:
	print(m)
	for i in range(len(b)):
		print(a[i], end=' ')
		print(b[i], end=' ')
		print(c[i])
else:
	print(pe)
	for i in range(len(c)):
		print(a[i], end=' ')
		print(b[i], end=' ')
		print(c[i])


n = int(input())
students = input().split()
math = 0
PE = 0
CS = 0
c = []
p = []
m = []
for i in range(n):
	if students[i] == '1':
		CS += 1
		c.append(i + 1)
	elif students[i] == '2':
		math += 1
		m.append(i + 1)
	else:
		PE += 1
		p.append(i + 1)
w = min(CS, math, PE)
print(w)
for i in range(w):
	print(c[0], m[0], p[0])
	del p[0]
	del c[0]
	del m[0]


n = int(input())
i1 = list(map(str, input().split()))
l = [i1.count('1'), i1.count('2'), i1.count('3')]
if '0' not in l:
	a = min(l)
	print(a)
	for i in range(int(a)):
		print(i1.index('1') + 1, i1.index('2') + 1, i1.index('3') + 1)
		i1[i1.index('1')] = '4'
		i1[i1.index('2')] = '4'
		i1[i1.index('3')] = '4'
else:
	print('0')


input()
students = {t: set() for t in '123'}
for (i, t) in enumerate(input().split(), 1):
	students[t].add(i)
w = min((len(students[t]) for t in '123'))
print(w)
for _ in range(w):
	print(' '.join((str(students[t].pop()) for t in '123')))