You are given an array $a$ consisting of $n$ integers. You can perform the following operations with it:   Choose some positions $i$ and $j$ ($1 \le i, j \le n, i \ne j$), write the value of $a_i \cdot a_j$ into the $j$-th cell and remove the number from the $i$-th cell;  Choose some position $i$ and remove the number from the $i$-th cell (this operation can be performed no more than once and at any point of time, not necessarily in the beginning). 

The number of elements decreases by one after each operation. However, the indexing of positions stays the same. Deleted numbers can't be used in the later operations.

Your task is to perform exactly $n - 1$ operations with the array in such a way that the only number that remains in the array is maximum possible. This number can be rather large, so instead of printing it you need to print any sequence of operations which leads to this maximum number. Read the output format to understand what exactly you need to print.


-----Input-----

The first line contains a single integer $n$ ($2 \le n \le 2 \cdot 10^5$) — the number of elements in the array.

The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($-10^9 \le a_i \le 10^9$) — the elements of the array.


-----Output-----

Print $n - 1$ lines. The $k$-th line should contain one of the two possible operations.

The operation of the first type should look like this: $1~ i_k~ j_k$, where $1$ is the type of operation, $i_k$ and $j_k$ are the positions of the chosen elements.

The operation of the second type should look like this: $2~ i_k$, where $2$ is the type of operation, $i_k$ is the position of the chosen element. Note that there should be no more than one such operation.

If there are multiple possible sequences of operations leading to the maximum number — print any of them.


-----Examples-----
Input
5
5 -2 0 1 -3

Output
2 3
1 1 2
1 2 4
1 4 5

Input
5
5 2 0 4 0

Output
1 3 5
2 5
1 1 2
1 2 4

Input
2
2 -1

Output
2 2

Input
4
0 -10 0 0

Output
1 1 2
1 2 3
1 3 4

Input
4
0 0 0 0

Output
1 1 2
1 2 3
1 3 4



-----Note-----

Let X be the removed number in the array. Let's take a look at all the examples:

The first example has, for example, the following sequence of transformations of the array: $[5, -2, 0, 1, -3] \to [5, -2, X, 1, -3] \to [X, -10, X, 1, -3] \to$ $[X, X, X, -10, -3] \to [X, X, X, X, 30]$. Thus, the maximum answer is $30$. Note, that other sequences that lead to the answer $30$ are also correct.

The second example has, for example, the following sequence of transformations of the array: $[5, 2, 0, 4, 0] \to [5, 2, X, 4, 0] \to [5, 2, X, 4, X] \to [X, 10, X, 4, X] \to$ $[X, X, X, 40, X]$. The following answer is also allowed: 

1 5 3

1 4 2

1 2 1

2 3



Then the sequence of transformations of the array will look like this: $[5, 2, 0, 4, 0] \to [5, 2, 0, 4, X] \to [5, 8, 0, X, X] \to [40, X, 0, X, X] \to$ $[40, X, X, X, X]$.

The third example can have the following sequence of transformations of the array: $[2, -1] \to [2, X]$.

The fourth example can have the following sequence of transformations of the array: $[0, -10, 0, 0] \to [X, 0, 0, 0] \to [X, X, 0, 0] \to [X, X, X, 0]$.

The fifth example can have the following sequence of transformations of the array: $[0, 0, 0, 0] \to [X, 0, 0, 0] \to [X, X, 0, 0] \to [X, X, X, 0]$.

Difficulty: MEDIUM_HARD
Tags: Greedy algorithms

Mathematics

Constructive algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
n = int(input())
t = n
num = list(map(int, input().split()))
visited = [True] * n
negative = 0
mn = -10 ** 10
pos = -1
zero = 0
pos_zero = []
for i in range(n):
	q = num[i]
	if q == 0:
		zero += 1
		pos_zero.append(i)
	elif q < 0:
		negative += 1
		if pos == -1:
			pos = i
		if mn < q:
			mn = q
			pos = i
for i in range(len(pos_zero) - 1):
	print(1, pos_zero[i] + 1, pos_zero[i + 1] + 1)
	visited[pos_zero[i]] = False
t -= zero
if zero > 0 and negative % 2 == 1 and (t > 0):
	print(1, pos + 1, pos_zero[-1] + 1)
	t -= 1
	visited[pos] = False
if negative % 2 == 1 and zero == 0 and (t > 0):
	visited[pos] = False
	print(2, pos + 1)
elif zero > 0 and t > 0 and (zero < n):
	visited[pos_zero[-1]] = False
	print(2, pos_zero[-1] + 1)
i = -1
(old, cur) = (None, None)
while n - i > 1:
	i += 1
	if visited[i]:
		if old is None:
			old = i
			visited[i] = False
			continue
		if cur is None:
			cur = i
			print(1, old + 1, cur + 1)
			(old, cur) = (cur, None)
			visited[old] = False
			continue


import sys
import math
from collections import defaultdict, deque
import heapq
n = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().split()))
(pos, neg, zero) = ([], [], [])
for i in range(n):
	if arr[i] == 0:
		zero.append([arr[i], i + 1])
		continue
	if arr[i] > 0:
		pos.append([arr[i], i + 1])
		continue
	neg.append([arr[i], i + 1])
(n, m, k) = (len(pos), len(neg), len(zero))
if m > 0:
	num = max(neg)
	ind = 0
	for i in range(m):
		if num == neg[i]:
			ind = i
	(neg[0], neg[ind]) = (neg[ind], neg[0])
ans = []
j = 0
ch = True
if m % 2 != 0:
	if k > 0:
		ans.append([1, neg[0][1], zero[0][1]])
		j += 1
	else:
		ans.append([2, neg[0][1]])
		j += 1
		ch = False
for i in range(1, n):
	ans.append([1, pos[i][1], pos[0][1]])
for i in range(1, k):
	ans.append([1, zero[i][1], zero[0][1]])
for i in range(j + 1, m):
	ans.append([1, neg[i][1], neg[j][1]])
if ch:
	if len(ans) < n + m + k - 1 and k > 0:
		ans.append([2, zero[0][1]])
	if n > 0 and j < m:
		ans.append([1, pos[0][1], neg[j][1]])
elif n > 0:
	if j < m:
		ans.append([1, neg[j][1], pos[0][1]])
	if k > 0:
		ans.append([1, zero[0][1], pos[0][1]])
elif j < m:
	if k > 0:
		ans.append([1, zero[0][1], neg[j][1]])
n = len(ans)
for i in range(n):
	print(*ans[i])


N = int(input())
A = [int(x) for x in input().split()]
B = [abs(x) for x in A]
zeros = [i for i in range(N) if A[i] == 0]
positives = [i for i in range(N) if A[i] > 0]
negs = [(abs(A[i]), i) for i in range(N) if A[i] < 0]
idx = []
if len(negs) % 2 == 0:
	if len(zeros) > 1:
		print('\n'.join(['1 {} {}'.format(i + 1, zeros[0] + 1) for i in zeros[1:]]))
		if len(zeros) < N:
			print('2 {}'.format(zeros[0] + 1))
	elif len(zeros) == 1:
		print('2 {}'.format(zeros[0] + 1))
	else:
		pass
	idx = [i for (v, i) in negs] + positives
else:
	negs.sort()
	negs = [i for (v, i) in negs]
	if len(zeros) > 0:
		print('\n'.join(['1 {} {}'.format(i + 1, zeros[0] + 1) for i in zeros[1:]]))
		print('1 {} {}'.format(zeros[0] + 1, negs[0] + 1))
		if len(zeros) + 1 < N:
			print('2 {}'.format(negs[0] + 1))
	else:
		print('2 {}'.format(negs[0] + 1))
	idx = positives + negs[1:]
if idx:
	mx = -1
	mxVal = float('-inf')
	for i in idx:
		if B[i] > mxVal:
			mxVal = B[i]
			mx = i
	print('\n'.join(['1 {} {}'.format(u + 1, mx + 1) for u in idx if u != mx]))


n = int(input())
a = [int(el) for el in input().split()]
k0 = 0
kotr = 0
index_minotr = 0
minotr = float('-inf')
minotr_index = -1
minabs = float('+inf')
minabs_index = -1
index0 = -1
for i in range(n):
	if a[i] == 0:
		k0 += 1
		index0 = i
	elif abs(a[i]) < minabs:
		minabs = abs(a[i])
		minabs_index = i
	if a[i] < 0:
		kotr += 1
		if a[i] > minotr:
			minotr = a[i]
			minotr_index = i
if k0 == n - 1 and kotr == 0:
	for i in range(n - 1):
		for j in range(i + 1, n):
			if a[i] == 0 and a[j] == 0:
				print(1, i + 1, j + 1)
				index0 = j
				break
	print(2, index0 + 1)
	raise SystemExit()
if k0 == n - 1 and kotr == 1 or k0 == n:
	i = 0
	for i in range(n - 1):
		print(1, i + 1, i + 2)
	raise SystemExit
if kotr % 2 == 0:
	for i in range(n - 1):
		for j in range(i + 1, n):
			if a[i] == 0 and a[j] == 0:
				print(1, i + 1, j + 1)
				index0 = max(index0, j)
				break
			if a[i] != 0 and a[j] != 0:
				print(1, i + 1, j + 1)
				break
	if index0 != -1:
		print(2, index0 + 1)
	raise SystemExit
for i in range(n - 1):
	for j in range(i + 1, n):
		if a[i] == 0 and a[j] == 0:
			print(1, i + 1, j + 1)
			index0 = max(index0, j)
			break
		if a[i] == 0 and j == minotr_index:
			print(1, i + 1, j + 1)
			index0 = max(index0, j)
			a[j] = 0
			break
		if i == minotr_index and a[j] == 0:
			print(1, i + 1, j + 1)
			index0 = max(index0, j)
			break
		if i != minotr_index and j != minotr_index and (a[i] * a[j] != 0):
			print(1, i + 1, j + 1)
			break
if index0 == -1:
	print(2, minotr_index + 1)
else:
	print(2, index0 + 1)


n = int(input())
vector = [int(i) for i in input().split()]
usado = []
nusado = []
pos = -1
cn = 0
cz = 0
resp = []
i = 0
while i < n:
	v = vector[i]
	if v < 0:
		cn += 1
		if pos == -1 or vector[pos] < v:
			pos = i
		nusado.append(i)
	elif v == 0:
		cz += 1
		usado.append(i)
	else:
		nusado.append(i)
	i += 1
if cz == n or (cz == n - 1 and cn == 1):
	i = 1
	while i < n:
		resp.append('%d %d %d' % (1, i, i + 1))
		i += 1
else:
	cross = -1
	if cn % 2 == 1:
		cross = pos
		usado.append(pos)
	ultimo = -1
	i = 0
	for i in usado:
		if ultimo != -1:
			resp.append('%d %d %d' % (1, ultimo + 1, i + 1))
		ultimo = i
		i += 1
	if ultimo != -1:
		resp.append('%d %d' % (2, ultimo + 1))
	i = 0
	ultimo = -1
	for i in nusado:
		if i != cross:
			if ultimo != -1:
				resp.append('%d %d %d' % (1, ultimo + 1, i + 1))
			ultimo = i
		i += 1
print('\n'.join(resp))


try:
	n = int(input())
	a = list(map(int, input().split()))
	commands = []
	max_neg_index = None
	neg_count = 0
	last_zero = None
	last_positive = None

	def add_command_1(pos1, pos2):
		commands.append(f'1 {pos1} {pos2}')

	def add_command_2(position):
		commands.append(f'2 {position}')
	for i in range(n):
		value = a[i]
		if value is None:
			continue
		elif value < 0:
			neg_count += 1
			if max_neg_index is None or value > a[max_neg_index - 1]:
				max_neg_index = i + 1
		elif value == 0:
			if last_zero:
				add_command_1(last_zero, i + 1)
			last_zero = i + 1
		else:
			if last_positive is not None:
				add_command_1(last_positive, i + 1)
				a[last_positive - 1] = None
			last_positive = i + 1
	if not neg_count % 2:
		max_neg_index = None
	last_negative = None
	for i in range(n):
		value = a[i]
		if value is None or value >= 0:
			continue
		if max_neg_index is not None and i == max_neg_index - 1:
			continue
		if last_negative is not None:
			add_command_1(last_negative, i + 1)
			value = a[last_negative - 1] * value
			a[last_negative - 1] = None
		last_negative = i + 1
	if max_neg_index is not None and last_zero is not None:
		add_command_1(max_neg_index, last_zero)
	elif max_neg_index is not None:
		if len(commands) < n - 1:
			add_command_2(max_neg_index)
	if last_negative is not None and last_positive is not None:
		add_command_1(last_negative, last_positive)
	if last_zero is not None:
		if len(commands) < n - 1:
			add_command_2(last_zero)
	print('\n'.join(commands))
except Exception as exc:
	import traceback
	print(traceback.format_exc())


def main():
	n = int(input())
	a = list(map(int, input().split()))
	kill_idx = build_idx = n
	num_negs = num_pos = 0
	min_neg = (-2 * 10 ** 9, -1)
	max_neg = (1, -1)
	first_two_negs = [-1, -1]
	for (c, x) in enumerate(a):
		if x < 0:
			num_negs += 1
			if num_negs < 3:
				first_two_negs[num_negs - 1] = c
			if min_neg[0] < x:
				min_neg = (x, c)
			if max_neg[0] > x:
				max_neg = (x, c)
		elif x == 0:
			kill_idx = min(kill_idx, c)
		else:
			num_pos += 1
			build_idx = min(build_idx, c)
	if min_neg == max_neg and num_negs >= 2:
		max_neg = (a[first_two_negs[1]], first_two_negs[1])
	num_zeroes = n - num_negs - num_pos
	if kill_idx == n:
		if num_negs % 2 == 0:
			pass
		else:
			kill_idx = min_neg[1]
	if build_idx == n and num_negs > 1:
		build_idx = max_neg[1]
	for (c, x) in enumerate(a):
		if x > 0:
			if c == build_idx:
				continue
			print(1, c + 1, build_idx + 1)
		elif x == 0:
			if kill_idx == c:
				pass
			else:
				print(1, c + 1, kill_idx + 1)
		elif c == min_neg[1] and num_negs % 2 != 0:
			if kill_idx == c:
				pass
			else:
				print(1, c + 1, kill_idx + 1)
		elif c == build_idx:
			pass
		else:
			print(1, c + 1, build_idx + 1)
	if kill_idx == n:
		pass
	elif num_pos == 0:
		if num_zeroes == 0:
			print(2, kill_idx + 1)
			return
		else:
			if num_negs <= 1:
				return
			print(2, kill_idx + 1)
			return
	else:
		print(2, kill_idx + 1)
main()


from bisect import bisect

def main():
	input()
	l = sorted(((a, i) for (i, a) in enumerate(map(int, input().split()), 1)))
	(i, j) = (bisect(l, (0, -1)), bisect(l, (1, -1)))
	l = [i for (_, i) in l]
	(nn, zz, pp) = (l[:i], l[i:j], l[j:])
	(r, t) = ([], 0)
	if zz:
		t = zz.pop()
		for a in zz:
			r.append(f'1 {a} {t}')
	if len(nn) & 1:
		if t:
			r.append(f'1 {nn.pop()} {t}')
		else:
			t = nn.pop()
	nn += pp
	if nn:
		if t:
			r.append(f'2 {t}')
		t = nn.pop()
		for a in nn:
			r.append(f'1 {a} {t}')
	print('\n'.join(r))
main()


n = int(input())
v = list(map(int, input().split()))
(out, best, sub, zero) = ([0] * n, -1 << 30, [], [])
for i in range(n):
	if v[i] < 0:
		sub.append(i)
		if best < v[i]:
			best = v[i]
			isb = i
	elif v[i] == 0:
		zero.append(i)
op = 0

def f(v):
	global op
	if op == n - 1:
		return
	op += 1
	for x in v:
		print(x, end=' ')
	print()
	out[v[1] - 1] = 1
if len(zero) == 0:
	if len(sub) & 1:
		f([2, isb + 1])
else:
	for i in range(len(zero) - 1):
		f([1, zero[i] + 1, zero[i + 1] + 1])
	if len(sub) & 1:
		f([1, isb + 1, zero[-1] + 1])
	f([2, zero[-1] + 1])
for i in range(n - 1):
	if out[i]:
		continue
	j = i + 1
	while j < n and out[j]:
		j += 1
	if j < n:
		f([1, i + 1, j + 1])


from sys import stdin, stdout
from math import gcd, sqrt, factorial, pi, inf
from collections import deque, defaultdict
from bisect import bisect, bisect_left
from time import time
from itertools import permutations as per
from heapq import heapify, heappush, heappop, heappushpop
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\r\n')
L = lambda : list(R())
P = lambda x: stdout.write(str(x) + '\n')
lcm = lambda x, y: x * y // gcd(x, y)
nCr = lambda x, y: f[x] * inv(f[y] * f[x - y] % N) % N
inv = lambda x: pow(x, N - 2, N)
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
n = I()
a = L()
zeros = [i + 1 for i in range(n) if not a[i]]
mn = -inf
id = 0
minus = 0
op = 0
for i in range(n):
	if a[i] < 0:
		minus += 1
		if a[i] > mn:
			mn = a[i]
			id = i
if len(zeros) > 1:
	for i in range(1, len(zeros)):
		print(1, zeros[i], zeros[0])
		op += 1
	zeros = zeros[:1]
if minus & 1:
	a[id] = 0
	if zeros:
		print(1, id + 1, zeros[0])
	else:
		print(2, id + 1)
	op += 1
if zeros and op != n - 1:
	print(2, zeros[0])
a = [i + 1 for i in range(n) if a[i]]
for i in range(1, len(a)):
	print(1, a[i], a[0])


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
from collections import defaultdict
from itertools import permutations
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')
n = int(input())
a = list(map(int, input().split()))
ct = 0
mx = -10 ** 9
ind = -1
reject = list()
ok = list()
for i in range(n):
	if a[i] < 0:
		ct += 1
		if a[i] >= mx:
			mx = a[i]
			ind = i
if ct % 2 == 1:
	a[ind] = 0.5
	reject.append(ind + 1)
for i in range(n):
	if a[i] == 0:
		reject.append(i + 1)
		a[i] = 0.5
reject.sort()
for i in range(len(reject) - 1):
	print('1', reject[i], reject[i + 1])
if len(reject) > 0 and len(reject) != n:
	print('2', reject[-1])
for i in range(n):
	if a[i] != 0.5:
		ok.append(i + 1)
for i in range(len(ok) - 1):
	print('1', ok[i], ok[i + 1])


import atexit
import io
import sys
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

def main():
	n = int(input())
	arr = [(x[1], x[0] + 1) for x in enumerate(list(map(int, input().split())))]
	neg = []
	pos = []
	zer = []
	ops = 0
	for v in arr:
		if v[0] == 0:
			zer.append(v)
		elif v[0] > 0:
			pos.append(v)
		else:
			neg.append(v)
	extra = True
	while len(zer) > 1:
		pair = zer.pop()
		print(1, pair[1], zer[-1][1])
		ops += 1
	if ops == n - 1:
		exit(0)
	if len(neg) & 1 == 1 and len(zer) == 1:
		pair = neg.pop(neg.index(max(neg)))
		print(1, pair[1], zer[0][1])
		ops += 1
		if ops == n - 1:
			exit(0)
		pair = zer.pop()
		print(2, pair[1])
		extra = False
		ops += 1
		if ops == n - 1:
			exit(0)
	if ops == n - 1:
		exit(0)
	if len(zer) > 0:
		pair = zer.pop()
		print(2, pair[1])
		extra = False
		ops += 1
	if ops == n - 1:
		exit(0)
	if extra is True and len(neg) & 1 == 1:
		pair = neg.pop(neg.index(max(neg)))
		print(2, pair[1])
		ops += 1
	all = neg + pos
	if ops == n - 1:
		exit(0)
	for i in range(len(all) - 1):
		first = all[i]
		second = all[i + 1]
		print(1, first[1], second[1])
main()


n = int(input())
l = list(map(int, input().split()))
neg = list()
zero = list()
mneg = None
for i in range(n):
	if l[i] == 0:
		zero.append(i)
	elif l[i] < 0:
		neg.append(i)
		if mneg is None or l[i] > l[mneg]:
			mneg = i
if len(neg) % 2 == 0:
	i = 0
	while len(zero) - 1 > i:
		print(1, zero[i] + 1, zero[i + 1] + 1, sep=' ')
		i += 1
	if len(zero) - 1 == i and len(zero) != n:
		print(2, zero[i] + 1)
	(i, j) = (0, 1)
	while j < n and i < n:
		if l[i] != 0:
			if l[j] != 0 and j > i:
				print(1, i + 1, j + 1, sep=' ')
				i = j
				j = i + 1
			else:
				j = j + 1
		else:
			i = i + 1
else:
	i = 0
	while len(zero) - 1 > i:
		print(1, zero[i] + 1, zero[i + 1] + 1, sep=' ')
		i += 1
	if len(zero) - 1 == i:
		print(1, zero[i] + 1, mneg + 1, sep=' ')
		if len(zero) != n - 1:
			print(2, mneg + 1)
		l[mneg] = 0
	else:
		if len(zero) != n - 1:
			print(2, mneg + 1)
		l[mneg] = 0
	(i, j) = (0, 1)
	while j < n and i < n:
		if l[i] != 0:
			if l[j] != 0 and j > i:
				print(1, i + 1, j + 1, sep=' ')
				i = j
				j = i + 1
			else:
				j = j + 1
		else:
			i = i + 1


n = int(input())
b = list(map(int, input().split()))
k = 0
c = []
r = 1000000000000
for j in range(n):
	if b[j] == 0:
		c.append(j + 1)
	elif b[j] < 0:
		k += 1
		if abs(b[j]) < r:
			r = abs(b[j])
			q = j + 1
	if b[j] != 0:
		p = j
for j in range(n):
	if b[j] != 0 and k != 0 and (j != q - 1):
		s = j
f = []
j = 1
while j < len(c):
	f.append([1, c[j], c[0]])
	j += 1
if k % 2 != 0:
	if len(c) > 0 and len(f) != n - 1:
		f.append([1, q, c[0]])
		if len(f) != n - 1:
			f.append([2, c[0]])
			for j in range(n):
				if b[j] != 0 and j != q - 1 and (j != s):
					f.append([1, j + 1, s + 1])
	elif len(f) != n - 1:
		f.append([2, q])
		for j in range(n):
			if b[j] != 0 and j != q - 1 and (j != s):
				f.append([1, j + 1, s + 1])
elif len(c) > 0:
	if len(f) != n - 1:
		f.append([2, c[0]])
		for j in range(n):
			if b[j] != 0 and j != p:
				f.append([1, j + 1, p + 1])
else:
	for j in range(n):
		if b[j] != 0 and j != p:
			f.append([1, j + 1, p + 1])
for j in f:
	print(*j)


n = int(input())
a = list(map(int, input().split()))
ze = []
ng = []
po = []
for i in range(n):
	if a[i] > 0:
		po.append(i)
	elif a[i] < 0:
		ng.append(i)
	else:
		ze.append(i)

def ma():
	j = ng[0]
	ans = a[ng[0]]
	for i in range(len(ng)):
		if a[ng[i]] > ans:
			j = i
			ans = a[ng[i]]
	return ans

def cof(z, zz, zzz):
	if z != -1:
		if zz != -1:
			print(1, zz + 1, z + 1)
		if zzz != -1:
			print(1, zzz + 1, z + 1)
	elif zz != -1:
		if z != -1:
			print(1, z + 1, zz + 1)
		if zzz != -1:
			print(1, zzz + 1, zz + 1)
	else:
		if z != -1:
			print(1, z + 1, zzz + 1)
		if zz != -1:
			print(1, zz + 1, zzz + 1)
if len(ng) % 2 == 1:
	i = a.index(ma())
	(z, zz, zzz) = (-1, -1, -1)
	if len(po) == 1:
		zzz = po[0]
	if len(ze) == 1:
		z = ze[-1]
	op = 0
	for j in range(len(ze) - 1):
		op += 1
		z = ze[j + 1]
		print(1, ze[j] + 1, ze[j + 1] + 1)
	for j in range(len(ng) - 1):
		if ng[j] == i:
			continue
		if ng[j + 1] == i:
			if j + 2 < len(ng):
				op += 1
				zz = ng[j + 2]
				print(1, ng[j] + 1, ng[j + 2] + 1)
		else:
			zz = ng[j + 1]
			op += 1
			print(1, ng[j] + 1, ng[j + 1] + 1)
	for j in range(len(po) - 1):
		zzz = po[j + 1]
		print(1, po[j] + 1, po[j + 1] + 1)
	if z != -1:
		op += 1
		print(1, z + 1, i + 1)
	z = -1
	if op < n - 1:
		print(2, i + 1)
	cof(z, zz, zzz)
else:
	(z, zz, zzz) = (-1, -1, -1)
	for j in range(len(ze) - 1):
		z = ze[j + 1]
		print(1, ze[j] + 1, ze[j + 1] + 1)
	for j in range(len(ng) - 1):
		zz = ng[j + 1]
		print(1, ng[j] + 1, ng[j + 1] + 1)
	for j in range(len(po) - 1):
		zzz = po[j + 1]
		print(1, po[j] + 1, po[j + 1] + 1)
	if len(ze) > 0 and len(ze) != n:
		print(2, ze[-1] + 1)
	z = -1
	if len(po) == 1:
		zzz = po[0]
	cof(z, zz, zzz)


def solve(arr: list) -> None:
	arr1 = []
	arr2 = []
	maxVal = 0
	index = -1
	negCnt = 0
	for i in range(len(arr)):
		if arr[i] > 0:
			arr1.append(i)
		elif arr[i] == 0:
			arr2.append(i)
		elif arr[i] < 0:
			if maxVal == 0 or arr[i] > maxVal:
				maxVal = arr[i]
				index = i
			arr1.append(i)
			negCnt += 1
	if negCnt % 2 == 1:
		arr1.remove(index)
		arr2.append(index)
	for i in range(len(arr1) - 1):
		print(1, arr1[i] + 1, arr1[i + 1] + 1)
	for i in range(len(arr2)):
		if i == len(arr2) - 1:
			if arr1:
				print(2, arr2[i] + 1)
		else:
			print(1, arr2[i] + 1, arr2[i + 1] + 1)
	return
input()
arr = list(map(int, input().split()))
solve(arr)


n = int(input())
a = list(map(int, input().split()))
(cnt_zero, cnt_nega, cnt_nega_max, cnt_nega_max_pos) = (0, 0, -10000000000.0, -1)
used = [0] * n
for (i, v) in enumerate(a):
	if v == 0:
		cnt_zero += 1
		used[i] = 1
		continue
	if v < 0:
		cnt_nega += 1
		if cnt_nega_max_pos == -1 or cnt_nega_max < v:
			cnt_nega_max = v
			cnt_nega_max_pos = i
if cnt_nega % 2 == 1:
	used[cnt_nega_max_pos] = 1
if cnt_zero == n or (cnt_zero == n - 1 and cnt_nega == 1):
	for i in range(n - 1):
		print('1', i + 1, i + 2)
else:
	left = -1
	for i in range(n):
		if used[i] == 1:
			if left != -1:
				print('1', left + 1, i + 1)
			left = i
	if left != -1:
		print('2', left + 1)
	left = -1
	for i in range(n):
		if used[i] == 0:
			if left != -1:
				print('1', left + 1, i + 1)
			left = i


import sys
n = int(input())
l = list(map(int, sys.stdin.readline().rstrip().split()))
temp = [i for i in range(1, n + 1)]
temp = set(temp)
lt = n
neg = []
cntn = 0
cnt0 = 0
f0 = 0
f1 = 0
ze = []
idx = -1
mn = -10 ** 9 - 10
for i in range(n):
	if l[i] < 0:
		cntn += 1
		f1 = 1
		if l[i] > mn:
			mn = l[i]
			idx = i + 1
	elif l[i] == 0:
		f0 = 1
		cnt0 += 1
		ze.append(i + 1)
if f0:
	if f1:
		if cntn % 2:
			for i in range(cnt0 - 1):
				print(1, ze[i], ze[i + 1])
				temp.remove(ze[i])
				lt -= 1
			print(1, ze[cnt0 - 1], idx)
			temp.remove(ze[cnt0 - 1])
			lt -= 1
			if lt > 1:
				print(2, idx)
				temp.remove(idx)
				lt -= 1
			temp = list(temp)
			for i in range(lt - 1):
				print(1, temp[i], temp[i + 1])
		else:
			for i in range(cnt0 - 1):
				print(1, ze[i], ze[i + 1])
				temp.remove(ze[i])
				lt -= 1
			if lt > 1:
				print(2, ze[cnt0 - 1])
				temp.remove(ze[cnt0 - 1])
				lt -= 1
			temp = list(temp)
			for i in range(lt - 1):
				print(1, temp[i], temp[i + 1])
	else:
		for i in range(cnt0 - 1):
			print(1, ze[i], ze[i + 1])
			temp.remove(ze[i])
			lt -= 1
		if lt > 1:
			print(2, ze[cnt0 - 1])
			temp.remove(ze[cnt0 - 1])
			lt -= 1
		temp = list(temp)
		for i in range(lt - 1):
			print(1, temp[i], temp[i + 1])
elif f1:
	if cntn % 2:
		neg.sort(key=lambda x: x[0], reverse=True)
		print(2, idx)
		temp.remove(idx)
		lt -= 1
		temp = list(temp)
		for i in range(lt - 1):
			print(1, temp[i], temp[i + 1])
	else:
		temp = list(temp)
		for i in range(lt - 1):
			print(1, temp[i], temp[i + 1])
else:
	temp = list(temp)
	for i in range(lt - 1):
		print(1, temp[i], temp[i + 1])


n = input()
n = int(n)
a = input()
a = list(a.split(' '))
neg = []
pos = []
zero = []
maxx = -10000000000
idx = 0
for i in range(n):
	a[i] = int(a[i])
	if a[i] < 0:
		neg.append(i + 1)
		if maxx < a[i]:
			maxx = a[i]
			idx = i + 1
	elif a[i] == 0:
		zero.append(i + 1)
	else:
		pos.append(i + 1)
res = []
if len(neg) % 2 == 1 and len(zero) != 0:
	zero.append(idx)
	neg.remove(idx)
	for i in range(0, len(zero) - 1, 1):
		t = (1, zero[i], zero[i + 1])
		res.append(t)
	if len(zero) != n:
		t = (2, zero[len(zero) - 1])
		res.append(t)
elif len(neg) % 2 == 1:
	t = (2, idx)
	neg.remove(idx)
	res.append(t)
	neg.extend(zero)
elif len(zero) != 0:
	for i in range(0, len(zero) - 1, 1):
		t = (1, zero[i], zero[i + 1])
		res.append(t)
	t = (2, zero[len(zero) - 1])
	if len(zero) != n:
		res.append(t)
neg.extend(pos)
l = len(neg)
for i in range(0, l - 1, 1):
	t = (1, neg[i], neg[i + 1])
	res.append(t)
for x in res:
	for u in x:
		print(u, end=' ')
	print()


n = int(input())
arr = list(map(int, input().split()))
nc = 0
zc = 0
for i in arr:
	if i < 0:
		nc += 1
	elif i == 0:
		zc += 1
nc = nc % 2
if nc == 1:
	nu = -float('inf')
	ind = -1
	for i in range(n):
		if arr[i] < 0 and arr[i] > nu:
			nu = arr[i]
			ind = i
	if zc == 0:
		print(2, ind + 1)
		if ind != 0:
			for i in range(1, n):
				if i != ind:
					print(1, i + 1, 1)
		else:
			for i in range(2, n):
				if i != ind:
					print(1, i + 1, 2)
	else:
		cnt = 0
		for i in range(n):
			if arr[i] == 0:
				cnt += 1
				print(1, i + 1, ind + 1)
		if cnt < n - 1:
			print(2, ind + 1)
		sp = -1
		for i in range(n):
			if arr[i] != 0 and i != ind:
				sp = i
				break
		if sp != -1:
			for i in range(n):
				if arr[i] != 0 and i != ind and (i != sp):
					print(1, i + 1, sp + 1)
elif zc != 0:
	ind = -1
	cnt = 0
	for i in range(n):
		if arr[i] == 0:
			ind = i
			break
	for i in range(n):
		if arr[i] == 0 and i != ind:
			cnt += 1
			print(1, i + 1, ind + 1)
	if cnt < n - 1:
		print(2, ind + 1)
	sp = -1
	for i in range(n):
		if arr[i] != 0:
			sp = i
			break
	if sp != -1:
		for i in range(n):
			if arr[i] != 0 and i != sp:
				print(1, i + 1, sp + 1)
else:
	for i in range(1, n):
		print(1, i + 1, 1)


n = int(input())
arr = list(map(int, input().split()))
pos = []
neg = []
zer = []
max_Negative = -1
for i in range(n):
	if arr[i] > 0:
		pos.append(i + 1)
	elif arr[i] == 0:
		zer.append(i + 1)
	elif max_Negative == -1:
		max_Negative = i
	elif arr[max_Negative] < arr[i]:
		max_Negative = i
if n - len(pos) - len(zer) & 1:
	zer.append(max_Negative + 1)
	for i in range(n):
		if arr[i] < 0 and i != max_Negative:
			pos.append(i + 1)
else:
	for i in range(n):
		if arr[i] < 0:
			pos.append(i + 1)
for i in range(len(pos) - 1):
	print(1, pos[i], pos[i + 1])
for i in range(len(zer) - 1):
	print(1, zer[i], zer[i + 1])
if len(zer) > 0 and len(pos) != 0:
	print(2, zer[-1])


n = int(input())
u = list(map(int, input().split()))
otr = 0
null = []
omax = -10 ** 9 - 1
omaxi = -1
for i in range(n):
	if u[i] < 0:
		otr += 1
		if u[i] > omax:
			omax = u[i]
			omaxi = i
	elif u[i] == 0:
		null.append(i)
for i in range(len(null) - 1):
	print(1, null[i] + 1, null[-1] + 1)
	u[null[i]] = '-'
if len(null) == n:
	exit()
if len(null) + 1 == n and otr == 1:
	print(1, min(omaxi, null[-1]) + 1, max(omaxi, null[-1]) + 1)
	exit()
if otr % 2 == 1:
	if len(null) != 0:
		print(1, omaxi + 1, null[-1] + 1)
		print(2, null[-1] + 1)
		u[omaxi] = '-'
		u[null[-1]] = '-'
	else:
		print(2, omaxi + 1)
		u[omaxi] = '-'
elif len(null) != 0:
	print(2, null[-1] + 1)
	u[null[-1]] = '-'
j = -1
for i in range(n - 1, -1, -1):
	if u[i] != '-':
		j = i
		break
for i in range(j):
	if u[i] != '-':
		print(1, i + 1, j + 1)


from functools import reduce
n = int(input())
a = [int(x) for x in input().split(' ')]
part1 = []
part2 = []
neg = []
s = -1
for (i, x) in enumerate(a):
	if x < 0:
		if s == -1:
			s = i
			continue
		if a[s] < x:
			neg.append(s + 1)
			s = i
		else:
			neg.append(i + 1)
	if x == 0:
		part1.append(i + 1)
	if x > 0:
		part2.append(i + 1)
ans = 1
if len(neg) % 2 == 0 and s != -1:
	part1.append(s + 1)
if len(neg) % 2 == 1:
	part2.append(s + 1)
part2 = part2 + neg
s = 10 ** 10
for i in part1:
	if s == 10 ** 10:
		s = i
		continue
	print(1, s, i)
	s = i
if s != 10 ** 10 and len(part2) != 0:
	print(2, s)
s = 10 ** 10
for i in part2:
	if s == 10 ** 10:
		s = i
		continue
	print(1, s, i)
	s = i


import bisect
n = int(input())
A = list(map(int, input().split()))
B = sorted(A)
l = bisect.bisect_left(B, 0)
r = bisect.bisect_right(B, 0)
MINUS = B[:l]
PLUS = B[r:]
ZERO = B[l:r]
ZEROLIST = []
for i in range(n):
	if A[i] == 0:
		ZEROLIST.append(i)
USED = []
if len(ZERO) == n:
	True
elif len(ZERO) == n - 1 and len(MINUS) == 1:
	True
elif len(MINUS) % 2 == 0 and len(ZERO) != 0:
	for i in range(1, len(ZEROLIST)):
		print(1, ZEROLIST[i - 1] + 1, ZEROLIST[i] + 1)
		USED.append(ZEROLIST[i - 1] + 1)
	print(2, ZEROLIST[-1] + 1)
	USED.append(ZEROLIST[-1] + 1)
elif len(MINUS) % 2 == 0 and len(ZERO) == 0:
	True
elif len(MINUS) % 2 == 1 and len(ZERO) == 0:
	DEL = MINUS[-1]
	print(2, A.index(DEL) + 1)
	USED.append(A.index(DEL) + 1)
elif len(MINUS) % 2 == 1 and len(ZERO) != 0:
	DEL = MINUS[-1]
	ZEROLIST.append(A.index(DEL))
	for i in range(1, len(ZEROLIST)):
		print(1, ZEROLIST[i - 1] + 1, ZEROLIST[i] + 1)
		USED.append(ZEROLIST[i - 1] + 1)
	print(2, ZEROLIST[-1] + 1)
	USED.append(ZEROLIST[-1] + 1)
	True
NOKORI = sorted(list(set(range(1, n + 1)) - set(USED)))
for i in range(1, len(NOKORI)):
	print(1, NOKORI[i - 1], NOKORI[i])


n = int(input())
ai = list(map(int, input().split()))
maxNegNumber = -10000000000
maxInd = 0
numberOfNeg = 0
for i in range(n):
	if ai[i] < 0:
		numberOfNeg += 1
		if maxNegNumber < ai[i]:
			maxInd = i
			maxNegNumber = ai[i]
prev = -1
num0 = 0
for i in range(n):
	if ai[i] > 0:
		if prev == -1:
			prev = i
			continue
		print(1, prev + 1, i + 1)
		prev = i
for i in range(n):
	if ai[i] < 0 and (numberOfNeg % 2 == 0 or maxInd != i):
		if prev == -1:
			prev = i
			continue
		print(1, prev + 1, i + 1)
		prev = i
prev = -1
for i in range(n):
	if ai[i] == 0:
		num0 += 1
		if prev == -1:
			prev = i
			continue
		print(1, prev + 1, i + 1)
		prev = i
if prev != -1 and numberOfNeg % 2 == 1:
	print(1, prev + 1, maxInd + 1)
	if num0 != n - 1:
		print(2, maxInd + 1)
elif prev != -1:
	if num0 != n:
		print(2, prev + 1)
elif numberOfNeg % 2 == 1:
	print(2, maxInd + 1)


from enum import Enum

class OperationType(Enum):
	Multiply = 1
	Remove = 2

class RemoveOperation:

	def __init__(self, index):
		self.type = OperationType.Remove
		self.index = index

	def __repr__(self):
		return 'RemoveOperation({})'.format(self.index)

class MultiplyOperation:

	def __init__(self, index_a, index_b):
		self.type = OperationType.Multiply
		self.index_a = index_a
		self.index_b = index_b

	def __repr__(self):
		return 'MultiplyOperation({}, {})'.format(self.index_a, self.index_b)

def multiply_remaining(removed, n):
	operations = []
	keep_indices = set(range(1, n + 1)) - set(removed)
	previous = None
	for index in sorted(keep_indices):
		if previous is not None:
			operations.append(MultiplyOperation(previous, index))
		previous = index
	return operations

def multiply_everything(n):
	operations = []
	for i in range(1, n):
		operations.append(MultiplyOperation(i, i + 1))
	return operations

def remove_indices_and_multiply_remaining(removed, n):
	operations = []
	keep_indices = set(range(1, n + 1)) - set(removed)
	previous = None
	for index in sorted(keep_indices):
		if previous is not None:
			operations.append(MultiplyOperation(previous, index))
		previous = index
	return operations

def find_zero_indices(xs):
	zero_indices = []
	for (index, x) in enumerate(xs):
		if x == 0:
			zero_indices.append(index + 1)
	return zero_indices

def remove_indices_and_multiply_remaining(indices_to_remove, n):
	operations = []
	previous = None
	for index in indices_to_remove:
		if previous is not None:
			operations.append(MultiplyOperation(previous, index))
		previous = index
	if len(indices_to_remove) < n:
		operations.append(RemoveOperation(previous))
		operations += multiply_remaining(indices_to_remove, n)
	return operations

def find_index_of_largest_negative(xs):
	maximum = float('-inf')
	maximum_index = None
	for (index, x) in enumerate(xs):
		if x < 0 and x > maximum:
			maximum = x
			maximum_index = index
	return maximum_index + 1

def solve(xs):
	n = len(xs)
	negatives = 0
	zeros = 0
	for x in xs:
		if x == 0:
			zeros += 1
		if x < 0:
			negatives += 1
	if zeros == 0 and negatives == 0:
		return multiply_everything(n)
	elif zeros == n:
		return multiply_everything(n)
	elif zeros == 0 and negatives > 0:
		if negatives % 2 == 0:
			return multiply_everything(n)
		else:
			return remove_indices_and_multiply_remaining([find_index_of_largest_negative(xs)], n)
	elif negatives == 0 and zeros > 0:
		return remove_indices_and_multiply_remaining(find_zero_indices(xs), n)
	elif negatives % 2 == 0:
		return remove_indices_and_multiply_remaining(find_zero_indices(xs), n)
	else:
		indices_to_remove = sorted([find_index_of_largest_negative(xs)] + find_zero_indices(xs))
		return remove_indices_and_multiply_remaining(indices_to_remove, n)

def verify(xs, maximum):
	solution = solve(xs)
	assert len(solution) == len(xs) - 1
	num_removes = 0
	removed = [False] * len(xs)
	for operation in solution:
		if operation.type is OperationType.Remove:
			assert not removed[operation.index - 1]
			num_removes += 1
			removed[operation.index - 1] = True
		elif operation.type is OperationType.Multiply:
			assert not removed[operation.index_a - 1]
			assert not removed[operation.index_b - 1]
			removed[operation.index_a - 1] = True
			xs[operation.index_b - 1] *= xs[operation.index_a - 1]
	assert num_removes <= 1
	num_remaining = 0
	remaining_index = -1
	for (index, value) in enumerate(xs):
		if not removed[index]:
			num_remaining += 1
			remaining_index = index
	assert num_remaining == 1
	assert maximum == xs[remaining_index]
n = int(input())
xs = list(map(int, input().split()))[:n]
for operation in solve(xs):
	if operation.type is OperationType.Multiply:
		print(1, operation.index_a, operation.index_b)
	else:
		print(2, operation.index)


n = int(input())
a = list(map(int, input().split()))
hu = 0
humax = -float('inf')
huind = None
able = set(range(n))
ans = []
mae = -1
for i in range(n):
	if a[i] == 0:
		if mae == -1:
			mae = i
			able.discard(i)
		else:
			ans.append([1, mae + 1, i + 1])
			able.discard(i)
			mae = i
	if a[i] < 0:
		hu += 1
		if a[i] > humax:
			humax = a[i]
			huind = i
if hu % 2 == 1:
	if mae == -1:
		ans.append([2, huind + 1])
		able.discard(huind)
		mae = huind
	else:
		ans.append([1, mae + 1, huind + 1])
		able.discard(huind)
		ans.append([2, huind + 1])
		mae = huind
		if able == set():
			ans.pop(-2)
			able.add(0)
if a[mae] == 0:
	ans.append([2, mae + 1])
if able == set():
	ans.pop()
mae = -1
for i in able:
	if mae == -1:
		mae = i
	else:
		ans.append([1, mae + 1, i + 1])
		mae = i
for i in ans:
	print(*i)


n = int(input())
a = list(map(int, input().split()))
mn = min(a)
mx = max(a)
if mn == mx and a[0] == 0:
	for i in range(n - 1):
		print('1', i + 1, n)
	exit(0)
if mn < 0 and mx == 0:
	cnt = 0
	for it in a:
		if it < 0:
			cnt += 1
			if cnt > 1:
				break
	if cnt == 1:
		pz = 0 if a[0] == 0 else 1
		for i in range(n):
			if i != pz:
				print('1', i + 1, pz + 1)
		exit(0)
last = n - 1
while a[last] == 0:
	last -= 1
lastZero = -1
for i in range(n):
	if a[i] == 0:
		lastZero = i
cnt = 0
for i in range(last + 1):
	if a[i] < 0:
		cnt += 1
if cnt % 2 == 0:
	for i in range(n):
		if i == lastZero:
			continue
		if a[i] == 0:
			print('1', i + 1, lastZero + 1)
		elif i != last:
			print('1', i + 1, last + 1)
	if lastZero != -1:
		print('2', lastZero + 1)
	exit(0)
mn = -1
for i in range(last + 1):
	if a[i] >= 0:
		continue
	if mn == -1 or abs(a[mn]) > abs(a[i]):
		mn = i
if mn == last:
	last -= 1
	while a[last] == 0:
		last -= 1
for i in range(last):
	if i == mn:
		continue
	if a[i] == 0:
		print('1', i + 1, mn + 1)
	else:
		print('1', i + 1, last + 1)
for i in range(last + 1, n):
	if i != mn:
		print('1', i + 1, mn + 1)
print('2', mn + 1)


n = int(input())
s = [[a, b + 1] for (b, a) in enumerate(map(int, input().split()))]
zeros = []
negs = []
for (i, j) in s:
	if i == 0:
		zeros.append([i, j])
	elif i < 0:
		negs.append([i, j])
for i in range(1, len(zeros)):
	s[zeros[i - 1][1] - 1] = [0, 0]
	print(1, zeros[i - 1][1], zeros[i][1])
ff = 0
if zeros:
	if len(negs) % 2:
		f = max(negs)
		s[f[1] - 1] = [0, 0]
		print(1, f[1], zeros[-1][1])
		ff = 1
	s[zeros[-1][1] - 1] = [0, 0]
	if len(zeros) != n - ff:
		print(2, zeros[-1][1])
elif len(negs) % 2:
	f = max(negs)
	s[f[1] - 1] = [0, 0]
	print(2, f[1])
p = 0
for (i, j) in s:
	if i:
		if p:
			print(1, p, j)
		p = j


from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from heapq import heappush, heappop
import math
import io
import os
import math
import bisect

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def sieve(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 digits(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def ceil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def mapin():
	return map(int, input().split())
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
l = [int(x) for x in input().split()]
ans = 0
mi = -10000000000.0
ct = 0
po = 0
z = [0] * n
zzz = []
for i in range(n):
	if l[i] < 0:
		if l[i] > mi:
			mi = l[i]
			po = i
		ct += 1
	elif l[i] == 0:
		z[i] = 1
		zzz.append(i + 1)
if ct & 1:
	z[po] = 1
	zzz.append(po + 1)
zz = []
for i in range(n):
	if z[i] == 0:
		zz.append(i + 1)
if z.count(1) == 0:
	for i in range(1, len(zz)):
		print(1, zz[i], zz[0])
elif z.count(1) == 1:
	for i in range(n):
		if z[i] == 1:
			print(2, i + 1)
	for i in range(1, len(zz)):
		print(1, zz[i], zz[0])
else:
	for i in range(1, len(zzz)):
		print(1, zzz[i], zzz[0])
	if len(zz) > 0:
		print(2, zzz[0])
		for i in range(1, len(zz)):
			print(1, zz[i], zz[0])


def main():
	n = int(input())
	a = list(map(int, input().split()))
	(cnt_z, cnt_n, idx) = (0, 0, -1)
	z_idx = []
	a.append(-10 ** 9 - 1)
	for i in range(n):
		if a[i] < 0:
			cnt_n += 1
			idx = i if a[idx] < a[i] else idx
		elif not a[i]:
			cnt_z += 1
			z_idx.append(i)
	if cnt_z == n or (cnt_z == n - 1 and cnt_n == 1):
		for i in range(n - 1):
			print(1, i + 1, i + 2)
		return
	used = [0 for i in range(n)]
	for i in range(cnt_z - 1):
		print(1, z_idx[i] + 1, z_idx[i + 1] + 1)
		used[z_idx[i]] = 1
	if cnt_n % 2 and cnt_z:
		print(1, idx + 1, z_idx[-1] + 1)
		used[idx] = 1
	elif cnt_n % 2:
		z_idx.append(idx)
	if len(z_idx):
		print(2, z_idx[-1] + 1)
		used[z_idx[-1]] = 1
	lst = -1
	for i in range(n):
		if not used[i]:
			if lst != -1:
				print(1, lst + 1, i + 1)
			lst = i

def __starting_point():
	main()
__starting_point()


n = int(input())
l = list(map(int, input().split()))
neg = []
zer = []
ans = []
s = set()
st = 1
ma = -9999999999999999999999999999999
count = 0
d = dict()
for i in range(n):
	if l[i] < 0:
		neg.append(i + 1)
		ma = max(l[i], ma)
		if l[i] in d:
			d[l[i]] += 1
		else:
			d.update({l[i]: 1})
		if l[i] != ma or d[l[i]] > 1:
			st = i + 1
	elif l[i] == 0:
		zer.append(i + 1)
	else:
		st = i + 1
if len(neg) % 2 == 1:
	ind = l.index(ma)
	for i in range(1, len(zer)):
		ans.append([1, zer[i], zer[0]])
		s.add(zer[i] - 1)
	if len(zer) != 0:
		ans.append([1, zer[0], ind + 1])
		s.add(zer[0] - 1)
	ans.append([2, ind + 1])
	s.add(ind)
	for i in range(n):
		if i in s or i == st - 1:
			continue
		ans.append([1, i + 1, st])
else:
	for i in range(1, len(zer)):
		ans.append([1, zer[i], zer[0]])
		s.add(zer[i] - 1)
	if len(zer) != 0:
		ans.append([2, zer[0]])
		s.add(zer[0] - 1)
	for i in range(n):
		if i in s or i == st - 1:
			continue
		ans.append([1, i + 1, st])
for i in range(n - 1):
	print(*ans[i], sep=' ')


k = int(input())
a = list(map(int, input().split()))
z = []
n = []
rest = []
m = -99999999999
count = 0
for (i, j) in enumerate(a):
	if j < 0:
		n.append(i)
		rest.append(i)
		if m < j:
			m = j
			ind = i
	elif j == 0:
		z.append(i)
	else:
		rest.append(i)
if len(n) % 2 == 0 and len(z) == 0:
	for i in range(k - 1):
		print(1, i + 1, i + 2)
elif len(n) % 2 == 0:
	for i in range(len(z) - 1):
		print(1, z[i] + 1, z[i + 1] + 1)
		count += 1
	if count < k - 1 and len(z) > 0:
		print(2, z[-1] + 1)
	for i in range(len(rest) - 1):
		print(1, rest[i] + 1, rest[i + 1] + 1)
elif len(n) % 2 == 1:
	for i in range(len(z) - 1):
		print(1, z[i] + 1, z[i + 1] + 1)
		count += 1
	if count == 0:
		i = 0
	if len(z) > 0 and count != 0:
		print(1, z[i + 1] + 1, ind + 1)
		count += 1
	elif count == 0 and len(z) > 0:
		print(1, z[i] + 1, ind + 1)
		count += 1
	if count < k - 1:
		print(2, ind + 1)
	rest.remove(ind)
	for i in range(len(rest) - 1):
		print(1, rest[i] + 1, rest[i + 1] + 1)
else:
	for i in range(len(rest) - 1):
		print(1, rest[i] + 1, rest[i + 1] + 1)


n = int(input())
from sys import *
lst = [int(x) for x in stdin.readline().split()]
lst1 = []
lst2 = []
lst3 = []
c = 0
mk = 10000000000
for j in range(0, n):
	i = lst[j]
	if i > 0:
		lst1.append(str(j + 1))
	elif i < 0:
		lst2.append(str(j + 1))
		if abs(i) < mk:
			t = str(j + 1)
			mk = abs(i)
	else:
		lst3.append(str(j + 1))
		c = c + 1
fv = []
s = ''
if len(lst2) % 2 == 0:
	for i in range(0, len(lst3) - 1):
		s = '1' + ' ' + lst3[i] + ' ' + lst3[i + 1] + '\n'
		stdout.write(s)
	if len(lst3) != n and len(lst3) > 0:
		s = '2' + ' ' + lst3[-1] + '\n'
		stdout.write(s)
	t = lst1 + lst2
	for i in range(0, len(t) - 1):
		s = '1' + ' ' + t[i] + ' ' + t[i + 1] + '\n'
		stdout.write(s)
else:
	tk = lst3 + [t]
	tk2 = lst1
	for i in lst2:
		if i != t:
			tk2.append(i)
	lst3 = tk
	t = tk2
	for i in range(0, len(lst3) - 1):
		s = '1' + ' ' + lst3[i] + ' ' + lst3[i + 1] + '\n'
		stdout.write(s)
	if len(lst3) != n:
		s = '2' + ' ' + lst3[-1] + '\n'
		stdout.write(s)
	for i in range(0, len(t) - 1):
		s = '1' + ' ' + t[i] + ' ' + t[i + 1] + '\n'
		stdout.write(s)
ans = ''


import sys, os, io
from sys import stdin
from math import log, gcd, ceil
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import math
alphabets = list('abcdefghijklmnopqrstuvwxyz')

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

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 countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def si():
	return input()

def prefix_sum(arr):
	r = [0] * (len(arr) + 1)
	for (i, el) in enumerate(arr):
		r[i + 1] = r[i] + el
	return r

def divideCeil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

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

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

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')

def power_set(L):
	cardinality = len(L)
	n = 2 ** cardinality
	powerset = []
	for i in range(n):
		a = bin(i)[2:]
		subset = []
		for j in range(len(a)):
			if a[-j - 1] == '1':
				subset.append(L[j])
		powerset.append(subset)
	powerset_orderred = []
	for k in range(cardinality + 1):
		for w in powerset:
			if len(w) == k:
				powerset_orderred.append(w)
	return powerset_orderred

def fastPlrintNextLines(a):
	print('\n'.join(map(str, a)))

def sortByFirstAndSecond(A):
	A = sorted(A, key=lambda x: x[0])
	A = sorted(A, key=lambda x: x[1])
	return list(A)
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = 1
for _ in range(t):
	n = ii()
	l = li()
	ans = []
	prev = -1
	for i in range(n):
		if l[i] == 0:
			if prev == -1:
				prev = i
			else:
				ans.append([1, prev + 1, i + 1])
				prev = i
	temp = [-1, -1]
	if prev != -1:
		negcnt = 0
		maxneg = -100000000000000000000
		for i in l:
			if i < 0:
				maxneg = max(maxneg, i)
				negcnt += 1
		if negcnt % 2 == 1:
			ans.append([1, l.index(maxneg) + 1, prev + 1])
			l[l.index(maxneg)] = 0
		temp = [2, prev + 1]
	else:
		negcnt = 0
		maxneg = -100000000000000000000
		for i in l:
			if i < 0:
				maxneg = max(maxneg, i)
				negcnt += 1
		if negcnt % 2 == 1:
			ans.append([2, l.index(maxneg) + 1])
			l[l.index(maxneg)] = 0
	prev = -1
	for i in range(n):
		if l[i] != 0:
			if prev == -1:
				prev = i
			else:
				ans.append([1, prev + 1, i + 1])
				prev = i
	if prev != -1 and temp != [-1, -1]:
		ans.append(temp)
	for i in ans:
		print(*i)


n = int(input())
a = list(map(int, input().split()))
ct = 0
mn = 1000000000000000000
pos = 0
is_all_zero = True
for i in range(n):
	x = a[i]
	if x < 0:
		ct += 1
		if mn > abs(x):
			mn = abs(x)
			pos = i
if ct % 2 == 1:
	a[pos] = 0
for x in a:
	if x != 0:
		is_all_zero = False
if is_all_zero:
	for i in range(n - 1):
		print(1, i + 1, i + 2)
	exit(0)
pre = 0
pre0 = 0
for i in range(n):
	if a[i] == 0:
		if pre0:
			print(1, pre0, i + 1)
		pre0 = i + 1
	elif pre == 0:
		pre = i + 1
	else:
		print(1, pre, i + 1)
		pre = i + 1
if pre0:
	print(2, pre0)


import sys
n = int(input())
arr = list(map(int, input().split()))
arr2 = [[0] * 2 for i in range(n)]
j = 0
f = 0
maxNeg = -10000000000.0
maxNegInd = -1
t1 = []
indz = []
indo = []
arr3 = []
for i in arr:
	arr2[j][0] = i
	if i == 0:
		indz.append(j)
	elif i < 0:
		indo.append(j)
	else:
		arr3.append(j)
	if i < 0 and i > maxNeg:
		maxNeg = i
		maxNegInd = j
	j += 1
if len(indo) > 1:
	if len(indo) % 2 == 1:
		for it in indo:
			if it != maxNegInd:
				arr3.append(it)
	else:
		for it in indo:
			arr3.append(it)
for i in range(len(indz) - 1):
	arr2[indz[i]][1] = 1
	t1.append([indz[i], indz[i + 1]])
if len(indz) == len(arr):
	if t1:
		for items in t1:
			print('1 ' + str(items[0] + 1) + ' ' + str(items[1] + 1))
elif len(indz) + len(indo) == len(arr) and len(indo) == 1:
	if t1:
		for items in t1:
			print('1 ' + str(items[0] + 1) + ' ' + str(items[1] + 1))
	print(str(2) + ' ' + str(maxNegInd + 1))
else:
	if t1:
		for items in t1:
			print('1 ' + str(items[0] + 1) + ' ' + str(items[1] + 1))
	if len(indo) % 2 == 0:
		if indz:
			print('2 ' + str(indz[len(indz) - 1] + 1))
			arr2[indz[len(indz) - 1]][1] = 1
	elif indz:
		arr2[indz[len(indz) - 1]][1] = 1
		print(str(1) + ' ' + str(indz[len(indz) - 1] + 1) + ' ' + str(maxNegInd + 1))
		arr2[maxNegInd][1] = 1
		print(str(2) + ' ' + str(maxNegInd + 1))
	else:
		arr2[maxNegInd][1] = 1
		print(str(2) + ' ' + str(maxNegInd + 1))
	t2 = []
	j = 0
	t3 = []
	t4 = 0
	for item in arr3:
		t4 += 1
		t2.append(item)
		if t4 >= 2:
			print('1 ' + str(t2[t4 - 2] + 1) + ' ' + str(t2[t4 - 1] + 1))


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

def solve(zero):
	if not zero:
		return 0
	if len(zero) == 1:
		return zero[0]
	for i in range(len(zero) - 1):
		print(1, zero[i], zero[i + 1])
	return zero[-1]
pos = []
neg = []
zero = []
for (i, v) in enumerate(a):
	if v > 0:
		pos.append(i + 1)
	elif v < 0:
		neg.append(i + 1)
	else:
		zero.append(i + 1)
if len(neg) % 2 == 0:
	if zero:
		index = solve(zero)
	if zero and len(pos + neg) > 0:
		print(2, index)
	solve(pos + neg)
elif len(neg) % 2 == 1:
	if zero:
		index = solve(zero)
		index1 = max(neg, key=lambda x: a[x - 1])
		print(1, index, index1)
		neg.remove(index1)
	else:
		index1 = max(neg, key=lambda x: a[x - 1])
		neg.remove(index1)
	if len(pos + neg) > 0:
		print(2, index1)
	solve(pos + neg)


n = int(input())
arr = list(map(int, input().split()))
negs = []
negnos = []
zeros = []
pos = []
posnos = []
vanish = 0
flag = 0
for i in range(n):
	if arr[i] < 0:
		negs.append(i + 1)
		negnos.append(arr[i])
	elif not arr[i]:
		zeros.append(i + 1)
	else:
		pos.append(i + 1)
		posnos.append(arr[i])
if len(negs) == 1 and (not len(pos)):
	negs = negs + zeros
	for x in range(len(negs) - 1):
		print(1, negs[x], negs[x + 1])
	exit(0)
if len(negs) % 2:
	if len(zeros):
		for x in range(len(zeros) - 1):
			print(1, zeros[x], zeros[x + 1])
		print(1, arr.index(max(negnos)) + 1, zeros[-1])
		print(2, zeros[-1])
		rmi = arr.index(max(negnos))
		for i in range(len(negs)):
			if rmi + 1 != negs[i]:
				pos.append(negs[i])
	else:
		print(2, arr.index(max(negnos)) + 1)
		rmi = arr.index(max(negnos))
		for i in range(len(negs)):
			if rmi + 1 != negs[i]:
				pos.append(negs[i])
elif len(negs):
	for x in range(len(zeros) - 1):
		print(1, zeros[x], zeros[x + 1])
	if len(zeros):
		print(2, zeros[-1])
	for i in range(len(negs)):
		pos.append(negs[i])
elif len(zeros):
	for x in range(len(zeros) - 1):
		print(1, zeros[x], zeros[x + 1])
	flag = 1
if pos:
	if flag:
		print(2, zeros[-1])
	for i in range(len(pos) - 1):
		print(1, pos[i], pos[i + 1])


n = int(input())
a = list(map(int, input().split()))
commands = []
max_neg_index = None
neg_count = 0
last_zero = None
last_positive = None

def add_command_1(pos1, pos2):
	commands.append(f'1 {pos1} {pos2}')

def add_command_2(position):
	commands.append(f'2 {position}')
for i in range(n):
	value = a[i]
	if value is None:
		continue
	elif value < 0:
		neg_count += 1
		if max_neg_index is None or value > a[max_neg_index - 1]:
			max_neg_index = i + 1
	elif value == 0:
		if last_zero:
			add_command_1(last_zero, i + 1)
		last_zero = i + 1
	else:
		if last_positive is not None:
			add_command_1(last_positive, i + 1)
			a[last_positive - 1] = None
		last_positive = i + 1
if not neg_count % 2:
	max_neg_index = None
last_negative = None
for i in range(n):
	value = a[i]
	if value is None or value >= 0:
		continue
	if max_neg_index is not None and i == max_neg_index - 1:
		continue
	if last_negative is not None:
		add_command_1(last_negative, i + 1)
		value = a[last_negative - 1] * value
		a[last_negative - 1] = None
	last_negative = i + 1
if max_neg_index is not None and last_zero is not None:
	add_command_1(max_neg_index, last_zero)
elif max_neg_index is not None:
	if len(commands) < n - 1:
		add_command_2(max_neg_index)
if last_negative is not None and last_positive is not None:
	add_command_1(last_negative, last_positive)
if last_zero is not None:
	if len(commands) < n - 1:
		add_command_2(last_zero)
print('\n'.join(commands))


r = input
n = int(r())
a = [int(x) for x in r().split()]
zero = []
nega = []
normal = []
MaxNega = int(-10 ** 9 - 7)
IdMaxNega = -1
cnt = int(0)
res = str('')

def Printall(arr):
	Str = str('')
	for i in range(1, len(arr)):
		Str += '1 %d %d\n' % (arr[i - 1] + 1, arr[i] + 1)
	return Str
for i in a:
	if i < 0 and MaxNega < i:
		MaxNega = i
		IdMaxNega = cnt
	if i == 0:
		zero.append(cnt)
	if i > 0:
		normal.append(cnt)
	if i < 0:
		nega.append(cnt)
	cnt += 1
a = []
Nzero = len(zero)
Nnega = len(nega)
if Nnega == 0 and Nzero == 0:
	res += Printall(normal)
elif Nzero == 0:
	if Nnega & 1:
		res += '2 %d\n' % (IdMaxNega + 1)
		if Nnega > 1:
			nega.remove(IdMaxNega)
		else:
			nega = []
		normal = normal + nega
		res += Printall(normal)
	else:
		normal = normal + nega
		res += Printall(normal)
elif Nzero > 0:
	for i in range(1, Nzero):
		res += '1 %d %d\n' % (zero[i - 1] + 1, zero[i] + 1)
	zero = zero[-1]
	if Nnega == 0:
		if len(normal) > 0:
			res += '2 %d\n' % (zero + 1)
		res += Printall(normal)
	if Nnega > 0:
		if Nnega & 1:
			if len(normal) == 0 and len(nega) == 1:
				res += '2 %d\n' % (IdMaxNega + 1)
			else:
				res += '1 %d %d\n' % (zero + 1, IdMaxNega + 1)
				res += '2 %d\n' % (IdMaxNega + 1)
			if Nnega > 1:
				nega.remove(IdMaxNega)
			else:
				nega = []
			normal = normal + nega
			res += Printall(normal)
		else:
			res += '2 %d\n' % (zero + 1)
			normal = normal + nega
			res += Printall(normal)
print(res)


import sys
f = sys.stdin
out = sys.stdout
n = int(f.readline().rstrip('\r\n'))
arr = list(map(int, f.readline().rstrip('\r\n').split()))
nc = 0
zc = 0
for i in arr:
	if i < 0:
		nc += 1
	elif i == 0:
		zc += 1
nc = nc % 2
if nc == 1:
	nu = -float('inf')
	ind = -1
	for i in range(n):
		if arr[i] < 0 and arr[i] > nu:
			nu = arr[i]
			ind = i
	if zc == 0:
		out.write('2 ' + str(ind + 1) + '\n')
		if ind != 0:
			for i in range(1, n):
				if i != ind:
					out.write('1 ' + str(i + 1) + ' 1\n')
		else:
			for i in range(2, n):
				if i != ind:
					out.write('1 ' + str(i + 1) + ' 2\n')
	else:
		cnt = 0
		for i in range(n):
			if arr[i] == 0:
				cnt += 1
				out.write('1 ' + str(i + 1) + ' ' + str(ind + 1) + '\n')
		if cnt < n - 1:
			out.write('2 ' + str(ind + 1) + '\n')
		sp = -1
		for i in range(n):
			if arr[i] != 0 and i != ind:
				sp = i
				break
		if sp != -1:
			for i in range(n):
				if arr[i] != 0 and i != ind and (i != sp):
					out.write('1 ' + str(i + 1) + ' ' + str(sp + 1) + '\n')
elif zc != 0:
	ind = -1
	cnt = 0
	for i in range(n):
		if arr[i] == 0:
			ind = i
			break
	for i in range(n):
		if arr[i] == 0 and i != ind:
			cnt += 1
			out.write('1 ' + str(i + 1) + ' ' + str(ind + 1) + '\n')
	if cnt < n - 1:
		out.write('2 ' + str(ind + 1) + '\n')
	sp = -1
	for i in range(n):
		if arr[i] != 0:
			sp = i
			break
	if sp != -1:
		for i in range(n):
			if arr[i] != 0 and i != sp:
				out.write('1 ' + str(i + 1) + ' ' + str(sp + 1) + '\n')
else:
	for i in range(1, n):
		out.write('1 ' + str(i + 1) + ' 1\n')