Nastia has received an array of $n$ positive integers as a gift.

She calls such an array $a$ good that for all $i$ ($2 \le i \le n$) takes place $gcd(a_{i - 1}, a_{i}) = 1$, where $gcd(u, v)$ denotes the greatest common divisor (GCD) of integers $u$ and $v$.

You can perform the operation: select two different indices $i, j$ ($1 \le i, j \le n$, $i \neq j$) and two integers $x, y$ ($1 \le x, y \le 2 \cdot 10^9$) so that $\min{(a_i, a_j)} = \min{(x, y)}$. Then change $a_i$ to $x$ and $a_j$ to $y$.

The girl asks you to make the array good using at most $n$ operations.

It can be proven that this is always possible.


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 10000$) — the number of test cases.

The first line of each test case contains a single integer $n$ ($1 \le n \le 10^5$) — the length of the array.

The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_{n}$ ($1 \le a_i \le 10^9$) — the array which Nastia has received as a gift.

It's guaranteed that the sum of $n$ in one test doesn't exceed $2 \cdot 10^5$.


-----Output-----

For each of $t$ test cases print a single integer $k$ ($0 \le k \le n$) — the number of operations. You don't need to minimize this number.

In each of the next $k$ lines print $4$ integers $i$, $j$, $x$, $y$ ($1 \le i \neq j \le n$, $1 \le x, y \le 2 \cdot 10^9$) so that $\min{(a_i, a_j)} = \min{(x, y)}$ — in this manner you replace $a_i$ with $x$ and $a_j$ with $y$.

If there are multiple answers, print any.


-----Examples-----

Input
2
5
9 6 3 11 15
3
7 5 13
Output
2
1 5 11 9
2 5 7 6
0


-----Note-----

Consider the first test case.

Initially $a = [9, 6, 3, 11, 15]$.

In the first operation replace $a_1$ with $11$ and $a_5$ with $9$. It's valid, because $\min{(a_1, a_5)} = \min{(11, 9)} = 9$.

After this $a = [11, 6, 3, 11, 9]$.

In the second operation replace $a_2$ with $7$ and $a_5$ with $6$. It's valid, because $\min{(a_2, a_5)} = \min{(7, 6)} = 6$.

After this $a = [11, 7, 3, 11, 6]$ — a good array.

In the second test case, the initial array is already good.

Difficulty: EASY
Tags: Number theory

Mathematics

Constructive algorithms

Starter code:

Solutions:
from math import gcd
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(n - 1)
	(val, idx) = min(((val, idx) for (idx, val) in enumerate(a)))
	counter = 1
	for i in range(idx + 1, n):
		a[i] = val + counter
		counter += 1
		print(idx + 1, i + 1, val, a[i])
	counter = 1
	for i in range(idx - 1, -1, -1):
		a[i] = val + counter
		counter += 1
		print(idx + 1, i + 1, val, a[i])


import sys
input = sys.stdin.readline
import math
mod = 10 ** 9 + 7

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())
for _ in range(inp()):
	n = inp()
	l = inlt()
	o = []
	k = 0
	if n == 1:
		print(0)
		continue
	for i in range(1, n, 2):
		k += 1
		if l[i] > l[i - 1]:
			(l[i], l[i - 1]) = (l[i - 1], l[i])
		o.append([i, i + 1, l[i], 10 ** 9 + 7])
	print(k)
	for i in range(k):
		print(*o[i])


import math

def gcd(a, b):
	if a < b:
		(a, b) = (b, a)
	while a % b != 0:
		(a, b) = (b, a % b)
	return b
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if n == 1:
		print(0)
		continue
	print(n)
	for i in range(1, n):
		if a[i] < a[i - 1]:
			print(i, i + 1, 10 ** 9 + 7 + i - 1, a[i])
		else:
			print(i, i + 1, 10 ** 9 + 7 + i - 1, a[i - 1])
			a[i] = a[i - 1]
		a[i - 1] = 10 ** 9 + 7 - i - 1
	print(n - 1, n, 1073676287, a[-1])


def solve(arr):
	print(len(arr) - 1)
	min_n = min(arr)
	min_i = arr.index(min_n)
	for i in range(len(arr)):
		if i == min_i:
			continue
		print(f'{i + 1} {min_i + 1} {min_n + abs(min_i - i)} {min_n}')
for _ in range(int(input())):
	input()
	arr = list(map(int, input().split()))
	solve(arr)


import math
for test in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	if n == 1:
		print(0)
		continue
	if n == 2:
		print(1)
		print(1, 2, min(a), min(a) + 1)
		continue
	s = max(a)
	for i in range(n - 1):
		m = min(a[i], a[i + 1])
		s += 1
		a[i] = s
		a[i + 1] = m
		t = [i + 1, i + 2, s, m]
		ans.append(t)
	if math.gcd(a[-1], a[-2]) != 1:
		i = a[-2] + 1
		while True:
			if math.gcd(a[-3], i) == 1 and math.gcd(i, a[-1]) == 1:
				m = i
				break
			i += 1
		t = [n - 1, n, m, a[-1]]
		ans.append(t)
	print(len(ans))
	for i in ans:
		print(*i)


from sys import stdout, stdin

def computeGCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
for _ in range(int(input())):
	n = int(input())
	b = 1000000007
	arr = list(map(int, input().split()))
	print(n // 2)
	for i in range(1, n, 2):
		print(i, i + 1, min(arr[i], arr[i - 1]), b)


import sys
import math
input = sys.stdin.readline
from functools import cmp_to_key

def pi():
	return int(input())

def pl():
	return int(input(), 16)

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

def ts():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
f = []

def factMod(n, m):
	global f
	f = [1 for i in range(n + 1)]
	f[0] = 1
	for i in range(1, n + 1):
		f[i] = f[i - 1] * i % m

def fact(n):
	global f
	f = [1 for i in range(n)]
	for i in range(1, n):
		f[i] = f[i - 1] * i

def fast_mod_exp(a, b, m):
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a = a * a % m
		b = b >> 1
	return res

def inverseMod(n, m):
	return fast_mod_exp(n, m - 2, m)

def ncrMod(n, r, m):
	if r == 0:
		return 1
	if n < r:
		return 0
	return f[n] * inverseMod(f[n - r], m) % m * inverseMod(f[r], m) % m

def ncr(n, r):
	if r == 0:
		return 1
	if n < r:
		return 0
	return f[n] / (f[r] * f[n - r])

def nc2(n):
	return n * (n - 1) / 2

def main():
	B()

def A():
	t = pi()
	while t:
		t -= 1
		[a, b] = ti()
		if a == b or b == 1:
			print('NO')
			continue
		print('YES')
		print(b * a, (b + 1) * a, (2 * b + 1) * a)

def B():
	t = pi()
	while t:
		t -= 1
		n = pi()
		a = ti()
		mn = 9999999999999999
		mnIndex = -1
		for i in range(n):
			if mn > a[i]:
				mnIndex = i
				mn = a[i]
		print(n - 1)
		res = [0 for i in range(n)]
		res[mnIndex] = mn
		for i in range(mnIndex - 1, -1, -1):
			if res[i + 1] == mn:
				print(mnIndex + 1, i + 1, mn, mn + 1)
				res[i] = mn + 1
			else:
				print(mnIndex + 1, i + 1, mn, mn)
				res[i] = mn
		for i in range(mnIndex + 1, n):
			if res[i - 1] == mn:
				print(mnIndex + 1, i + 1, mn, mn + 1)
				res[i] = mn + 1
			else:
				print(mnIndex + 1, i + 1, mn, mn)
				res[i] = mn
main()


for u in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	i = 0
	j = 0
	k = 0
	l = 0
	print(n // 2)
	l = 1000000007
	for i in range(0, n - 1, 2):
		print(i + 1, i + 2, min(a[i], a[i + 1]), l)


for tt in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	idx = l.index(min(l))
	num = l[idx]
	print(n - 1)
	alt = 0
	for i in range(n):
		if idx == i:
			continue
		if alt % 2 == 0:
			print(i + 1, idx + 1, 1000000007, num)
		else:
			print(i + 1, idx + 1, 1000000009, num)
		alt += 1


import math
for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	f = []
	for i in range(0, n - 1, 2):
		m = min(arr[i], arr[i + 1])
		arr[i] = m
		arr[i + 1] = 10 ** 9 + 7
		f.append([i + 1, i + 2, m, 10 ** 9 + 7])
	print(len(f))
	for x in f:
		print(*x)


import math
t = int(input())
for _i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	mi = min(arr)
	pos = -1
	for i in range(n):
		if arr[i] == mi:
			pos = i
			break
	print(n - 1)
	for i in range(n):
		if i == pos:
			continue
		print(str(pos + 1) + ' ' + str(i + 1) + ' ' + str(arr[pos]) + ' ' + str(abs(pos - i) + arr[pos]))


import math
n = int(input())
for i in range(0, n):
	n = int(input())
	ar = list(map(int, input().split()))[:n]
	s = 0
	matrix = []
	l = 1000000007
	for j in range(1, n, 2):
		b = []
		t = min(ar[j - 1], ar[j])
		ar[j - 1] = t
		ar[j] = l
		b = [j, j + 1, t, l]
		matrix.append(b)
		s = s + 1
	print(s)
	for j in range(s):
		print(*matrix[j])


def solve(n, iarr):
	(mini, minv) = (0, iarr[0])
	for i in range(n):
		if iarr[i] < minv:
			mini = i
			minv = iarr[i]
	cmd = []
	if mini != 0:
		cmd.append([0, mini, minv, minv + 10000])
	for i in range(1, n):
		cmd.append([0, i, minv, minv + i])
	print(len(cmd))
	for (i1, i2, x, y) in cmd:
		iarr[i1] = x
		iarr[i2] = y
		print(i1 + 1, i2 + 1, x, y)
T = int(input())
for t in range(T):
	n = int(input())
	iarr = list(map(int, input().split()))
	solve(n, iarr)


import sys
import math
import bisect
import heapq
from bisect import bisect_right
from sys import stdin, stdout

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

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

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

def get_list_of_list(n):
	return [list(map(int, sys.stdin.readline().strip().split())) for _ in range(n)]

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

def Solution(arr, n):
	mn = float('inf')
	pos = -1
	for i in range(n):
		if arr[i] < mn:
			mn = arr[i]
			pos = i
	st = 0
	ops = -1
	if pos % 2 == 0:
		st = 1
		ops = n // 2
	else:
		st = 0
		ops = (n + 1) // 2
	print(ops)
	r = pow(10, 9) + 7
	for i in range(ops):
		print(pos + 1, st + 1, arr[pos], r)
		st += 2

def main():
	for _ in range(get_int()):
		n = get_int()
		arr = get_ints_in_list()
		Solution(arr, n)
main()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	pr1 = 10 ** 9 + 7
	if n == 1:
		print(0)
	else:
		print(n // 2)
		if pr1 in l:
			raise
		for i in range(0, n, 2):
			if i + 1 < n:
				print(i + 1, i + 2, min(l[i], l[i + 1]), pr1)
				l[i + 1] = pr1


from math import gcd
inp = int(input())
for _ in range(inp):
	n = int(input())
	p = list(map(int, input().split(' ')))
	minimum = min(p)
	min_ind = p.index(minimum)
	print(n - 1)
	for (i, value) in enumerate(p):
		if i == min_ind:
			continue
		print(str(min_ind + 1) + ' ' + str(i + 1) + ' ' + str(minimum) + ' ' + str(minimum + abs(i - min_ind)))


import math

def main():
	n = int(input())
	arr = list(map(int, input().split()))
	x = min(arr)
	j = arr.index(x)
	info = []
	for i in range(n):
		if i != j:
			y = x + abs(j - i)
			info.append([j + 1, i + 1, x, y])
			arr[i] = y
	print(len(info))
	for i in range(len(info)):
		print(' '.join(map(str, info[i])))
t = int(input())
for i in range(t):
	main()


from sys import stdin
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	ind = a.index(min(a))
	print(n - 1)
	for i in range(n):
		if i == ind:
			continue
		x = abs(ind - i) + a[ind]
		print(ind + 1, i + 1, a[ind], x)


for _ in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	c = 0
	oper = []
	minVal = min(l)
	for i in range(n):
		if minVal == l[i]:
			minIndex = i
	print(n - 1)
	temp = minVal + 1
	for i in range(minIndex + 1, n):
		print(minIndex + 1, i + 1, minVal, temp)
		temp += 1
	temp = minVal + 1
	for i in range(minIndex - 1, -1, -1):
		print(minIndex + 1, i + 1, minVal, temp)
		temp += 1


t = int(input())
for _ in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	print(n // 2)
	for i in range(0, n - 1, 2):
		print(i + 1, i + 2, min(lst[i], lst[i + 1]), 1000000007)


import sys
import math
from collections import defaultdict as dd
from sys import stdin
input = stdin.readline
m = 10 ** 9 + 7
sys.setrecursionlimit(10 ** 5)
T = int(input())
for _ in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	c = 0
	ans = []
	for i in range(n - 1):
		if math.gcd(arr[i], arr[i + 1]) != 1:
			c += 1
			p = min(arr[i], arr[i + 1])
			if i - 1 >= 0:
				if math.gcd(arr[i - 1], p) != 1:
					ans.append([i + 1, i + 2, m, p])
					arr[i] = m
					arr[i + 1] = p
				else:
					ans.append([i + 1, i + 2, p, m])
					arr[i] = p
					arr[i + 1] = m
			else:
				ans.append([i + 1, i + 2, p, m])
				arr[i] = p
				arr[i + 1] = m
	print(c)
	for i in ans:
		print(*i)


from math import gcd

def main():
	n = int(input())
	a = list(map(int, input().split()))
	k = 0
	ans = []
	mina = 10 ** 9 + 1
	i = 0
	for j in range(n):
		if a[j] < mina:
			i = j
			mina = a[j]
	now = 10 ** 9 + 1
	for j in range(i - 1, -1, -1):
		if gcd(a[j + 1], a[j]) == 1:
			continue
		while gcd(a[j + 1], now) != 1:
			now += 1
		a[j] = now
		ans.append((i + 1, j + 1, a[i], a[j]))
		k += 1
		if gcd(a[j + 1], a[j]) != 1:
			print('Error', j, a[j + 1], a[j], gcd(a[j + 1], a[j]))
		assert gcd(a[j + 1], a[j]) == 1
	now = 10 ** 9 + 1
	for j in range(i + 1, n):
		if gcd(a[j - 1], a[j]) == 1:
			continue
		while gcd(a[j - 1], now) != 1:
			now += 1
		a[j] = now
		ans.append((i + 1, j + 1, a[i], a[j]))
		k += 1
		if gcd(a[j - 1], a[j]) != 1:
			print('Error', j, a[j - 1], a[j], gcd(a[j - 1], a[j]))
		assert gcd(a[j - 1], a[j]) == 1
	print(k)
	assert k <= n
	for i in range(k):
		print(*ans[i])
	return
t = int(input())
for _ in range(t):
	main()


from sys import stdin, stdout
import math, bisect, heapq
from collections import Counter, deque, defaultdict
L = lambda : list(map(int, stdin.readline().strip().split()))
I = lambda : int(stdin.readline().strip())
S = lambda : stdin.readline().strip()
C = lambda : stdin.readline().strip().split()

def pr(a):
	print(' '.join(list(map(str, a))))

def solve():
	n = I()
	a = L()
	m = min(a)
	x = a.index(m)
	ans = []
	for i in range(x - 1, -1, -1):
		ans.append((i + 1, x + 1, m + x - i, m))
	for i in range(x + 1, n):
		ans.append((x + 1, i + 1, m, m + i - x))
	print(len(ans))
	for i in ans:
		pr(i)
for _ in range(I()):
	solve()


import math, sys, bisect, heapq, os
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
from functools import lru_cache
pr = lambda x: x

def input():
	return sys.stdin.readline().rstrip('\r\n')
aj = lambda : list(map(int, input().split()))

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]
MOD = 1000000000 + 7

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])

def solve():
	for _ in range(int(input())):
		(n,) = aj()
		A = aj()
		print(n // 2)
		for i in range(1, n, 2):
			print(i, i + 1, min(A[i], A[i - 1]), MOD)
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
	from aj import *
except:
	pass
solve()


import sys
from os import path
from collections import Counter
if path.exists('inp.txt'):
	sys.stdin = open('inp.txt', 'r')
	sys.stdout = open('out.txt', 'w')
import math
t = int(input())
m = 1000000007
while t:
	ts = []
	t -= 1
	ans = 0
	n = int(input())
	li = list(map(int, input().split()))
	for i in range(1, n, 2):
		ans += 1
		ts.append([i, i + 1, min(li[i], li[i - 1]), m])
		li[i] = m
	print(ans)
	for i in ts:
		print(*i)


P = [1000000007, 1000000009, 1000000021, 1000000033]

def main():
	N = int(input())
	A = list(map(int, input().split()))
	if N == 1:
		return print(0)
	print(N - 1)
	for i in range(N - 1):
		print(i + 1, i + 2, P[i % 3], min(A[i], A[i + 1]))
		A[i + 1] = min(A[i], A[i + 1])
		A[i] = P[i % 3]
T = int(input())
for _ in range(T):
	main()


import sys
t = int(input())
for i in range(t):
	n = int(input())
	nums = input().split(' ')
	k = n - 1
	smallest = sys.maxsize
	smallest_index = 0
	for j in range(n):
		num = nums[j]
		if int(num) <= smallest:
			smallest = int(num)
			smallest_index = j
	print(k)
	step = 1
	for j in range(smallest_index + 1, n):
		ii = smallest_index
		jj = j
		x = smallest
		y = smallest + step
		nums[jj] = y
		print(ii + 1, jj + 1, x, y)
		step += 1
	step = 1
	for j in range(smallest_index - 1, -1, -1):
		ii = smallest_index
		jj = j
		x = smallest
		y = smallest + step
		nums[jj] = y
		print(ii + 1, jj + 1, x, y)
		step += 1


n = int(input())
for i in range(n):
	input()
	v = [int(x) for x in input().split()]
	minNum = min(v)
	minInd = v.index(min(v))
	print(len(v) - 1)
	for (index, j) in enumerate(v):
		if index == minInd:
			continue
		print('{} {} {} {}'.format(minInd + 1, index + 1, minNum, minNum + abs(index - minInd)))
		j = minNum + abs(index - minInd)


def check(a, b):
	if idx % 2 == a:
		for i in range(n):
			if i != idx:
				if i % 2 == b:
					print(i + 1, idx + 1, m + 1, m)
				else:
					print(i + 1, idx + 1, m, m)
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	m = min(a)
	idx = a.index(m)
	print(n - 1)
	check(1, 0)
	check(0, 1)


from sys import stdin
T = int(stdin.readline().strip())
for caso in range(T):
	n = int(stdin.readline().strip())
	s = list(map(int, stdin.readline().strip().split()))
	mn = 10 ** 20
	ind = -1
	for i in range(n):
		if s[i] < mn:
			ind = i
			mn = s[i]
	ans = []
	t = True
	for i in range(ind + 1, n):
		if t:
			ans.append([ind + 1, i + 1, mn, mn + 1])
		else:
			ans.append([ind + 1, i + 1, mn, mn])
		t = not t
	t = True
	for i in range(ind - 1, -1, -1):
		if t:
			ans.append([ind + 1, i + 1, mn, mn + 1])
		else:
			ans.append([ind + 1, i + 1, mn, mn])
		t = not t
	print(len(ans))
	for i in ans:
		print(*i)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(n // 2)
	l = 1000000007
	for i in range(0, n - 1, 2):
		print(i + 1, i + 2, min(a[i], a[i + 1]), l)


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def update(a):
	k = 0
	x = []
	y = []
	I = []
	J = []
	for i in range(1, len(a)):
		if gcd(a[i], a[i - 1]) != 1:
			k += 1
			I.append(i)
			J.append(i + 1)
			if a[i - 1] <= a[i]:
				while gcd(a[i], a[i - 1]) != 1:
					a[i] += 1
				x.append(a[i - 1])
				y.append(a[i])
			elif i > 1:
				while gcd(a[i - 2], a[i - 1]) != 1 or gcd(a[i], a[i - 1]) != 1:
					a[i - 1] += 1
				x.append(a[i - 1])
				y.append(a[i])
			else:
				while gcd(a[i], a[i - 1]) != 1:
					a[i - 1] += 1
				x.append(a[i - 1])
				y.append(a[i])
	return (x, y, I, J, k)
t = int(input())
for test in range(t):
	n = int(input())
	a = [int(e) for e in input().split()]
	(x, y, I, J, k) = update(a)
	print(k)
	for i in range(len(x)):
		print('%d %d %d %d' % (I[i], J[i], x[i], y[i]))


import math
for t in range(int(input())):
	n = int(input())
	ans = []
	c = 0
	l = list(map(int, input().split()))
	for i in range(1, n, 2):
		c += 1
		l[i - 1] = min(l[i], l[i - 1])
		l[i] = 1999999973
		ans.append((i + 1, i, 1999999973, min(l[i], l[i - 1])))
	if n > 1:
		if math.gcd(l[-1], l[-2]) != 1:
			ans.append((n, n - 1, 1999999973, min(l[-1], l[-2])))
	print(c)
	for i in range(len(ans)):
		print(*ans[i])
	if n > 1:
		if math.gcd(l[-1], l[-2]) != 1:
			ans.append((n, n - 1, 1999999973, min(l[-1], l[-2])))


import sys
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = sys.stdin.readline
T = int(input())
while T:
	T -= 1
	n = int(input())
	a = list(map(int, input().split()))
	mini = a.index(min(a))
	print(n - 1)
	flag = True
	for i in range(mini + 1, n):
		if flag:
			print(mini + 1, i + 1, a[mini], a[mini] + 1)
		else:
			print(mini + 1, i + 1, a[mini], a[mini])
		flag = not flag
	flag = True
	for i in range(mini - 1, -1, -1):
		if flag:
			print(mini + 1, i + 1, a[mini], a[mini] + 1)
		else:
			print(mini + 1, i + 1, a[mini], a[mini])
		flag = not flag


import sys
input = sys.stdin.buffer.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = min(a)
	i = a.index(x)
	swapped = 0
	if i != 0:
		print(n)
		print(1, i + 1, x, x + i)
		swapped = 1
	if not swapped:
		print(n - 1)
	for i in range(2, n + 1):
		print(1, i, x, x + i - 1)


for ii in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	m = a.index(min(a))
	if m != 0:
		print(n)
		print(1, m + 1, a[m], a[0])
		a[0] = a[m]
	else:
		print(n - 1)
	for jj in range(1, n):
		print(1, jj + 1, a[0], a[0] + jj)


import math
t = int(input())
pr = []
num = 2 * 10 ** 9
while len(pr) != 4:
	for j in range(2, int(math.sqrt(num) + 1)):
		if num % j == 0:
			break
	else:
		pr.append(num)
	num -= 1
for x in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	i = 0
	val = arr[0]
	pos = 0
	out = []
	for i in range(1, n):
		if arr[i] < val:
			val = arr[i]
			pos = i
	if pos != 0:
		print(n)
		print(1, pos + 1, val, pr[0], sep=' ')
		for i in range(1, n):
			print(i, i + 1, pr[i % 4], val, sep=' ')
	else:
		print(n - 1)
		for i in range(1, n):
			print(i, i + 1, pr[i % 4], val, sep=' ')


def gcd(x, y):
	if y == 0:
		return x
	return gcd(y, x % y)
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	for i in range(1, n):
		if gcd(a[i - 1], a[i]) != 1:
			if a[i - 1] > a[i]:
				if i - 2 >= 0:
					if a[i - 2] == 1000000007:
						a[i - 1] = a[i] + 1
					else:
						a[i - 1] = 1000000007
				else:
					a[i - 1] = a[i] + 1
			else:
				a[i] = a[i - 1] + 1
			ans.append([i, i + 1, a[i - 1], a[i]])
	print(len(ans))
	for x in ans:
		print(x[0], x[1], x[2], x[3])


def prime(n):
	np = []
	isprime = []
	for i in range(n + 1, n + 200):
		np.append(i)
	for j in np:
		val_is_prime = True
		for x in range(2, j - 1):
			if j % x == 0:
				val_is_prime = False
				break
		if val_is_prime:
			isprime.append(j)
	return min(isprime)
x = int(1000000000.0 + 7)
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(n - 1)
	for __ in range(n - 1):
		if __ % 2 == 0:
			p = min(a[__], a[__ + 1])
			a[__] = x
			a[__ + 1] = p
			print(__ + 1, __ + 2, x, p)
		else:
			p = min(a[__], a[__ + 1])
			a[__] = x + 2
			a[__ + 1] = p
			print(__ + 1, __ + 2, x + 2, p)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	ind = arr.index(min(arr))
	(i, j) = (ind - 1, ind + 1)
	f = True
	print(n - 1)
	while i >= 0:
		if f:
			f = False
			if arr[ind] != 1:
				print(i + 1, ind + 1, arr[ind] + 1, arr[ind])
			else:
				print(i + 1, ind + 1, 2 * arr[ind] + 1, arr[ind])
		else:
			f = True
			print(i + 1, ind + 1, arr[ind], arr[ind])
		i -= 1
	f = True
	i = ind + 1
	while i < n:
		if f:
			f = False
			if arr[ind] != 1:
				print(i + 1, ind + 1, arr[ind] + 1, arr[ind])
			else:
				print(i + 1, ind + 1, 2 * arr[ind] + 1, arr[ind])
		else:
			f = True
			print(ind + 1, i + 1, arr[ind], arr[ind])
		i += 1


import sys
input = sys.stdin.readline
from pprint import pprint

def do():
	n = int(input())
	dat = list(map(int, input().split()))
	if n == 1:
		print(0)
		return
	res = []
	vala = 10 ** 9 + 5
	valb = 10 ** 9 + 6
	x = None
	y = dat[n - 1]
	print(n)
	for i in range(n - 1):
		y = min(y, dat[i])
		if i % 2 == 0:
			print(i + 1, n, vala, y)
		else:
			print(i + 1, n, valb, y)
	print(n - 1, n, 10 ** 9 + 7, y)
q = int(input())
for _ in range(q):
	do()


t = int(input())
for i in range(t):
	results = []
	n = int(input())
	if n == 0:
		continue
	a = list(map(int, input().split()))
	minimum = min(a)
	indx = a.index(minimum)
	for j in range(indx - 1, -1, -1):
		results.append([indx + 1, j + 1, minimum, minimum + (indx - 1 - j + 1)])
	for j in range(indx + 1, n):
		results.append([indx + 1, j + 1, minimum, minimum + (j - indx)])
	print(n - 1)
	for j in results:
		print(' '.join(map(str, j)))


for _ in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input().split()]
	print(n // 2)
	i = 0
	while i < n - 1:
		min_ele = min(arr[i], arr[i + 1])
		if arr[i] > arr[i + 1]:
			(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
		arr[i + 1] = 10 ** 9 + 7
		print(i + 1, i + 2, min_ele, 10 ** 9 + 7)
		i += 2


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	p = -1
	m = 1000000001
	pri = 1000000007
	for i in range(n):
		if l[i] < m:
			m = l[i]
			p = i
	print((p + 1) // 2 + (n - p) // 2)
	j = p - 1
	while j >= 0:
		print(p + 1, j + 1, l[p], pri)
		j -= 2
	j = p + 1
	while j < n:
		print(p + 1, j + 1, l[p], pri)
		j += 2


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	temp = arr[-1]
	if arr[-1] % 2 == 0:
		temp = arr[-1] + 1
	print(n - 1)
	c = min(arr)
	d = arr.index(c)
	for i in range(n):
		if i == d:
			continue
		else:
			print(d + 1, i + 1, c, c + abs(d - i))


import sys
import string
from collections import Counter, defaultdict
from math import fsum, sqrt, gcd, ceil, factorial
from itertools import combinations, permutations
flush = lambda : sys.stdout.flush
comb = lambda x, y: factorial(x) // factorial(y) // factorial(x - y)
ip = lambda : input()
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())
mod = 10 ** 9 + 7

def solve():
	n = ii()
	arr = rr()
	ans = []
	for i in range(n - 1):
		if gcd(arr[i], arr[i + 1]) != 1:
			x = min(arr[i], arr[i + 1])
			if arr[i] == x:
				if arr[i] == mod:
					z = mod + 2
				else:
					z = mod
				arr[i + 1] = z
				ans.append([i + 1, i + 2, x, z])
			else:
				if i > 0 and arr[i - 1] != mod:
					z = mod
				else:
					z = mod + 2
				arr[i] = z
				ans.append([i + 1, i + 2, z, x])
	print(len(ans))
	for i in ans:
		print(*i)
for _ in range(ii()):
	solve()


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	mini = min(a)
	m = a.index(mini)
	print(n - 1)
	k = a[m] + 1
	l = a[m] + 1
	for i in range(m - 1, -1, -1):
		print(m + 1, i + 1, a[m], k)
		k += 1
	for i in range(m + 1, n):
		print(m + 1, i + 1, a[m], l)
		l += 1


import sys
from sys import stdout
input = lambda : sys.stdin.readline().rstrip('\r\n')
P = lambda : list(map(int, input().split()))
from math import factorial as f, log2, gcd
import random
mod = 10 ** 9 + 7
tc = int(input())
p = 2
for _ in range(tc):
	n = int(input())
	l = P()
	m = min(l)
	if p <= m:
		p = m + 1
		while True:
			prime = True
			for i in range(2, int(p ** 0.5) + 1):
				if p % i == 0:
					prime = False
					break
			if prime:
				break
			else:
				p += 1
	ind = l.index(m)
	print(n - 1)
	op = 1
	for i in range(ind - 1, -1, -1):
		if op:
			print(ind + 1, i + 1, m, p)
		else:
			print(ind + 1, i + 1, m, p + 1)
		op = not op
	op = 1
	for i in range(ind + 1, n):
		if op:
			print(ind + 1, i + 1, m, p)
		else:
			print(ind + 1, i + 1, m, p + 1)
		op = not op


from collections import defaultdict
from functools import reduce
from bisect import bisect_right
from bisect import bisect_left
import copy

def main():
	for _ in range(int(input())):
		n = int(input())
		d = defaultdict(int)
		l = list(map(int, input().split()))
		atomic = min(l)
		spot = l.index(atomic)
		print(n - 1)
		for i in range(n):
			if spot != i:
				print(spot + 1, i + 1, atomic, atomic + abs(spot - i))

def primes1(n):
	sieve = [True] * (n // 2)
	for i in range(3, int(n ** 0.5) + 1, 2):
		if sieve[i // 2]:
			sieve[i * i // 2::i] = [False] * ((n - i * i - 1) // (2 * i) + 1)
	return [2] + [2 * i + 1 for i in range(1, n // 2) if sieve[i]]

def GCD(a, b):
	if b == 0:
		return a
	else:
		return GCD(b, a % b)
main()


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	ind = lst.index(min(lst))
	print(n - 1)
	mi = min(lst)
	for j in range(ind + 1, n):
		print(ind + 1, j + 1, mi, mi + abs(j - ind))
	for j in range(0, ind):
		print(ind + 1, j + 1, mi, mi + abs(j - ind))


import sys
import math
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	a = [int(i) for i in sys.stdin.readline().split()]
	m = min(a)
	arg_m = -1
	for i in range(n):
		if a[i] == m:
			arg_m = i
			break
	print(n - 1)
	for i in range(arg_m % 2, n, 2):
		if i == arg_m:
			continue
		print('%d %d %d %d' % (arg_m + 1, i + 1, m, m))
	for i in range((arg_m + 1) % 2, n, 2):
		print('%d %d %d %d' % (arg_m + 1, i + 1, m, m + 1))


for case in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	chakra = arr[0]
	ind = 0
	for i in range(1, n):
		if chakra > arr[i]:
			chakra = arr[i]
			ind = i
	temp = chakra + 1
	if n == 1:
		print(0)
	elif n == 2:
		print(1)
		if ind == 0:
			print(1, 2, chakra, chakra + 1)
		else:
			print(1, 2, chakra + 1, chakra)
	elif ind != 0:
		print(n - 1)
		for i in range(1, ind):
			print(i + 1, ind + 1, temp, chakra)
			temp += 1
		yolo = temp
		temp += 1
		for i in range(ind + 1, n):
			print(i + 1, ind + 1, temp, chakra)
			temp += 1
		print(1, ind + 1, chakra, yolo)
	else:
		print(n - 1)
		temp = chakra + 2
		for i in range(2, n):
			print(1, i + 1, chakra, temp)
			temp += 1
		print(1, 2, chakra, chakra + 1)


from sys import stdin, stdout
get_string = lambda : stdin.readline().strip('\n')
get_intmap = lambda : map(int, get_string().split(' '))

def testcase():
	n = int(input())
	a = list(get_intmap())
	(mn, mni) = (10000000000.0, -1)
	for (ind, i) in enumerate(a):
		if i < mn:
			(mn, mni) = (i, ind)
	print(n - 1)
	mni += 1
	for tup in [(mni - 1, 0, -1), (mni + 1, n + 1)]:
		tmp = mn + 1
		for ind in range(*tup):
			stdout.write('{} {} {} {}\n'.format(ind, mni, tmp, mn))
			tmp += 1
single = 0
t = 1 if single else int(input())
for _ in range(t):
	testcase()


def answer():
	m = min(a)
	for i in range(n):
		if a[i] == m:
			ind = i
			break
	opp = []
	c = 1
	for i in range(ind - 1, -1, -1):
		opp.append([ind + 1, i + 1, m, m + c])
		c += 1
	c = 1
	for i in range(ind + 1, n):
		opp.append([ind + 1, i + 1, m, m + c])
		c += 1
	print(len(opp))
	for x in opp:
		print(*x)
for T in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	answer()


import math
t = int(input())
for _ in range(t):
	n = int(input())
	ans = []
	q = 1999999973
	cnt = 0
	ali = list(map(int, input().split()))
	for i in range(1, n, 2):
		cnt += 1
		ali[i - 1] = min(ali[i], ali[i - 1])
		ali[i] = q
		ans.append((i + 1, i, q, min(ali[i], ali[i - 1])))
	if n > 1:
		if math.gcd(ali[-1], ali[-2]) != 1:
			ans.append((n, n - 1, q, min(ali[-1], ali[-2])))
	print(cnt)
	for i in range(len(ans)):
		print(*ans[i])


import sys, getpass
import math, random
import functools, itertools, collections, heapq, bisect
from collections import Counter, defaultdict, deque
input = sys.stdin.readline
M9 = 10 ** 9 + 7
MAXINT = sys.maxsize
OFFLINE_TEST = getpass.getuser() == 'hkmac'

def log(*args):
	if OFFLINE_TEST:
		print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)

def solve(*args):
	if OFFLINE_TEST:
		log('----- solving ------')
		log(*args)
		log('----- ------- ------')
	return solve_(*args)

def read_matrix(rows):
	return [list(map(int, input().split())) for _ in range(rows)]

def read_strings(rows):
	return [input().strip() for _ in range(rows)]

def solve_():
	n = int(input())
	a = list(map(int, input().split()))
	m = min(a)
	ind = a.index(m)
	print(n - 1)
	j = 1
	for i in range(ind - 1, -1, -1):
		a[i] = m + j
		print(ind + 1, i + 1, m, a[i])
		j += 1
	j = 1
	for i in range(ind + 1, len(a)):
		a[i] = m + j
		print(ind + 1, i + 1, m, a[i])
		j += 1
for case_num in range(int(input())):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	mn = min(a)
	idx = a.index(mn)
	d = {}
	if idx & 1:
		d['odd'] = a[idx]
		d['even'] = a[idx] + 1
	else:
		d['odd'] = a[idx] + 1
		d['even'] = a[idx]
	print(n - 1)
	for i in range(n):
		if i == idx:
			continue
		if i & 1:
			print(i + 1, idx + 1, d['odd'], a[idx])
		else:
			print(i + 1, idx + 1, d['even'], a[idx])


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	mini = min(a)
	index = 0
	b = mini
	c = mini
	print(n - 1)
	for j in range(n):
		if mini == a[j]:
			index = j
			break
	for j in range(index - 1, -1, -1):
		b += 1
		print(index + 1, j + 1, mini, b)
	for j in range(index + 1, n):
		c += 1
		print(index + 1, j + 1, mini, c)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	prm = 1000000009
	mn = float('inf')
	for i in range(n):
		if arr[i] < mn:
			mn = arr[i]
			index = i
	ind = []
	i = index + 1
	while i < n:
		ind.append(i)
		i += 2
	i = index - 1
	while i >= 0:
		ind.append(i)
		i -= 2
	print(len(ind))
	for i in ind:
		print(index + 1, end=' ')
		print(i + 1, end=' ')
		print(arr[index], end=' ')
		print(prm)


import sys
input = sys.stdin.readline
t = int(input())
while t > 0:
	n = int(input())
	a = [*map(int, input().split())]
	x = a.index(min(a))
	print(n - 1)
	for i in range(n):
		if i != x:
			print(x + 1, i + 1, a[x], a[x] + abs(i - x))
	t -= 1


from __future__ import division, print_function
import math
import sys
import os
from io import BytesIO, IOBase
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

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

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

def insr():
	s = input().strip()
	return list(s[:len(s)])

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

def gcdeu(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
for _ in range(inp()):
	n = inp()
	l = inlt()
	s = []
	mn = min(l)
	flag = 0
	idx = l.index(min(l))
	for i in range(1, n):
		if gcdeu(l[i], l[i - 1]) != 1:
			flag = 1
			break
	if flag:
		print(n - 1)
		for i in range(n):
			if i != idx:
				l[i] = mn + abs(idx - i)
				print(i + 1, idx + 1, mn + abs(idx - i), mn)
	else:
		print(0)


from sys import stdin, stdout
import math

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

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

def li():
	return list(mi())

def si():
	return stdin.readline()
t = 1
t = ii()
mod = 10 ** 9 + 7
for _ in range(t):
	n = ii()
	l1 = li()
	min1 = min(l1)
	ind = l1.index(min1)
	j = ind - 1
	k = ind + 1
	c1 = 0
	c2 = 0
	print(n - 1)
	while j >= 0:
		if c1 % 2 == 0:
			print(ind + 1, j + 1, l1[ind], mod)
			l1[j] = mod
		else:
			print(ind + 1, j + 1, l1[ind], l1[ind])
			l1[j] = l1[ind]
		c1 += 1
		j -= 1
	while k < n:
		if c2 % 2 == 0:
			print(ind + 1, k + 1, l1[ind], mod)
			l1[k] = mod
		else:
			print(ind + 1, k + 1, l1[ind], l1[ind])
			l1[k] = l1[ind]
		c2 += 1
		k += 1


import os
import sys
from math import *
from collections import *
from heapq import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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')
ALPHA = 'abcde'
M = 10 ** 9 + 7
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for i in range(Int()):
	n = Int()
	a = array()
	ind = a.index(min(a))
	print(n - 1)
	for i in range(n):
		d = abs(i - ind)
		if d:
			print(ind + 1, i + 1, a[ind], a[ind] + d)
		a[i] = a[ind] + d


T = int(input())
for t in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	index = arr.index(min(arr))
	s = 0
	m = arr[index]
	print(n - 1)
	if index % 2 == 0:
		for i in range(n):
			if i != index:
				if i % 2 != 0:
					arr[i] = m + 1
					print('{} {} {} {}'.format(i + 1, index + 1, m + 1, m))
				else:
					arr[i] = m
					print('{} {} {} {}'.format(i + 1, index + 1, m, m))
	else:
		for i in range(n):
			if i != index:
				if i % 2 == 0:
					arr[i] = m + 1
					print('{} {} {} {}'.format(i + 1, index + 1, m + 1, m))
				else:
					arr[i] = m
					print('{} {} {} {}'.format(i + 1, index + 1, m, m))


from sys import stdin, gettrace
if gettrace():

	def inputi():
		return input()
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()

def solve():
	n = int(input())
	aa = [int(a) for a in input().split()]
	print(n - 1)
	bp = min(range(n), key=lambda i: aa[i])
	bv = aa[bp]
	for i in range(bp + 1, n):
		print(bp + 1, i + 1, bv, bv + i - bp)
	for i in range(0, bp):
		print(i + 1, bp + 1, bv + bp - i, bv)

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()


Z = 1000000007
for _ in range(int(input())):
	n = int(input())
	aa = list(map(int, input().split()))
	x = list((f'{i} {i + 1} {min(aa[i - 1], aa[i])} {Z}' for i in range(1, n, 2)))
	print(len(x))
	ans = '\n'.join(x)
	print(ans)


from math import sqrt, ceil, gcd
R = lambda : list(map(int, input().split()))
bigprime = 1999999973
for _ in ' ' * int(input()):
	n = int(input())
	a = R()
	op = []
	for i in range(0, n - 1, 2):
		op.append([i + 1, i + 2, min(a[i], a[i + 1]), bigprime])
		a[i] = min(a[i], a[i + 1])
		a[i + 1] = bigprime
	print(len(op))
	for i in op:
		print(*i)


import sys
from math import gcd
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if n == 1:
		print(0)
		continue
	mx = max(a)
	mn = min(a)
	while gcd(mn, mx) > 1:
		mx += 1
	res = []
	for i in range(1, n):
		x = min(a[0], a[i])
		res.append((1, i + 1, x, mx + i - 1))
		a[0] = x
		a[i] = mx + i
	print(len(res))
	for r in res:
		print(*r)


from sys import stdin as sin

def aint():
	return int(input())

def amap():
	return map(int, sin.readline().split())

def alist():
	return list(map(int, sin.readline().split()))

def astr():
	return input()
from math import gcd
for _ in range(aint()):
	n = aint()
	l = alist()
	ans = []
	m = max(l) + 1
	for i in range(n - 1):
		c = min(l[i], l[i + 1])
		l[i] = m
		l[i + 1] = c
		m += 1
		ans.append([i + 1, i + 2, l[i], l[i + 1]])
	if n >= 2 and gcd(l[-2], l[-1]) != 1:
		while gcd(l[-1], l[-2]) != 1 or (n >= 3 and gcd(l[-2], l[-3]) != 1):
			l[-2] += 1
		ans.append([n - 1, n, l[-2], l[-1]])
	print(len(ans))
	for i in ans:
		print(*i)


from math import gcd
for t in range(int(input())):
	pn = 10 ** 9 + 7
	N = int(input())
	arr = list(map(int, input().split()))
	ans = []
	for i in range(0, len(arr) - 1, 2):
		ans.append([i + 1, i + 2, min(arr[i], arr[i + 1]), pn])
		arr[i + 1] = pn
	if ans:
		print(len(ans))
		for i in ans:
			print(*i)
	else:
		print(0)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	for i in range(1, n, 2):
		ans += [[i, i + 1, min(a[i], a[i - 1]), 10 ** 9 + 7]]
	print(len(ans))
	for i in ans:
		print(*i)


from math import gcd

def gcdl(li):
	for i in range(1, n):
		if gcd(L[i - 1], L[i]) != 1:
			return False
	return True
tcs = int(input())
for tc in range(tcs):
	n = int(input())
	L = list(map(int, input().split()))
	p = L[0]
	ans = []
	if gcdl(L):
		print(0)
		continue
	ml = min(L)
	idm = L.index(ml)
	mn = n
	if idm == 0:
		mn = n - 1
	print(mn)
	if idm != 0:
		print(*[1, idm + 1, ml, ml + 1])
		L[0] = ml
		L[idm] = ml + 1
	for i in range(1, n):
		print(*[1, i + 1, ml, ml + i])
		L[i] = ml + i


import os
import sys
from io import BytesIO, IOBase
import math
from queue import Queue
import itertools
import bisect
import heapq
import random

def main():
	pass
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')

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 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(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	return l

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 maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def countcon(s, i):
	c = 0
	ch = s[i]
	for i in range(i, len(s)):
		if s[i] == ch:
			c += 1
		else:
			break
	return c

def lis(arr):
	n = len(arr)
	lis = [1] * n
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] > arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
	maximum = 0
	for i in range(n):
		maximum = max(maximum, lis[i])
	return maximum

def isSubSequence(str1, str2):
	m = len(str1)
	n = len(str2)
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m

def maxfac(n):
	root = int(n ** 0.5)
	for i in range(2, root + 1):
		if n % i == 0:
			return n // i
	return n

def p2(n):
	c = 0
	while n % 2 == 0:
		n //= 2
		c += 1
	return c

def seive(n):
	primes = [True] * (n + 1)
	primes[1] = primes[0] = False
	i = 2
	while i * i <= n:
		if primes[i] == True:
			for j in range(i * i, n + 1, i):
				primes[j] = False
		i += 1
	pr = []
	for i in range(0, n + 1):
		if primes[i]:
			pr.append(i)
	return pr

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 denofactinverse(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return pow(fac, m - 2, m)

def numofact(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return fac

def sod(n):
	s = 0
	while n > 0:
		s += n % 10
		n //= 10
	return s

def q(t, l, r, x):
	print('?', t, l, r, x, flush=True)
	return int(input())
for xyz in range(0, int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	print(n - 1)
	val = min(l)
	ind = l.index(val)
	val += 1
	for i in range(ind + 1, n):
		print(ind + 1, i + 1, l[ind], val)
		l[i] = val
		val += 1
	val = min(l) + 1
	for i in range(ind - 1, -1, -1):
		print(ind + 1, i + 1, l[ind], val)
		l[i] = val
		val += 1


t = int(input())
for bbbb in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	mn = min(a)
	mni = a.index(mn)
	if mni > 0:
		print(n)
		print(1, mni + 1, mn, mn + 1)
	else:
		print(n - 1)
	for i in range(1, n):
		print(1, i + 1, mn, mn + i % 2)


from math import gcd
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	p = 10 ** 9 + 7
	c = 0
	ans = []
	for i in range(0, n - 1, 2):
		(a, b) = (min(arr[i], arr[i + 1]), p)
		arr[i] = a
		arr[i + 1] = p
		ans.append([i + 1, i + 2, a, p])
	print(len(ans))
	for i in ans:
		print(*i)


testCases = int(input())
for _ in range(testCases):
	n = int(input())
	row = input()
	numbers = [int(x) for x in row.strip().split(' ')]
	output = []
	min_ = min(numbers)
	index = numbers.index(min_)
	print(n - 1)
	for i in range(n):
		if index != i:
			print(f'{i + 1} {index + 1} {min_ + abs(index - i)} {min_}')


import sys, io, os
input = lambda : sys.stdin.readline().encode()
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
read = lambda : map(int, input().split())
out = []
for _ in range(int(input())):
	n = int(input())
	a = list(read())
	x = a.index(min(a))
	moves = []
	for i in range(x - 1, -1, -1):
		moves.append(f'{i + 1} {x + 1} {a[x] + (x - i)} {a[x]}')
	for i in range(x + 1, n):
		moves.append(f'{i + 1} {x + 1} {a[x] + (i - x)} {a[x]}')
	out.append(str(len(moves)))
	out.append('\n'.join(moves))
print('\n'.join(out))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	pos = 0
	for i in range(n):
		if a[i] < a[pos]:
			pos = i
	k = a[pos] + 1
	print(n - 1)
	for i in range(pos + 1, n):
		print(pos + 1, i + 1, a[pos], k)
		k += 1
	k = a[pos] + 1
	for i in range(pos - 1, -1, -1):
		print(pos + 1, i + 1, a[pos], k)
		k += 1


from sys import stdin, stdout
input = stdin.readline
pr = 10 ** 9 + 7
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	ans = []
	for i in range(n - 1):
		b = min(arr[i], arr[i + 1])
		if i % 2 == 0:
			p = [i + 1, i + 2, pr, b]
		else:
			p = [i + 1, i + 2, b, pr]
		arr[i] = p[2]
		arr[i + 1] = p[3]
		ans.append(p)
	print(len(ans))
	for i in ans:
		print(*i)


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input())
t = 1
while t <= T:
	n = int(input())
	arr = list(map(int, input().split()))
	maximum = max(arr)
	minimum = min(arr)
	start = maximum + 10 ** 9
	if n == 1:
		print(0)
		t += 1
		continue
	print(n)
	for i in range(n - 1):
		(arr[i], arr[i + 1]) = (start - i, min(arr[i], arr[i + 1]))
		temp = [i + 1, i + 2, arr[i], arr[i + 1]]
		os.sys.stdout.write(' '.join(map(str, temp)) + '\n')
	prime = 10 ** 9 + 7
	temp = [n - 1, n, prime, arr[n - 1]]
	os.sys.stdout.write(' '.join(map(str, temp)) + '\n')
	t += 1


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(t,) = I()
for _ in range(t):
	(n,) = I()
	l = I()
	an = []
	ix = l.index(min(l))
	k = 1
	for i in range(n):
		if i != ix:
			an.append([ix + 1, i + 1, l[ix], l[ix] + abs(i - ix)])
			l[i] = l[ix] + abs(i - ix)
	print(len(an))
	for i in range(len(an)):
		print(*an[i])


from math import gcd
for v in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = 0
	ansa = []
	for i in range(n - 1):
		if gcd(a[i], a[i + 1]) != 1:
			if a[i + 1] >= a[i]:
				ma = a[i]
				while gcd(ma, a[i]) != 1:
					ma += 1
				a[i + 1] = ma
				ansa.append([i + 1, i + 1 + 1, a[i], ma])
				ans += 1
			else:
				ma = a[i + 1]
				if i == 0:
					while gcd(ma, a[i + 1]) != 1:
						ma += 1
				else:
					while gcd(ma, a[i + 1]) != 1 or gcd(ma, a[i - 1]) != 1:
						ma += 1
				a[i] = ma
				ansa.append([i + 1, i + 1 + 1, ma, a[i + 1]])
				ans += 1
	print(ans)
	if not ansa == []:
		for i in ansa:
			print(*i)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ind = 0
	o = 1000000007
	e = 1000000207
	for i in range(1, n):
		if a[i] < a[ind]:
			ind = i
	print(n - 1)
	for i in range(0, n):
		if i == ind:
			continue
		elif i % 2 == ind % 2:
			if a[ind] % 2 == 0:
				print(ind + 1, i + 1, a[ind], e)
			else:
				print(ind + 1, i + 1, a[ind], o)
		elif a[ind] % 2 == 0:
			print(ind + 1, i + 1, a[ind], o)
		else:
			print(ind + 1, i + 1, a[ind], e)


for _ in range(int(input())):
	n = int(input())
	a = input().split()
	for i in range(n):
		a[i] = int(a[i])
	x = min(a)
	s = x
	z = a.index(x)
	print(n - 1)
	p = 0
	for i in range(z - 1, -1, -1):
		a = z + 1
		b = i + 1
		if p % 2 == 0:
			c = x + 1
		else:
			c = x
		print(str(a) + ' ' + str(b) + ' ' + str(x) + ' ' + str(c))
		p += 1
	p = 0
	for i in range(z + 1, n):
		a = z + 1
		b = i + 1
		if p % 2 == 0:
			c = x + 1
		else:
			c = x
		print(str(a) + ' ' + str(b) + ' ' + str(x) + ' ' + str(c))
		p += 1


import math
from collections import defaultdict, Counter
from math import floor, sqrt, gcd
import sys

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	for i in range(5, int(math.sqrt(n) + 1), 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def nextPrime(N):
	if N <= 1:
		return 2
	prime = N
	found = False
	while not found:
		prime = prime + 1
		if isPrime(prime) == True:
			found = True
	return prime
for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	m = min(l)
	k = nextPrime(m)
	count = 0
	idx = l.index(m)
	ans = []
	find = k
	for i in range(idx - 1, -1, -1):
		if l[i] != find:
			count += 1
			ans.append([i + 1, idx + 1, find, m])
		if find == k:
			find = m
		elif find == m:
			find = k
	find = k
	for i in range(idx + 1, n):
		if l[i] != find:
			count += 1
			ans.append([i + 1, idx + 1, find, m])
		if find == k:
			find = m
		elif find == m:
			find = k
	print(count)
	for j in ans:
		print(*j)


out = []
for _ in range(int(input())):
	n = int(input())
	data = [x for x in map(int, input().split())]
	minv = min(data)
	pos = data.index(minv)
	out.append('{}'.format(n - 1))
	for i in range(len(data)):
		if i != pos:
			out.append('{} {} {} {}'.format(pos + 1, i + 1, minv, minv + abs(i - pos)))
print('\n'.join(out))


def some_random_function():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function5():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)
import os, sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		rr = min(a)
		z = a.index(rr)
		op = []
		for i in range(z):
			if i & 1 != z & 1:
				op.append((i + 1, z + 1, 10 ** 9 + 7, rr))
		for i in range(z + 1, n):
			if i & 1 != z & 1:
				op.append((z + 1, i + 1, rr, 10 ** 9 + 7))
		print(len(op))
		for i in op:
			print(*i)
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')

def some_random_function1():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function2():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function3():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function4():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function6():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function7():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function8():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)
main()


for s in [*open(0)][2::2]:
	a = s.split()
	n = len(a)
	print(n // 2)
	while n > 1:
		print(n, n - 1, min(a[n - 2:n], key=int), 10 ** 9 + 7)
		n -= 2


from math import *
mod1 = int(pow(10, 9) + 7)
mod2 = int(pow(10, 9) + 9)
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ver = True
	for i in range(n - 1):
		if gcd(a[i], a[i + 1]) != 1:
			ver = False
			break
	if ver == True:
		print(0)
		continue
	ans = []
	curr = mod1
	for i in range(n - 1):
		if gcd(a[i], a[i + 1]) != 1:
			ans.append([i + 1, n, curr, min(a[i], a[-1])])
			a[-1] = min(a[i], a[-1])
			a[i] = curr
			if curr == mod1:
				curr = mod2
			else:
				curr = mod1
	print(len(ans))
	for i in range(len(ans)):
		print(*ans[i])


import math

def getRelPrime(val):
	if math.gcd(val, 2) == 1:
		return 2
	p = 3
	while True:
		if math.gcd(val, p) == 1:
			return p
		else:
			p += 2
t = int(input())
for _ in range(t):
	n = int(input())
	array = list(map(int, input().split()))
	minval = min(array)
	minidx = array.index(minval)
	p = getRelPrime(minval)
	print(n - 1)
	for i in range(n):
		if i == minidx:
			continue
		elif (minidx - i) % 2 == 0:
			print(i + 1, minidx + 1, minval, minval)
		else:
			print(i + 1, minidx + 1, minval + p, minval)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	N = int(input())
	li = list(map(int, input().split()))
	(mn, mn_i) = (min(li), li.index(min(li)))
	print(N - 1)
	for (i, n) in enumerate(li):
		if i != mn_i:
			li[i] = mn + abs(mn_i - i)
			print(mn_i + 1, i + 1, mn, mn + abs(mn_i - i))


from collections import defaultdict
from collections import deque
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	result = []
	for i in range(1, n):
		if a[i - 1] <= a[i]:
			if i == 1 or a[i - 2] == 1000000009:
				result.append((i, i + 1, 1000000007, a[i - 1]))
				(a[i - 1], a[i]) = (1000000007, a[i - 1])
			else:
				result.append((i, i + 1, 1000000009, a[i - 1]))
				(a[i - 1], a[i]) = (1000000009, a[i - 1])
		elif i == 1 or a[i - 2] == 1000000009:
			result.append((i, i + 1, 1000000007, a[i]))
			a[i - 1] = 1000000007
		else:
			result.append((i, i + 1, 1000000009, a[i]))
			a[i - 1] = 1000000009
	print(len(result))
	for t in result:
		print(' '.join(map(str, t)))


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	ind = ar.index(min(ar))
	val = ar[ind]
	print(n - 1)
	for i in range(n):
		if i == ind:
			continue
		print(ind + 1, i + 1, val, val + abs(ind - i))


import math
debug = True

def pprint(*args, delimiter='#', amount=10):
	if debug:
		print('{0} DEBUG {0}'.format(delimiter * amount))
		print(*args)
		print('{0} ----- {0}'.format('-' * amount))

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	minimal = min(a)
	index = a.index(minimal)
	print(n - 1)
	right = minimal + 1
	for i in range(index + 1, n):
		print(index + 1, i + 1, minimal, right)
		right += 1
	left = minimal + 1
	for i in range(index - 1, -1, -1):
		print(index + 1, i + 1, minimal, left)
		left += 1
t = int(input())
while t > 0:
	t -= 1
	solve()


from os import path
import sys, time, collections as c, math, pprint as p, itertools as it, operator as op, bisect as bs, functools as fn
(maxx, localsys, mod) = (float('inf'), 0, int(1000000000.0 + 7))
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if n == 1:
		print(0)
		continue
	print(n // 2)
	for i in range(1, n, 2):
		print(i, i + 1, min(a[i - 1], a[i]), 10 ** 9 + 7)
		(a[i - 1], a[i]) = (min(a[i - 1], a[i]), 10 ** 9 + 7)


import os
import sys
from io import BytesIO, IOBase
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')
from math import ceil

def prod(a, mod=10 ** 9 + 7):
	ans = 1
	for each in a:
		ans = ans * each % mod
	return ans

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if True else 1):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	for i in range(1, n, 2):
		ans += [[i, i + 1, min(a[i], a[i - 1]), 10 ** 9 + 7]]
		(a[i - 1], a[i]) = (min(a[i - 1], a[i]), 10 ** 9 + 7)
	print(len(ans))
	for i in ans:
		print(*i)


import math
import sys
input = lambda : sys.stdin.readline().strip()
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	mn = a.index(min(a))
	print(n - 1)
	for i in range(n):
		if i != mn:
			print(i + 1, mn + 1, a[mn] + abs(i - mn), a[mn])


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	(m, ind) = (l[0], 0)
	for i in range(n):
		if l[i] < m:
			(m, ind) = (l[i], i)
	print(n - 1)
	for i in range(ind):
		print(i + 1, ind + 1, m + ind - i, m)
	for i in range(ind + 1, n):
		print(ind + 1, i + 1, m, m + i - ind)


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

def solve():
	n = int(input())
	a = list(readline())
	(pos, m) = min(enumerate(a), key=lambda p: p[1])
	if pos:
		print(n)
		print(1, pos + 1, m, m + pos)
	else:
		print(n - 1)
	for j in range(1, n):
		print(1, j + 1, m, m + j)

def main():
	t = int(input())
	for __ in range(t):
		solve()
main()


def sol(n, a):
	prim = 1999999973
	print(n // 2)
	new = n * [0]
	for i in range(1, n, 2):
		if a[i - 1] < a[i]:
			print(f'{i} {i + 1} {a[i - 1]} {prim}')
			new[i] = prim
			new[i - 1] = a[i - 1]
		else:
			print(f'{i} {i + 1} {a[i]} {prim}')
			new[i] = prim
			new[i - 1] = a[i]
	if n % 2 != 0:
		new[-1] = a[-1]

def main():
	for i in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		sol(n, a)
main()


from sys import stdin
input = stdin.readline
from heapq import heapify, heappush, heappop, heappushpop
from collections import defaultdict as dd, deque as dq, Counter as C
from math import factorial as f, ceil, gcd, sqrt, log
from bisect import bisect_left as bl, bisect_right as br
from itertools import combinations as c, permutations as p
from math import factorial as f, ceil, gcd, sqrt, log
mi = lambda : map(int, input().split())
ii = lambda : int(input())
li = lambda : list(map(int, input().split()))
mati = lambda r: [li() for _ in range(r)]
lcm = lambda a, b: a * b // gcd(a, b)
MOD = 1990475947

def solve():
	n = ii()
	arr = li()
	if n == 1:
		print(0)
	else:
		print((n + 1) // 2)
		for x in range(0, n, 2):
			if x == n - 1:
				continue
			else:
				(a, b, c) = (x + 1, x + 2, min(arr[x], arr[x + 1]))
				print(a, b, MOD, c)
			arr[x + 1] = min(arr[x], arr[x + 1])
		if len(arr) % 2 == 1:
			print(len(arr) - 1, len(arr), min(arr[-1], arr[-2]), MOD)
for _ in range(ii()):
	solve()


import sys
import math
from bisect import bisect_left
from collections import Counter, defaultdict
L = lambda : list(map(int, input().split()))
I = lambda : int(input())
S = lambda : input()
mod = 10 ** 9 + 7

def solve():
	n = I()
	a = L()
	ans = []
	x = a.index(min(a))
	m = min(a)
	s = 1
	for i in range(x - 1, -1, -1):
		ans.append([i + 1, x + 1, m + s, m])
		s += 1
	s = 1
	for i in range(x + 1, n):
		ans.append([x + 1, i + 1, m, m + s])
		s += 1
	print(len(ans))
	for i in ans:
		print(*i)
for _ in range(I()):
	solve()


import sys

class BNastiaAndAGoodArray:

	def solve(self, tc=0):
		from math import gcd
		for _ in range(int(input())):
			n = int(input())
			a = [int(_) for _ in input().split()]
			ans = []
			for i in range(1, n):
				if gcd(a[i], a[i - 1]) == 1:
					continue
				if a[i] >= a[i - 1]:
					ans.append([i + 1, i, a[i - 1] + 1, a[i - 1]])
					a[i] = a[i - 1] + 1
				else:
					k = a[i] + 1
					while gcd(k, a[i]) != 1 or (i != 1 and gcd(k, a[i - 2]) != 1):
						k += 1
					ans.append([i, i + 1, k, a[i]])
					a[i - 1] = k
			print(len(ans))
			for change in ans:
				print(*change)
solver = BNastiaAndAGoodArray()
input = sys.stdin.readline
solver.solve()


import time, math as mt, bisect as bs, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

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

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

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

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count

def readTree(n, e):
	adj = [set() for i in range(n + 1)]
	for i in range(e):
		(u1, u2) = IP()
		adj[u1].add(u2)
	return adj

def sieve():
	li = [True] * (10 ** 3 + 5)
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	(prime, cur) = ([0] * 200, 0)
	for i in range(10 ** 3 + 5):
		if li[i] == True:
			prime[cur] = i
			cur += 1
	return prime

def SPF():
	mx = 10 ** 7 + 1
	spf = [mx] * mx
	spf[1] = 1
	for i in range(2, mx):
		if spf[i] == mx:
			spf[i] = i
			for j in range(i * i, mx, i):
				if i < spf[j]:
					spf[j] = i
	return spf

def prime(n, d):
	while n != 1:
		d[spf[n]] = d.get(spf[n], 0) + 1
		n = n // spf[n]
	return
mod = 1000000007
inf = 1e+18

def solve():
	n = II()
	a = L()
	mn = inf
	for i in range(n):
		if a[i] < mn:
			mn = a[i]
			note = i
	print(n - 1)
	for i in range(n):
		if i != note:
			if abs(note - i) % 2 == 0:
				print(i + 1, note + 1, mn, mn)
			else:
				print(i + 1, note + 1, mn + 1, mn)
	return
t = II()
for i in range(t):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	mi = min(a)
	idx = a.index(mi)
	print(n - 1)
	for i in range(n):
		if i == idx:
			continue
		if (i - idx) % 2:
			print(i + 1, idx + 1, mi + 1, mi)
		else:
			print(i + 1, idx + 1, mi, mi)


import sys
import math
from math import factorial, inf, gcd, sqrt
from heapq import *
from functools import *
from itertools import *
from collections import *
from typing import *
from bisect import *
import random
sys.setrecursionlimit(10 ** 5)

def rarray():
	return [int(i) for i in input().split()]
t = 1
t = int(input())
for ii in range(t):
	n = int(input())
	a = rarray()
	m = a.index(min(a))
	f = [a[m] + 1]
	for i in range(a[m] + 2, int(2000000000.0)):
		if gcd(f[0], i) == 1 and gcd(a[m], i) == 1:
			f.append(i)
			break
	j = 0
	print(n - 1)
	for i in range(n):
		if i != m:
			print(i + 1, m + 1, f[j], a[m])
			j ^= 1


def findMinIndex(arr):
	minm = arr[0]
	minIndex = 0
	for i in range(1, len(arr)):
		if arr[i] < minm:
			minm = arr[i]
			minIndex = i
	return minIndex
for t in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	final = []
	minIndex = findMinIndex(arr)
	count = 1
	for i in range(minIndex - 1, -1, -1):
		arr[i] = arr[minIndex] + count
		count += 1
		final.append([minIndex + 1, i + 1, arr[minIndex], arr[i]])
	count = 1
	for i in range(minIndex + 1, n):
		arr[i] = arr[minIndex] + count
		final.append([minIndex + 1, i + 1, arr[minIndex], arr[i]])
		count += 1
	print(len(final))
	for ele in final:
		print(*ele)


from math import *
from collections import *
from functools import *
from bisect import *
from itertools import *
from heapq import *
inf = float('inf')
ninf = -float('inf')
ip = input
alphal = 'abcdefghijklmnopqrstuvwxyz'
alphau = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
mod = 10 ** 9 + 7

def ipl():
	return list(map(int, ip().split()))

def ipn():
	return int(ip())

def ipf():
	return float(ip())

def solve():
	n = ipn()
	a = ipl()
	i = a.index(min(a))
	print(n - 1)
	for j in range(n):
		if i != j:
			print(i + 1, j + 1, a[i], a[i] + abs(i - j))
t = ipn()
for _ in range(t):
	solve()


import os
import sys
from io import BytesIO, IOBase
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()

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

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

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
from heapq import *
from collections import deque as dq
from math import ceil, floor, sqrt, pow, factorial, log2
import bisect as bs
from collections import Counter
from itertools import permutations
for _ in range(N()):
	n = N()
	a = RLL()
	ans = []
	m = 999999999999999
	j = -1
	for i in range(n):
		if a[i] < m:
			m = a[i]
			j = i
	for i in range(n):
		if i != j:
			if (i - j) % 2 == 0:
				ans.append([j + 1, i + 1, a[j], a[j]])
			else:
				ans.append([j + 1, i + 1, a[j], a[j] + 1])
	print(len(ans))
	for i in ans:
		print(*i)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
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')

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree1:

	def __init__(self, data, default=10 ** 6, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
MOD = 10 ** 9 + 7

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
mod = 10 ** 9 + 7
omod = 998244353
prime = [True for i in range(10)]
pp = [0] * 10

def SieveOfEratosthenes(n=10):
	p = 2
	c = 0
	while p * p <= n:
		if prime[p] == True:
			c += 1
			for i in range(p, n + 1, p):
				pp[i] += 1
				prime[i] = False
		p += 1

def binarySearch(arr, n, key):
	left = 0
	right = n - 1
	mid = 0
	res = arr[n - 1]
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] >= key:
			res = arr[mid]
			right = mid - 1
		else:
			left = mid + 1
	return res

def binarySearch1(arr, n, key):
	left = 0
	right = n - 1
	mid = 0
	res = arr[0]
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] > key:
			right = mid - 1
		else:
			res = arr[mid]
			left = mid + 1
	return res
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(n - 1)
	m = min(a)
	ind = 0
	for i in range(n):
		if a[i] == m:
			ind = i
	c = 0
	for i in range(ind + 1, n):
		if c % 2 == 0:
			print(ind + 1, i + 1, m, m + 1)
			c = 1
		else:
			print(ind + 1, i + 1, m, m)
			c = 0
	c = 0
	for i in range(ind - 1, -1, -1):
		if c % 2 == 0:
			print(ind + 1, i + 1, m, m + 1)
			c = 1
		else:
			print(ind + 1, i + 1, m, m)
			c = 0


import sys
t = int(sys.stdin.readline())
for i in range(t):
	n = int(sys.stdin.readline())
	data = list(map(int, sys.stdin.readline().split()))
	val = min(data)
	idx = data.index(val)
	print(len(data) - 1)
	for j in range(len(data)):
		if j == idx:
			continue
		print(f'{idx + 1} {j + 1} {val} {val + abs(idx - j)}')


import sys
input = lambda : sys.stdin.readline()
print = lambda x: sys.stdout.write(str(x) + '\n')
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	minidx = a.index(min(a))
	ans = []
	if minidx > 0:
		ans.append((1, minidx + 1, a[minidx], a[minidx] + 1))
		a[0] = a[minidx]
	for i in range(1, n):
		ans.append((1, i + 1, a[0], a[i - 1] + 1))
		a[i] = a[i - 1] + 1
	print(len(ans))
	for x in ans:
		print(' '.join(map(str, x)))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	i = 0
	m = 10 ** 9 + 7
	print(n // 2)
	while i < n - 1:
		print(i + 1, i + 2, min(a[i], a[i + 1]), m)
		i += 2