Salmon loves to be a tidy person. One day, when he looked at the mess that he made after playing with his rubber ducks, he felt awful. Now he wants to clean up his mess, by placing his ducks into boxes.
Each rubber duck has a color. There are a total of $N+1$ colors, numbered from $0$ to $N$. Salmon wants to place his $N*K$ ducks into $N$ boxes, each of which can fit $K$ ducks. Each duck should be placed inside a box.
Salmon is very particular when it comes to how many colors he can place in each box. Since Salmon doesn't like lots of colors mixing together he only wants to have a maximum of $2$ distinct colors per box.
Please help Salmon achieve this goal!

It can be shown that there will always be at least one valid solution under given constraints.

If there are multiple correct solutions, you may output any one of them.   

-----Input:-----
- The first line contains an integer $T$, denoting the number of testcases. $T$ testcases will follow, each containing two lines.   
- The first line of each testcase contains two space-separated integers $N$ and $K$.   
- The second line of each testcase contains $N+1$  space-separated integers. The $i+1$-th integer denotes the number of ducks with color-$i$ where $0 \leq i \leq N$

-----Output:-----
- Output $N$ lines for each testcase. 
- The $i$-th line of a testcase should contain $4$ space-separated integers $c1, m1, c2, m2$ respectively which denotes that that are $m1$ ducks of color-$c1$ and $m2$ ducks of color-$c2$ inside the $i$-th box where $0 \leq m1,m2 \leq K$ and $0 \leq c1,c2 \leq N$. 
- Note that even if you have only one color to put inside the $i$-th box, you should still output $4$ space-separated integers and keep either $m1$ or $m2$ as $0$. And $0 \leq c1,c2 \leq N$.
- The output should be valid and should satisfy Salmon's goal.

-----Constraints-----
- $T=10$
- $2 \leq N \leq 10^5$ 
- $2 \leq K \leq 10^5$ 
- Total ducks for each test case is exactly $N*K$
- There can be a color with $0$ ducks

-----Subtasks-----
- Subtask 1 [20 points]: $2 \leq N \leq 10$, $K=2$ 
- Subtask 2 [30 points]: $N=2$, $K=5$
- Subtask 3 [50 points]: original constraints

-----Sample Input:-----
1
2 4
3 4 1

-----Sample Output:-----
2 1 1 3
1 1 0 3

-----Explanation:-----
- In the given testcase, Salmon has $N=2$ boxes, each of size $K=4$ and there are total $N*K=8$ ducks.   
- The first box is filled with $1$ duck of color-$2$ and $3$ ducks of color-$1$ and the second box is filled with $1$ duck of color-$1$ and $3$ ducks of color-$0$.   
- Each duck is inside a box and each box has at most two distinct colors. Also each box contains exactly $K=4$ ducks.

Source: codechef | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	c = [int(i) for i in input().split()]
	i = 0
	m = 0
	if n == 2 and k == 5:
		c1 = c
		c.sort()
		d = dict()
		for i in range(len(c)):
			for j in range(len(c1)):
				if c[i] == c1[j]:
					d[i] = j
					c1[j] = -1
					break
		while m < n:
			if i == n:
				print(d[n], k, d[n - 1], 0)
				c[n] -= k
				m += 1
			elif c[i] >= k:
				print(d[i], k, d[i + 1], 0)
				c[i] = c[i] - k
				m += 1
			elif c[i] == 0:
				i += 1
			else:
				for j in range(i + 1, n + 1):
					if c[i] + c[j] >= k:
						print(d[i], c[i], d[j], k - c[i])
						c[j] -= k - c[i]
						c[i] = 0
						m += 1
						break
	else:
		while m < n:
			if i == n:
				print(n, k, n - 1, 0)
				c[n] -= k
				m += 1
			elif c[i] >= k:
				print(i, k, i + 1, 0)
				c[i] = c[i] - k
				m += 1
			elif c[i] == 0:
				i += 1
			else:
				for j in range(i + 1, n + 1):
					if c[i] + c[j] >= k:
						print(i, c[i], j, k - c[i])
						c[j] -= k - c[i]
						c[i] = 0
						m += 1
						break


t = int(input())
for i in range(0, t):
	(n, k) = list(map(int, input().split()))
	c = list(map(int, input().split()))
	l = c[:]
	while sum(l) != 0:
		a = max(l)
		b = min(l)
		m1 = c.index(a)
		m2 = c.index(b)
		n1 = l.index(a)
		n2 = l.index(b)
		print(str(m2) + ' ' + str(c[m2]) + ' ' + str(m1) + ' ' + str(k - c[m2]))
		l[n1] = l[n1] - (k - c[m2])
		del l[n2]
		c[m1] = c[m1] - (k - c[m2])
		c[m2] = 0


def abc(balls, n):
	y = n
	i = 0
	while y:
		if i <= n and balls[i] == 0:
			i = i + 1
			continue
		c1 = i
		if balls[i] >= 2:
			balls[i] -= 2
			m1 = 2
			c2 = n
			m2 = 0
		else:
			m1 = 1
			balls[i] = 0
			j = i
			while j < n and balls[j] == 0:
				j = j + 1
			i = j
			c2 = i
			balls[i] -= 1
			m2 = 1
		print(c1, m1, c2, m2)
		y = y - 1
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	balls = list(map(int, input().split()))
	if k == 2:
		abc(balls, n)
		continue
	arr = []
	for i in range(n + 1):
		arr.append([balls[i], i])
	arr = sorted(arr, key=lambda x: x[0])
	i = 0
	j = n
	y = n
	while arr[j][0] == 0:
		j = j - 1
	while y:
		if i == j:
			print(arr[i][1], arr[i][0], n, 0)
			y = y - 1
			continue
		x = k
		c1 = arr[i][1]
		if x <= arr[i][0]:
			arr[i][0] = arr[i][0] - x
			m1 = k
			m2 = 0
			c2 = n
		else:
			x = k - arr[i][0]
			m1 = arr[i][0]
			arr[i][0] = 0
			c2 = arr[j][1]
			m2 = min(arr[j][0], x)
			arr[j][0] = max(arr[j][0] - x, 0)
		if arr[j][0] == 0:
			j = j - 1
		if arr[i][0] == 0:
			i = i + 1
		print(c1, m1, c2, m2)
		y = y - 1


for i in range(int(input())):
	(n, k) = list(map(int, input().split()))
	lis = list(map(int, input().split()))
	mylis = []
	val = 0
	total = 0
	for i in range(n + 1):
		mylis.append([i, lis[i]])
	mylis = sorted(mylis, key=lambda x: x[1])
	i = 0
	j = n
	while total < k * n:
		if mylis[0][1] == k:
			mylis[0][1] -= k
			print(mylis[0][0], k, 0, 0)
			mylis = mylis[1:]
			total += k
		elif mylis[0][1] > k:
			mylis[0][1] -= k
			print(mylis[0][0], k, 0, 0)
			total += k
		else:
			val = mylis[0][1]
			print(mylis[0][0], val, mylis[-1][0], k - val)
			mylis = mylis[1:]
			mylis[-1][1] = mylis[-1][1] - (k - val)
			total += k


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest, nlargest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def chkprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
for _ in range(int(inp())):
	(n, k) = mp()
	l = lmp()
	l = [[l[i], i] for i in range(n + 1)]
	heapify(l)
	for i in range(n):
		b = nlargest(1, l)[0]
		s = nsmallest(1, l)[0]
		print(s[1], s[0], b[1], k - s[0])
		b[0] -= k - s[0]
		heappop(l)