The new generation external memory contains an array of integers $a[1 \ldots n] = [a_1, a_2, \ldots, a_n]$.

This type of memory does not support changing the value of an arbitrary element. Instead, it allows you to cut out any segment of the given array, cyclically shift (rotate) it by any offset and insert it back into the same place.

Technically, each cyclic shift consists of two consecutive actions:

You may select arbitrary indices $l$ and $r$ ($1 \le l < r \le n$) as the boundaries of the segment.

Then you replace the segment $a[l \ldots r]$ with it's cyclic shift to the left by an arbitrary offset $d$. The concept of a cyclic shift can be also explained by following relations: the sequence $[1, 4, 1, 3]$ is a cyclic shift of the sequence $[3, 1, 4, 1]$ to the left by the offset $1$ and the sequence $[4, 1, 3, 1]$ is a cyclic shift of the sequence $[3, 1, 4, 1]$ to the left by the offset $2$.

For example, if $a = [1, \color{blue}{3, 2, 8}, 5]$, then choosing $l = 2$, $r = 4$ and $d = 2$ yields a segment $a[2 \ldots 4] = [3, 2, 8]$. This segment is then shifted by the offset $d = 2$ to the left, and you get a segment $[8, 3, 2]$ which then takes the place of of the original elements of the segment. In the end you get $a = [1, \color{blue}{8, 3, 2}, 5]$.

Sort the given array $a$ using no more than $n$ cyclic shifts of any of its segments. Note that you don't need to minimize the number of cyclic shifts. Any method that requires $n$ or less cyclic shifts will be accepted.


-----Input-----

The first line contains an integer $t$ ($1 \leq t \leq 1000$) — the number of test cases.

The next $2t$ lines contain the descriptions of the test cases.

The first line of each test case description contains an integer $n$ ($2 \leq n \leq 50$) — the length of the array. The second line consists of space-separated elements of the array $a_i$ ($-10^9 \leq a_i \leq 10^9$). Elements of array $a$ may repeat and don't have to be unique.


-----Output-----

Print $t$ answers to all input test cases.

The first line of the answer of each test case should contain an integer $k$ ($0 \le k \le n$) — the number of actions to sort the array. The next $k$ lines should contain descriptions of the actions formatted as "$l$ $r$ $d$" (without quotes) where $l$ and $r$ ($1 \le l < r \le n$) are the boundaries of the segment being shifted, while $d$ ($1 \le d \le r - l$) is the offset value. Please remember that only the cyclic shifts to the left are considered so the chosen segment will be shifted by the offset $d$ to the to the left.

Note that you are not required to find the minimum number of cyclic shifts needed for sorting. Any sorting method where the number of shifts does not exceed $n$ will be accepted.

If the given array $a$ is already sorted, one of the possible answers is $k = 0$ and an empty sequence of cyclic shifts.

If there are several possible answers, you may print any of them.


-----Examples-----

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


-----Note-----

Explanation of the fourth data set in the example:

The segment $a[2 \ldots 4]$ is selected and is shifted to the left by $2$: $[2, \color{blue}{5, 1, 4}, 3] \longrightarrow [2, \color{blue}{4, 5, 1}, 3]$

The segment $a[1 \ldots 5]$ is then selected and is shifted to the left by $3$: $[\color{blue}{2, 4, 5, 1, 3}] \longrightarrow [\color{blue}{1, 3, 2, 4, 5}]$

After that the segment $a[1 \ldots 2]$ is selected and is shifted to the left by $1$: $[\color{blue}{1, 3}, 2, 4, 5] \longrightarrow [\color{blue}{3, 1}, 2, 4, 5]$

And in the end the segment $a[1 \ldots 3]$ is selected and is shifted to the left by $1$: $[\color{blue}{3, 1, 2}, 4, 5] \longrightarrow [\color{blue}{1, 2, 3}, 4, 5]$

Difficulty: EASY

Solutions:
def shift(l, n):
	return l[n:] + l[:n]
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = sorted(a)
	ans = []
	for i in range(n):
		if a[i] == b[i]:
			continue
		num = b[i]
		j = a[i:].index(num) + i
		d = j - i
		ans.append([i + 1, j + 1, d])
		c = a[i:j + 1]
		c = shift(c, d)
		a[i:j + 1] = c
	print(len(ans))
	for i in ans:
		print(*i)


from sys import stdin, stdout

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

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

def strs_from_str():
	return stdin.readline().strip().split()

def print_(for_print):
	stdout.write(str(for_print) + '\n')

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

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

def print_nl():
	stdout.write('\n')

def gcd_sum(n):
	return gcd(n, sum(map(int, list(str(n)))))

def solve(n, l):
	(k, l_ans) = (0, [])
	for i in range(n):
		mn = min(l[i:n])
		ind = l[i:n].index(mn) + i
		if ind > i:
			for j in range(ind - i):
				l[ind - j] = l[ind - j - 1]
			l[i] = mn
			k += 1
			l_ans.append(str(i + 1) + ' ' + str(ind + 1) + ' ' + str(ind - i))
	print_(k)
	for i in l_ans:
		print_(i)
sets = int_()
for _ in range(sets):
	solve(int_(), ilist_from_str())


t = int(input())
for _ in range(t):
	n = int(input())
	actions = []
	a = list(map(int, input().split()))
	for i in range(len(a) - 1):
		min_pos = i
		for j in range(i + 1, len(a)):
			if a[j] < a[min_pos]:
				min_pos = j
		if min_pos > i:
			actions.append((i, min_pos))
			opt = a[min_pos]
			for j in range(min_pos, i, -1):
				a[j] = a[j - 1]
			a[i] = opt
	print(len(actions))
	for ac in actions:
		print(ac[0] + 1, ac[1] + 1, ac[1] - ac[0])


import os, sys
from io import BytesIO, IOBase
from math import log2, ceil, sqrt, gcd
from _collections import deque
import heapq as hp
from bisect import bisect_left, bisect_right
from math import cos, sin
from itertools import permutations
from operator import itemgetter
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')
mod = 10 ** 9 + 7

def solve(id, x):
	l = id
	for i in range(id, n):
		if a[i] == x:
			l = i
			break
	ct = [a[l]] + a[id:l]
	ans.append([id + 1, l + 1, len(ct) - 1])
	for i in range(len(ct)):
		a[i + id] = ct[i]
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	ck = sorted(a)
	for i in range(n):
		if a[i] != ck[i]:
			solve(i, ck[i])
	print(len(ans))
	for i in ans:
		print(*i)


def shifts(arr):
	steps = []
	req = sorted(arr)
	while arr != req:
		(nomat, ind) = nonmatch(arr, req)
		shift = ind - nomat
		changed = [arr[ind]]
		changed.extend(arr[nomat:ind])
		arr[nomat:ind + 1] = changed
		steps.append([nomat, ind, shift])
	return steps

def nonmatch(arr, req):
	curr = -1
	for i in range(len(arr)):
		if arr[i] != req[i]:
			curr = i
			break
	nex = -1
	for i in range(curr, len(arr)):
		if arr[i] == req[curr]:
			nex = i
	return (curr, nex)
for j in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	steps = shifts(arr)
	print(len(steps))
	for i in steps:
		print(f'{i[0] + 1} {i[1] + 1} {i[2]}')


t = int(input())
for ti in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	q = [[a[i], i] for i in range(n)]
	q.sort()
	for i in range(n):
		a[q[i][1]] = i
	aa = []
	for i in range(n):
		if a[i] != i:
			b = a.index(i)
			aa.append([i + 1, b + 1, b - i])
			a = a[:i] + a[b:b + 1] + a[i:b] + a[b + 1:]
	print(len(aa))
	for i in aa:
		print(' '.join(list(map(str, i))))


for j in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	res = []
	for i in range(1, n):
		md = a.index(min(a))
		if md:
			res.append([i, i + md, md])
		a = a[:md] + a[md + 1:]
	print(len(res))
	for i in res:
		print(*i)


def cyc(arr, d):
	nw = [0] * len(arr)
	for i in range(len(arr)):
		nw[i] = arr[(i + d) % len(arr)]
	return nw
for _ in range(int(input())):
	llen = int(input())
	l = list(map(int, input().split()))
	ans = []
	sortedp = 0
	for i in range(sortedp, llen - 1):
		mn = 10000000000.0
		idx = -1
		for j in range(sortedp, llen):
			if l[j] < mn:
				mn = l[j]
				idx = j
		x = abs(sortedp - idx)
		if x == 0:
			sortedp += 1
			continue
		nxt = cyc(l[sortedp:idx + 1], x)
		for k in range(len(nxt)):
			l[k + sortedp] = nxt[k]
		ans.append([sortedp + 1, idx + 1, x])
		sortedp += 1
	print(len(ans))
	for el in ans:
		print(*el)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	for i in range(n - 1):
		idx = a.index(min(a))
		if idx > 0:
			ans.append([i + 1, i + idx + 1, idx])
		a = a[:idx] + a[idx + 1:]
	print(len(ans))
	for k in ans:
		print(*k)


def rotate_left(lst, l, r):
	hold = [lst[r]]
	for k in range(l, r):
		hold.append(lst[k])
	for k in range(l, r + 1):
		lst[k] = hold[k - l]
	return lst
T = int(input())
for t in range(T):
	N = int(input())
	vals = [int(s) for s in input().split()]
	v2 = [s for s in vals]
	v2.sort()
	rots = []
	for (i, v) in enumerate(v2):
		if v != vals[i]:
			j = i + 1
			while vals[j] != v:
				j += 1
			vals = rotate_left(vals, i, j)
			rots.append((i + 1, j + 1, j - i))
	print(len(rots))
	for (l, r, d) in rots:
		print(l, r, d)


from collections import deque
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = a.copy()
	b.sort()
	ans = 0
	out = []
	start = 0
	while True:
		if a == b:
			break
		for i in range(start, n):
			if a[i] == b[i] and i == start:
				start += 1
				break
			if a[i] == b[start]:
				temp = deque(a[start:i + 1])
				temp.rotate(-(i - start))
				a = a[:start] + list(temp) + a[i + 1:]
				out.append([start + 1, i + 1, i - start])
				start += 1
				ans += 1
				break
	print(ans)
	for i in out:
		print(*i)


import bisect
import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	o = l.copy()
	o.sort()
	if l == o:
		sys.stdout.write('0\n')
		continue
	cnt = 0
	ans = 0
	w = []
	while cnt < n:
		if l[cnt] == o[cnt]:
			cnt += 1
			continue
		for i in range(cnt, n):
			if l[i] == o[cnt]:
				ans += 1
				w.append((cnt + 1, i + 1, i - cnt))
				h = l[cnt:i]
				q = l[i]
				e = l[0:cnt] + [q] + h + l[i + 1:n]
				l = e
				break
		cnt += 1
	sys.stdout.write(str(ans) + '\n')
	for i in w:
		sys.stdout.write(str(i[0]) + ' ' + str(i[1]) + ' ' + str(i[2]) + '\n')


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	res = []
	for i in range(n):
		min_val = min(arr)
		min_ind = arr.index(min_val)
		if min_ind:
			res.append([i + 1, i + 1 + min_ind, min_ind])
		del arr[min_ind]
	print(len(res))
	for x in res:
		print(*x)


from sys import stdin
import collections, heapq, bisect, math
input = stdin.readline

def rint():
	return int(input())

def rstr():
	return input().strip()

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

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

def main():
	n = rint()
	arr = rlint()
	s = sorted(arr)
	res = []

	def shift(i, j):
		for k in range(j - 1, i - 1, -1):
			(arr[k], arr[k + 1]) = (arr[k + 1], arr[k])
	for i in range(n):
		j = i
		while j < n and s[i] != arr[j]:
			j += 1
		if i != j:
			shift(i, j)
			res.append([i + 1, j + 1, j - i])
	print(len(res))
	for row in res:
		print(*row)
for _ in range(rint()):
	main()


import sys
import io, os
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	ans = []
	for i in range(n):
		B = A[i:n]
		m = min(B)
		for j in range(i, n):
			if A[j] == m:
				break
		if i == j:
			continue
		A[i:j + 1] = [A[j]] + A[i:j]
		ans.append((i + 1, j + 1, j - i))
	print(len(ans))
	for i in range(len(ans)):
		print(*ans[i])


from collections import deque
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(__) for __ in input().split()]
	ans = []
	arr_sorted = arr[:]
	arr_sorted.sort()
	for _ in range(n):
		if arr[_] != arr_sorted[_]:
			idx = arr[_:].index(arr_sorted[_]) + _
			ans.append([_ + 1, idx + 1, idx - _])
			deq_rotated = deque(arr[_:idx + 1])
			deq_rotated.rotate(_ - idx)
			arr = arr[:_] + list(deq_rotated) + arr[idx + 1:]
	print(len(ans))
	for _ in ans:
		print(*_)


import sys
for _ in range(int(sys.stdin.readline())):
	n = int(sys.stdin.readline())
	d = [int(i) for i in sys.stdin.readline().split()]
	(r, rr) = ('', 0)
	for i in range(n - 1):
		x = d[i:]
		a = x.index(min(x))
		if a != 0:
			r += '%d %d %d\n' % (i + 1, a + 1 + i, a)
			rr += 1
			d = d[:i] + [d[a + i]] + d[i:a + i] + d[a + 1 + i:]
	sys.stdout.write('%d\n%s' % (rr, r))


import sys
from sys import stdin, stdout
from math import ceil, floor, sqrt, log, log2, log10
from collections import Counter
int_max = float('inf')
int_min = -float('inf')
ANS = []
input = stdin.readline

def solve():
	pass
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	temp = arr[:]
	temp.sort()
	i = 0
	ans = []
	while i < n:
		if arr[i] == temp[i]:
			i += 1
			continue
		else:
			l = i
			r = i
			for j in range(i, n):
				if arr[j] == temp[i]:
					r = j
					break
			tempVal = arr[r]
			arr[l + 1:r + 1] = arr[l:r]
			arr[l] = tempVal
			ans.append([l + 1, r + 1, r - l])
		i += 1
	print(len(ans))
	for i in ans:
		print(*i)


from os import path
from io import BytesIO, IOBase
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, Counter, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

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

def si():
	return input().rstrip()

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

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('0')
file = 1

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

def solve():
	for _ in range(1, ii() + 1):
		n = ii()
		a = li()
		b = a[:]
		b.sort()
		res = []
		for i in range(n):
			if a[i] == b[i]:
				continue
			for j in range(i + 1, n):
				if a[j] == b[i]:
					d = j - i
					res.append([i + 1, j + 1, d])
					a[i] = a[j]
					a[i + 1:j + 1] = a[i:j]
		print(len(res))
		for i in res:
			print(*i)
if file:
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


try:
	t = int(input())
	for i in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		count = 0
		output = []
		for j in range(n):
			mn = a[j]
			mnpos = j
			for k in range(j, n):
				if a[k] < mn:
					mn = a[k]
					mnpos = k
			if mnpos != j:
				output.append((j + 1, mnpos + 1, mnpos - j))
				count += 1
				temp = mn
				for k in range(mnpos, j, -1):
					a[k] = a[k - 1]
				a[j] = temp
		print(count)
		for j in range(count):
			print(output[j][0], output[j][1], output[j][2])
except:
	pass


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	b = []
	for j in arr:
		b.append(j)
	b.sort()
	pt = []
	for j in range(n):
		mini = arr.index(b[j], j, n)
		if j == mini:
			continue
		pt.append([j, mini])
		arr = arr[:j] + [arr[mini]] + arr[j:mini] + arr[mini + 1:]
	print(len(pt))
	for i in pt:
		print(i[0] + 1, i[1] + 1, i[1] - i[0])


from sys import stdin
input = stdin.readline

def cycshift(a: list, n: int) -> list:
	lenlist = len(a)
	b = [0] * lenlist
	for i in range(len(a)):
		b[i - n] = a[i]
	return b
t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	count = 0
	res = 0
	b = []
	for i in range(n):
		mn = min(a)
		if a[0] == mn:
			a.pop(0)
			count += 1
		else:
			id = a.index(mn)
			b.append([1 + count, id + 1 + count, id])
			a[0:id + 1] = cycshift(a[0:id + 1], id)
			a.pop(0)
			count += 1
			res += 1
	print(res)
	for j in b:
		print(*j)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = sorted([x for x in a])
	shifts = []
	for (index, item) in enumerate(b):
		target_index = a[index:].index(item) + index
		if target_index == index:
			continue
		a[index:target_index + 1] = [item] + a[index:target_index]
		shifts.append((index + 1, target_index + 1, target_index - index))
	print(len(shifts))
	for (l, r, d) in shifts:
		print(l, r, d)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr1 = arr[:]
	arr1.sort()
	ans = []
	cnt = 0
	for i in range(n):
		x = arr1[i]
		start = i + 1
		zzz = arr.index(x)
		end = zzz + 1 + i
		arr.pop(zzz)
		if abs(start - end) == 0:
			continue
		ans.append([start, end, end - start])
		cnt += 1
	print(cnt)
	for xx in ans:
		print(*xx)


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(n - 1):
		mx = min(a[i:])
		for j in range(i, n):
			if a[j] == mx:
				break
		if j == i:
			continue
		a.insert(i, a.pop(j))
		ans += [[i + 1, j + 1, j - i]]
	print(len(ans))
	for (x, y, z) in ans:
		print(x, y, z)


def rotateArray(arr, n, d):
	temp = []
	i = 0
	while i < d:
		temp.append(arr[i])
		i = i + 1
	i = 0
	while d < n:
		arr[i] = arr[d]
		i = i + 1
		d = d + 1
	arr[:] = arr[:i] + temp
	return arr
for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	x = l.copy()
	x.sort()
	ans = 0
	a = []
	for i in range(n):
		if l[i] == x[i]:
			continue
		else:
			r = i + l[i:].index(x[i])
			if r == i:
				continue
			a.append([i + 1, r + 1, r - i])
			temp = rotateArray(l[i:r + 1], len(l[i:r + 1]), r - i)
			for j in range(len(temp)):
				l[i + j] = temp[j]
			ans += 1
	print(ans)
	for i in a:
		print(i[0], i[1], i[2])


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = sorted(a)
	c = []
	for i in range(n):
		if a[i] != b[i]:
			j = a.index(b[i], i)
			c.append((i + 1, j + 1, j - i))
			a[i:j + 1] = [a[j]] + a[i:j]
	print(len(c))
	for v in c:
		print(*v)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	s = sorted(arr)
	cnt = 0
	lst = []
	for i in range(n):
		if arr[i] == s[i]:
			continue
		for j in range(i + 1, n):
			if arr[j] == s[i]:
				cnt += 1
				lst.append([i + 1, j + 1, j - i])
				for k in range(j, i, -1):
					arr[k] = arr[k - 1]
				arr[i] = s[i]
				break
	print(cnt)
	for i in lst:
		print(*i)


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
from sys import stdin, stdout
sys.setrecursionlimit(10 ** 5)

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

def iinp():
	return int(inp())

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

def lmp():
	return list(mp())
t = iinp()
for i in range(t):
	n = iinp()
	a = lmp()
	b = sorted(a)
	ans = []
	for i in range(n):
		if a[0] != b[i]:
			j = a.index(b[i])
			ans.append([i + 1, j + i + 1, j])
			a.pop(j)
		else:
			a.pop(0)
	print(len(ans))
	for (i, j, k) in ans:
		print(i, j, k)


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 collections import Counter, defaultdict
import math
import heapq
import bisect

def nck(n, k):
	res = 1
	for i in range(1, k + 1):
		res = res * (n - i + 1) // i
	return res
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if arr == sorted(arr):
		print(0)
	else:
		ls = sorted(arr)
		o = []
		for i in range(n):
			if ls[i] == arr[i]:
				continue
			else:
				ind = 0
				for j in range(i + 1, n):
					if arr[j] == ls[i]:
						ind = j
						break
				o.append([i + 1, ind + 1, ind - i])
				var = arr[i]
				arr[i] = arr[ind]
				for j in range(i + 1, ind + 1):
					tt = arr[j]
					arr[j] = var
					var = tt
		print(len(o))
		for i in o:
			print(*i)


TESTS = int(input())
for _ in range(TESTS):
	size = int(input())
	arr = list(map(int, input().split()))
	fullarr = []
	op = []
	l = 0
	while l < size:
		r = arr.index(min(arr))
		if r > 0:
			d = r
			op.append(f'{l + 1} {r + l + 1} {d}')
		fullarr.append(arr.pop(r))
		l += 1
	print(len(op))
	for s in op:
		print(s)


for _ in range(int(input())):
	n = int(input())
	(*a,) = map(int, input().split())
	ans = []
	for i in range(n):
		mn_i = a[i:].index(min(a[i:])) + i
		if mn_i == i:
			continue
		if mn_i < i:
			break
		ans.append((i + 1, mn_i + 1, mn_i - i))
		a[i:mn_i + 1] = [a[mn_i]] + a[i:mn_i]
	print(len(ans))
	for el in ans:
		print(*el)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(s) for s in input().split()]
	b = sorted(a)
	c = 0
	e = [None] * (n + 1)
	k = 0
	v = 0
	for i in range(n):
		if a[i] != b[i]:
			j = a[i:].index(b[i]) + i
			v = a.pop(j)
			a.insert(i, v)
			c += 1
			e[k] = [i + 1, j + 1, j - i]
			k += 1
		pass
	print(c)
	for i in range(c):
		print(*e[i])


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	store = []
	for i in range(n):
		mini = min(arr[i:])
		indx = -1
		pos = -1
		for j in range(i, n):
			if arr[j] == mini:
				indx = j
				pos = j
				break
		temp = arr[indx]
		for k in range(pos, i, -1):
			arr[k] = arr[k - 1]
		arr[i] = temp
		if indx > i:
			store.append([i, indx, indx - i])
	l = len(store)
	print(l)
	for i in range(l):
		print(store[i][0] + 1, store[i][1] + 1, store[i][2])


from sys import stdin
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	b = list(a)
	k = []
	b.sort()
	c = 0
	for i in range(n - 1):
		if a[i] != b[i]:
			c += 1
			v = a.index(b[i], i)
			d = v - i
			k.append([i + 1, v + 1, d])
			a = a[:i] + a[v:v + 1] + a[i:v] + a[v + 1:]
	print(c)
	for i in k:
		print(*i)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = sorted(a)
	c = 0
	ans = []
	for i in range(n):
		if a[i] == b[i]:
			continue
		c += 1
		j = a.index(b[i], i)
		ans.append(i + 1)
		ans.append(j + 1)
		x = a[j]
		for z in range(j, i, -1):
			(a[z], a[z - 1]) = (a[z - 1], a[z])
	print(c)
	for d in range(0, len(ans) - 1, 2):
		print(ans[d], ans[d + 1], ans[d + 1] - ans[d])


def solution(a):
	temp_ans = []
	for i in range(len(a) - 1):
		min_i = i
		min_v = a[i]
		for j in range(i + 1, len(a)):
			if a[j] < min_v:
				min_v = a[j]
				min_i = j
		if min_i - i == 0:
			continue
		else:
			a = a[:i] + [min_v] + a[i:min_i] + a[min_i + 1:]
			temp_ans.append(f'{i + 1} {min_i + 1} {min_i - i}')
	print(len(temp_ans))
	for i in temp_ans:
		print(i)
t = int(input())
data = []
for i in range(t):
	n = int(input())
	temp = list(map(int, input().split()))
	data.append(temp)
for temp in data:
	solution(temp)