The sequence of $m$ integers is called the permutation if it contains all integers from $1$ to $m$ exactly once. The number $m$ is called the length of the permutation.

Dreamoon has two permutations $p_1$ and $p_2$ of non-zero lengths $l_1$ and $l_2$.

Now Dreamoon concatenates these two permutations into another sequence $a$ of length $l_1 + l_2$. First $l_1$ elements of $a$ is the permutation $p_1$ and next $l_2$ elements of $a$ is the permutation $p_2$. 

You are given the sequence $a$, and you need to find two permutations $p_1$ and $p_2$. If there are several possible ways to restore them, you should find all of them. (Note that it is also possible that there will be no ways.)


-----Input-----

The first line contains an integer $t$ ($1 \le t \le 10\,000$) denoting the number of test cases in the input.

Each test case contains two lines. The first line contains one integer $n$ ($2 \leq n \leq 200\,000$): the length of $a$. The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \leq a_i \leq n-1$).

The total sum of $n$ is less than $200\,000$.


-----Output-----

For each test case, the first line of output should contain one integer $k$: the number of ways to divide $a$ into permutations $p_1$ and $p_2$.

Each of the next $k$ lines should contain two integers $l_1$ and $l_2$ ($1 \leq l_1, l_2 \leq n, l_1 + l_2 = n$), denoting, that it is possible to divide $a$ into two permutations of length $l_1$ and $l_2$ ($p_1$ is the first $l_1$ elements of $a$, and $p_2$ is the last $l_2$ elements of $a$). You can print solutions in any order.


-----Example-----
Input
6
5
1 4 3 2 1
6
2 4 1 3 2 1
4
2 1 1 3
4
1 3 3 1
12
2 1 3 4 5 6 7 8 9 1 10 2
3
1 1 1

Output
2
1 4
4 1
1
4 2
0
0
1
2 10
0



-----Note-----

In the first example, two possible ways to divide $a$ into permutations are $\{1\} + \{4, 3, 2, 1\}$ and $\{1,4,3,2\} + \{1\}$.

In the second example, the only way to divide $a$ into permutations is $\{2,4,1,3\} + \{2,1\}$.

In the third example, there are no possible ways.

Difficulty: MEDIUM
Tags: Mathematics

Implementation

Starter code:

Solutions:
t = int(input())
for i in range(t):
	n = int(input())
	mass = [int(x) for x in input().split()]
	answer = 0
	q = []
	Max = 0
	ind = 0
	for j in range(n):
		if Max < mass[j]:
			Max = mass[j]
	ind = Max - 1
	a1 = mass[:n - ind - 1]
	a2 = mass[n - ind - 1:]
	a3 = mass[:ind + 1]
	a4 = mass[ind + 1:]
	a1.sort()
	a2.sort()
	a3.sort()
	a4.sort()
	f1 = True
	f2 = True
	for i in range(n - ind - 1):
		if a1[i] != i + 1:
			f1 = False
	if f1:
		for i in range(ind + 1):
			if a2[i] != i + 1:
				f1 = False
	if f1:
		answer += 1
		q.append((n - ind - 1, ind + 1))
	for i in range(ind + 1):
		if a3[i] != i + 1:
			f2 = False
	if f2:
		for i in range(n - ind - 1):
			if a4[i] != i + 1:
				f2 = False
	if f2 and n - ind - 1 != ind + 1:
		answer += 1
		q.append((ind + 1, n - ind - 1))
	print(answer)
	for l in q:
		print(*l)


for t in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	mx = max(ar)
	d = []
	for c in range(2):
		if set(ar[:mx]) == set(range(1, mx + 1)) and set(ar[mx:]) == set(range(1, n - mx + 1)):
			d.append(mx)
		mx = n - mx
	p = set(d)
	print(len(p))
	for x in p:
		print(x, n - x)


def possible(a):
	ans = set()
	s = set()
	lmax = 0
	for i in range(len(a)):
		lmax = max(lmax, a[i])
		s.add(a[i])
		if lmax == i + 1 and len(s) == i + 1:
			ans.add(i + 1)
	return ans
t = int(input())
for case_num in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	left = possible(a)
	a.reverse()
	right = possible(a)
	ans = []
	for l in left:
		if n - l in right:
			ans.append(l)
	print(len(ans))
	for l in ans:
		print(l, n - l)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	mx = max(a)
	p1 = a[:mx]
	p2 = a[mx:]
	test = 0
	test1 = 0
	if len(set(p1)) == mx and max(p1) == mx and (len(set(p2)) == n - mx) and (max(p2) == n - mx):
		test = 1
	p1 = a[:n - mx]
	p2 = a[n - mx:]
	if len(set(p1)) == n - mx and max(p1) == n - mx and (len(set(p2)) == mx) and (max(p2) == mx):
		test1 = 1
	if mx == n // 2 and test:
		print(1)
		print(mx, n - mx)
	elif test and test1:
		print(2)
		print(mx, n - mx)
		print(n - mx, mx)
	elif test:
		print(1)
		print(mx, n - mx)
	elif test1:
		print(1)
		print(n - mx, mx)
	else:
		print(0)


for case in range(int(input())):
	n = int(input())
	series = [int(x) for x in input().split()]
	no_of_ways = 0
	set_a = set()
	set_b = set(series)
	letter_freq = {}
	for l in series:
		try:
			letter_freq[l] += 1
		except KeyError:
			letter_freq[l] = 1
	answers = []
	indices_to_end_a = set()
	visited = {}
	curr_max = -1
	for i in range(1, n + 1):
		num = series[i - 1]
		if num in visited:
			break
		visited[num] = True
		curr_max = max(curr_max, num)
		if curr_max == i:
			indices_to_end_a.add(i)
	visited = {}
	curr_max = -1
	series2 = series[::-1]
	indices_to_end_b = set()
	for i in range(1, n + 1):
		num = series2[i - 1]
		if num in visited:
			break
		visited[num] = True
		curr_max = max(curr_max, num)
		if curr_max == i:
			indices_to_end_b.add(n - i)
	for i in indices_to_end_a:
		if i in indices_to_end_b:
			answers.append([i, n - i])
	print(len(answers))
	for a in answers:
		print(a[0], a[1])


import sys

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		nums = list(map(int, sys.stdin.readline().split()))
		leftSet = set()
		rightSet = set()
		ans = []
		flag = True
		validFlag = True
		for i in range(len(nums)):
			if flag:
				if nums[i] in leftSet:
					flag = False
					if max(leftSet) != len(leftSet):
						validFlag = False
						break
				else:
					leftSet.add(nums[i])
			if not flag:
				if nums[i] in rightSet:
					validFlag = False
					break
				else:
					rightSet.add(nums[i])
		if validFlag:
			if leftSet and rightSet and (max(leftSet) == len(leftSet)) and (max(rightSet) == len(rightSet)):
				ans.append([len(leftSet), len(rightSet)])
		flag = True
		validFlag = True
		leftSet = set()
		rightSet = set()
		for i in reversed(range(len(nums))):
			if flag:
				if nums[i] in rightSet:
					flag = False
					if max(rightSet) != len(rightSet):
						validFlag = False
						break
				else:
					rightSet.add(nums[i])
			if not flag:
				if nums[i] in leftSet:
					validFlag = False
					break
				else:
					leftSet.add(nums[i])
		if validFlag:
			if leftSet and rightSet and (max(leftSet) == len(leftSet)) and (max(rightSet) == len(rightSet)):
				if [len(leftSet), len(rightSet)] not in ans:
					ans.append([len(leftSet), len(rightSet)])
		print(len(ans))
		for i in ans:
			print(i[0], i[1])
	return
main()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	l = max(a)
	y = {}
	u = 0
	for i in a:
		if i in y:
			y[i] += 1
		else:
			y[i] = 1
		if y[i] >= 3:
			u += 1
			break
	if u == 1:
		print(0)
		continue
	z = 0
	b = set()
	x = 0
	for i in range(l):
		if a[i] in b:
			x += 1
		else:
			b.add(a[i])
	c = a[l:]
	c.sort()
	for i in range(n - l):
		if c[i] != i + 1:
			x = x + 1
	if x == 0:
		z += 1
		p = l
		q = n - l
	u = 0
	b = set()
	x = 0
	for i in range(n - 1, n - l - 1, -1):
		if a[i] in b:
			x += 1
		else:
			b.add(a[i])
	c = a[:n - l]
	c.sort()
	for i in range(n - l):
		if c[i] != i + 1:
			x = x + 1
	if x == 0:
		u += 1
		z += 1
		r = n - l
		s = l
	if z == 0:
		print(0)
	elif z == 1:
		print(1)
		if u == 1:
			print(r, s)
		else:
			print(p, q)
	elif p == q:
		print(1)
		print(r, s)
	else:
		print(2)
		print(r, s)
		print(p, q)


t = int(int(input()))
for x in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ma = max(a)
	List = []
	if set(range(1, ma + 1)) == set(a[:ma]) and set(range(1, n - ma + 1)) == set(a[ma:]):
		List.append([ma, n - ma])
	if ma != n - ma:
		if set(range(1, n - ma + 1)) == set(a[:n - ma]) and set(range(1, ma + 1)) == set(a[n - ma:]):
			List.append([n - ma, ma])
	print(len(List))
	if len(List):
		for item in List:
			print(*item)


t = int(input())
ans = []
for i in range(t):
	n = int(input())
	nums = list(map(int, input().split()))
	summ_all = sum(nums)
	counter = 0
	variants = []
	nums_index = [-1] * n
	L = 0
	R = n - 1
	for j in range(n):
		if nums_index[nums[j] - 1] != -1:
			L = max(L, nums_index[nums[j] - 1] + 1)
			R = min(R, j)
		nums_index[nums[j] - 1] = j
	if L > R:
		ans.append([0])
	else:
		sum1 = sum(nums[:L])
		for j in range(L, R + 1):
			if sum1 == (j + 1) * j // 2 and summ_all - sum1 == (n - j) * (n - j + 1) // 2:
				variants.append(str(j) + ' ' + str(n - j))
				counter += 1
			sum1 += nums[j]
		ans.append([counter, variants])
for i in ans:
	print(i[0])
	if i[0] != 0:
		for j in range(i[0]):
			print(i[1][j])


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	(cnt, l, r, t) = ([0] * n, [0] * n, [0] * n, 0)
	for i in range(n):
		cnt[a[i]] += 1
		if cnt[a[i]] > 1:
			break
		t = max(t, a[i])
		if t == i + 1:
			l[i] = 1
	(cnt, t) = ([0] * n, 0)
	for i in range(n - 1, -1, -1):
		cnt[a[i]] += 1
		if cnt[a[i]] > 1:
			break
		t = max(t, a[i])
		if t == n - i:
			r[i] = 1
	res = []
	for i in range(n - 1):
		if l[i] + r[i + 1] == 2:
			res.append((i + 1, n - i - 1))
	print(len(res))
	for x in res:
		print(*x)


for i in range(int(input())):
	n = int(input())
	a = [int(j) for j in input().split()]
	pos = []
	b = [0 for j in range(n)]
	(maxb, countb) = (-1, 0)
	for j in range(n):
		if b[a[j] - 1] == 1:
			break
		b[a[j] - 1] = 1
		maxb = max(maxb, a[j])
		countb += 1
		if maxb == countb:
			pos.append(j + 1)
	(maxc, countc) = (-1, 0)
	k = len(pos) - 1
	(ans1, ans2) = (0, [])
	c = [0 for j in range(n)]
	for j in range(n - 1, -1, -1):
		if c[a[j] - 1] == 1:
			break
		c[a[j] - 1] = 1
		maxc = max(maxc, a[j])
		countc += 1
		while k > 0 and j < pos[k]:
			k -= 1
		if maxc == countc:
			if k < 0:
				break
			if j == pos[k]:
				ans1 += 1
				ans2.append(j)
	print(ans1)
	for j in range(ans1):
		print(ans2[j], n - ans2[j])


from collections import Counter
q = int(input())
for _ in range(q):
	n = int(input())
	dat = list(map(int, input().split()))
	c = Counter(dat)
	m = 0
	realmax = max(dat)
	f = True
	mode = 2
	maxval = -1
	for i in range(1, realmax + 1):
		if i not in c:
			f = False
			break
		if c[i] == 2:
			maxval = i
			continue
		if c[i] != 1:
			f = False
			break
	if n != maxval + realmax or f is False:
		print('0')
	else:
		lmax = dat[:maxval]
		rmax = dat[-maxval:]
		lreal = dat[:realmax]
		rreal = dat[-realmax:]
		lmax.sort()
		rmax.sort()
		lreal.sort()
		rreal.sort()
		ansm = list(range(1, maxval + 1))
		ansr = list(range(1, realmax + 1))
		res = []
		if lmax == ansm and rreal == ansr:
			res.append('{0} {1}'.format(maxval, realmax))
		if lreal == ansr and rmax == ansm:
			res.append('{0} {1}'.format(realmax, maxval))
		if len(res) == 2:
			if res[0] == res[1]:
				res = [res[0]]
		print(len(res))
		if len(res) > 0:
			print('\n'.join(res))


def main():
	n = int(input())
	lst = list(map(int, input().split()))
	mx = max(lst)
	ind1 = lst.index(mx)
	fst = set()
	if mx > len(lst) - 1 or mx < len(lst) // 2 + len(lst) % 2:
		print(0)
		return
	for i in range(0, mx):
		fst.add(lst[i])
	second = set()
	for i in range(mx, len(lst)):
		second.add(lst[i])
	can_be = 1
	for i in range(1, mx + 1):
		if not i in fst:
			can_be = 0
			break
	for i in range(1, len(lst) - mx + 1):
		if not i in second:
			can_be = 0
			break
	if can_be:
		to_print = str(mx) + ' ' + str(len(lst) - mx)
	fst = set()
	for i in range(0, len(lst) - mx):
		fst.add(lst[i])
	second = set()
	for i in range(len(lst) - mx, len(lst)):
		second.add(lst[i])
	if can_be and len(lst) - len(fst) == len(fst):
		print(1)
		print(to_print)
		return
	can_be1 = 1
	for i in range(1, len(lst) - mx + 1):
		if not i in fst:
			can_be1 = 0
			break
	for i in range(1, mx + 1):
		if not i in second:
			can_be1 = 0
			break
	if can_be1:
		if can_be:
			print(2)
			print(mx, len(lst) - mx)
			print(len(lst) - mx, mx)
		else:
			print(1)
			print(len(lst) - mx, mx)
	elif can_be:
		print(1)
		print(mx, len(lst) - mx)
	else:
		print(0)
t = int(input())
for i in range(t):
	main()


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = 0
	p = set()
	(l, r) = (0, sum(a))
	(left, right) = ({}, {})
	for i in a:
		right[i] = right.get(i, 0) + 1
	for i in range(n - 1):
		l += a[i]
		left[a[i]] = left.get(a[i], 0) + 1
		r -= a[i]
		right[a[i]] = right.get(a[i], 0) - 1
		if not right[a[i]]:
			del right[a[i]]
		j = n - i - 1
		if (2 + i) * (i + 1) // 2 == l and (j + 1) * j // 2 == r:
			if len(left) == i + 1 and len(right) == j:
				cnt += 1
				p.add((i + 1, n - i - 1))
	print(cnt)
	if cnt:
		for el in p:
			print(*el)


import sys
r = int(input())
t = -1

def input():
	global t
	t += 1
	return data[t]
data = sys.stdin.readlines()
for _ in range(r):
	k = int(input())
	a = list(map(int, input().split()))
	m = 0
	s = set()
	left = [False] * k
	for i in range(k):
		s.add(a[i])
		m = max(a[i], m)
		if m == len(s) == i + 1:
			left[i] = True
	m = 0
	s = set()
	right = [False] * k
	for i in range(k - 1, -1, -1):
		s.add(a[i])
		m = max(a[i], m)
		if m == len(s) == k - i:
			right[i] = True
	count = 0
	answer = []
	for i in range(k - 1):
		if left[i] and right[i + 1]:
			count += 1
			answer.append((i + 1, k - i - 1))
	print(count)
	for i in answer:
		print(*i)


t = int(input())
for test in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	z = set(a)
	if len(list(z)) == 1 and len(a) != 2:
		print(0)
	else:
		m = max(a)
		if m < n:
			s1 = set(a[0:m])
			s2 = set(a[len(a) - m:len(a)])
			x = list(s1)
			y = list(s2)
			if len(x) != m and len(y) != m:
				print(0)
			elif len(x) == m and len(y) == m:
				s1 = set(a[m:])
				s2 = set(a[0:n - m])
				l1 = []
				count = 1
				for i in range(m, n):
					l1.append(count)
					count += 1
				if n - m != m and set(l1) == s1 and (set(l1) == s2):
					print(2)
					print(n - m, '', m)
					print(m, '', n - m)
				elif n - m == m and set(l1) == s1 and (set(l1) == s2):
					print(1)
					print(n - m, '', m)
				else:
					print(0)
			elif len(x) == m and len(y) != m:
				l = list(a[m:])
				l1 = []
				count = 1
				for i in range(m, n):
					l1.append(count)
					count += 1
				if set(l) != set(l1):
					print(0)
				else:
					print(1)
					print(m, '', n - m)
			elif len(x) != m and len(y) == m:
				l = list(a[0:n - m])
				l1 = []
				count = 1
				for i in range(0, n - m):
					l1.append(count)
					count += 1
				if set(l) != set(l1):
					print(0)
				else:
					print(1)
					print(n - m, '', m)
		else:
			print(0)


from collections import defaultdict

def solve():
	N = int(input())
	arr = list(map(int, input().split()))
	splits = []
	l_dict = defaultdict(lambda : 0)
	l_dict_sum = 0
	r_dict = defaultdict(lambda : 0)
	for item in arr:
		r_dict[item] += 1
	r_dict_sum = sum(r_dict.keys())
	for i in range(N):
		left_len = i + 1
		right_len = N - (i + 1)
		l_e_s = left_len * (left_len + 1) // 2
		r_e_s = right_len * (right_len + 1) // 2
		r_dict[arr[i]] -= 1
		if r_dict[arr[i]] == 0:
			del r_dict[arr[i]]
			r_dict_sum -= arr[i]
		l_dict[arr[i]] += 1
		if l_dict[arr[i]] == 1:
			l_dict_sum += arr[i]
		if l_dict_sum == l_e_s and len(l_dict) == left_len and (r_dict_sum == r_e_s) and (len(r_dict) == right_len):
			splits.append((left_len, right_len))
	print(len(splits))
	for (l, r) in splits:
		print('{} {}'.format(l, r))
T = int(input())
for t in range(T):
	solve()


def somme_raison_1(n):
	return n * (n + 1) // 2
for _ in range(0, int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	x = 0
	my_set = set()
	h = [0] * n
	s = 0
	max_set = 0
	for i in range(0, len(l) - 1):
		s += l[i]
		my_set.add(l[i])
		max_set = max(max_set, l[i])
		if s == somme_raison_1(i + 1) and len(my_set) == i + 1 and (max_set == i + 1):
			h[i] += 1
	r = [0]
	my_set = set()
	max_set = 0
	s = 0
	for i in range(n - 1, 0, -1):
		s += l[i]
		my_set.add(l[i])
		max_set = max(max_set, l[i])
		if h[i - 1] == 1:
			if s == somme_raison_1(n - i) and len(my_set) == n - i and (max_set == n - i):
				r[0] += 1
				r.append(str(i) + ' ' + str(n - i))
	for i in r:
		print(i)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	seen = [False] * (n + 1)
	ans = set()
	for (i, x) in enumerate(a):
		if seen[x]:
			if sorted(a[:i]) == list(range(1, i + 1)) and sorted(a[i:]) == list(range(1, n - i + 1)):
				ans.add((i, n - i))
			break
		seen[x] = True
	seen = [False] * (n + 1)
	for (i, x) in list(enumerate(a))[::-1]:
		if seen[x]:
			if sorted(a[:i + 1]) == list(range(1, i + 2)) and sorted(a[i + 1:]) == list(range(1, n - i)):
				ans.add((i + 1, n - i - 1))
			break
		seen[x] = True
	print(len(ans))
	for (l1, l2) in ans:
		print(l1, l2)


get_int = lambda : int(input())
get_list = lambda : list(map(int, input().split()))

def main():
	for _ in range(get_int()):
		n = get_int()
		a = get_list()
		mx = max(a)
		a1 = [i for i in range(1, mx + 1)]
		a2 = [i for i in range(1, len(a) - mx + 1)]
		flag1 = 1
		flag2 = 1
		ans = 0
		if sorted(a[:mx]) == a1 and sorted(a[mx:]) == a2:
			ans += 1
			flag1 = 0
		if sorted(a[:len(a) - mx]) == a2 and sorted(a[len(a) - mx:]) == a1:
			ans += 1
			flag2 = 0
		if ans == 2:
			if mx == n - mx:
				print(1)
				print(mx, n - mx, sep=' ')
			else:
				print(2)
				print(mx, n - mx, sep=' ')
				print(n - mx, mx, sep=' ')
		elif ans == 1:
			if flag1 == 0:
				print(1)
				print(mx, n - mx, sep=' ')
			else:
				print(1)
				print(n - mx, mx, sep=' ')
		else:
			print(0)
main()


I = input
for _ in [0] * int(I()):
	n = int(I())
	a = (*map(int, I().split()),)
	m = max(a)
	r = [(k, n - k) for k in {m, n - m} if sorted(a[:k]) + sorted(a[k:]) == [*range(1, k + 1), *range(1, n - k + 1)]]
	print(len(r))
	for x in r:
		print(*x)


T = int(input())
for _ in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	v = max(A)
	if v < (n + 1) // 2 or v == n:
		a = 0
		print(a)
	elif n % 2 == 0 and v == n // 2:
		B = [0 for i in range(v + 1)]
		a = 1
		for i in range(v):
			B[A[i]] = B[A[i]] + 1
			if B[A[i]] > 1:
				a = 0
				break
		if a != 0:
			for i in range(v, n):
				B[A[i]] = B[A[i]] + 1
				if B[A[i]] != 2:
					a = 0
					break
		print(a)
		for i in range(a):
			print(v, v)
	else:
		B = [0 for i in range(v + 1)]
		a = 1
		V = []
		for i in range(v):
			B[A[i]] = B[A[i]] + 1
			if B[A[i]] > 1:
				a = 0
				break
		if a != 0:
			for i in range(v, n):
				B[A[i]] = B[A[i]] + 1
				if A[i] > n - v or B[A[i]] != 2:
					a = 0
					break
		if a == 1:
			V.append([v, n - v])
		A = A[::-1]
		B = [0 for i in range(v + 1)]
		a = 1
		for i in range(v):
			B[A[i]] = B[A[i]] + 1
			if B[A[i]] > 1:
				a = 0
				break
		if a != 0:
			for i in range(v, n):
				B[A[i]] = B[A[i]] + 1
				if A[i] > n - v or B[A[i]] != 2:
					a = 0
					break
		if a == 1:
			V.append([n - v, v])
		print(len(V))
		for i in V:
			print(*i)


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	ans = 0
	l1 = max(a)
	l2 = n - l1
	if l1 == n:
		print(0)
	else:
		p11 = sorted(a[:l1])
		p21 = sorted(a[l1:])
		p12 = sorted(a[:l2])
		p22 = sorted(a[l2:])
		p1 = [i + 1 for i in range(l1)]
		p2 = [j + 1 for j in range(l2)]
		k = 0
		if p11 == p1 and p21 == p2:
			ans += 1
			k = l1
		if p12 == p2 and p22 == p1:
			ans += 1
			k = l2
		if l1 == l2 and ans > 0:
			ans = 1
		print(ans)
		if ans == 1:
			print(k, n - k)
		if ans == 2:
			print(l1, l2)
			print(l2, l1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	m = max(a)
	last = n - m
	li = []
	if m >= n:
		print(0)
	else:
		left = set(a[:m])
		right = set(a[m:])
		if len(left) == m and max(left) == m and (len(right) == last) and (max(right) == last):
			li.append([m, last])
		left = set(a[:last])
		right = set(a[last:])
		if m != last and len(left) == last and (max(left) == last) and (len(right) == m) and (max(right) == m):
			li.append([last, m])
		if len(li) == 2:
			print(2)
			print(*li[0])
			print(*li[1])
		elif len(li) == 1:
			print(1)
			print(*li[0])
		else:
			print(0)


t = int(input())
for _ in range(t):
	n = int(input())
	r = 0
	a = list(map(int, input().split()))
	if n <= 2 * max(a):
		maxx = max(a)
		b = [0] * maxx
		for i in range(n):
			b[a[i] - 1] += 1
		flag = 1
		for i in range(0, maxx - 1):
			if b[i] == 1 and b[i + 1] == 1:
				pass
			elif b[i] == 2 and b[i + 1] == 2:
				pass
			elif b[i] == 2 and b[i + 1] == 1:
				r = i + 1
				flag = 2
			else:
				flag = 0
				break
		if flag == 1:
			if b.count(1) == n:
				flag = 0
			elif b.count(2) == n // 2:
				r = n // 2
	else:
		flag = 0
	if flag == 0:
		print(0)
	else:
		rr = []
		aa = [i + 1 for i in range(r)]
		if sorted(a[0:r]) == aa:
			rr.append([r, n - r])
		if flag != 1:
			if sorted(a[n - r:n]) == aa:
				rr.append([n - r, r])
		print(len(rr))
		if len(rr) > 0:
			for x in rr:
				print(*x)


import heapq
for _ in range(int(input())):
	n = int(input())
	array = list(map(int, input().split()))
	LeftHalf = [False] * n
	rightHalf = [False] * n
	Highestelement = 0
	Sum = 0
	d = {}
	ans = 0
	for i in range(n):
		if array[i] > Highestelement:
			Highestelement = array[i]
		Sum += array[i]
		if array[i] in d:
			break
		else:
			d[array[i]] = 0
		if Sum == (i + 1) * (i + 2) // 2 and Highestelement == i + 1:
			LeftHalf[i] = True
	Highestelement = 0
	Sum = 0
	d = {}
	for i in range(n - 1, -1, -1):
		if array[i] > Highestelement:
			Highestelement = array[i]
		Sum += array[i]
		if array[i] in d:
			break
		else:
			d[array[i]] = 0
		if Sum == (n - i) * (n - i + 1) // 2 and Highestelement == n - i:
			rightHalf[i] = True
	ansArray = []
	for i in range(n - 1):
		if LeftHalf[i] and rightHalf[i + 1]:
			ans += 1
			ansArray.append([i + 1, n - (i + 1)])
	print(ans)
	for i in ansArray:
		print(*i)


def solve():
	n = int(input())
	arr = [int(v) for v in input().split()]
	st = set()
	ans = set()
	for i in range(n):
		if arr[i] in st:
			lfst = set(arr[:i])
			rfst = set(arr[i:])
			if set(range(1, i + 1)) == lfst and set(range(1, n - i + 1)) == rfst:
				ans.add((i, n - i))
			break
		st.add(arr[i])
	st = set()
	for i in reversed(range(n)):
		if arr[i] in st:
			lfst = set(arr[:i + 1])
			rfst = set(arr[i:])
			if lfst == set(range(1, i + 2)) and rfst == set(range(1, n - i)):
				ans.add((i + 1, n - i - 1))
			break
		st.add(arr[i])
	print(len(ans))
	if len(ans):
		print('\n'.join(['%s %s' % (u, v) for (u, v) in ans]))

def solve1():
	n = int(input())
	arr = [int(v) for v in input().split()]
	st = set()
	ans = set()
	for i in range(n):
		if arr[i] in st:
			good = True
			lfst = set(arr[:i])
			rfst = set(arr[i:])
			for j in range(1, i + 1):
				if j not in lfst:
					good = False
					break
			for j in range(1, n - i + 1):
				if j not in rfst:
					good = False
					break
			if good:
				ans.add((i, n - i))
			break
		st.add(arr[i])
	st = set()
	for i in reversed(range(n)):
		if arr[i] in st:
			good = True
			lfst = set(arr[:i + 1])
			rfst = set(arr[i:])
			for j in range(1, i + 2):
				if j not in lfst:
					good = False
					break
			for j in range(1, n - i):
				if j not in rfst:
					good = False
					break
			if good:
				ans.add((i + 1, n - i - 1))
			break
		st.add(arr[i])
	print(len(ans))
	if len(ans):
		print('\n'.join(['%s %s' % (u, v) for (u, v) in ans]))
t = int(input())
for _ in range(t):
	solve1()


t = int(input())
res = ''
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	max_l = max(a)
	second_l = n - max_l
	k = 0
	sub_res = ''
	if max_l * second_l != 0:
		left = set(a[:max_l])
		right = set(a[max_l:])
		if len(left) == max_l and max(left) == max_l and (max(right) == second_l) and (len(right) == second_l):
			k = 1
			sub_res = str(max_l) + ' ' + str(second_l) + '\n'
		left = set(a[:second_l])
		right = set(a[second_l:])
		if max_l != second_l and len(right) == max_l and (len(left) == second_l) and (max(left) == second_l) and (max(right) == max_l):
			k += 1
			sub_res += str(second_l) + ' ' + str(max_l) + '\n'
	res += str(k) + '\n' + sub_res
print(res)


t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	f = 0
	ans = []
	m = max(A)
	if m >= n:
		print(0)
	else:
		p1a = A[:m]
		p2a = A[m:]
		p1b = A[:n - m]
		p2b = A[n - m:]
		if len(set(p1a)) == m == max(p1a) and len(set(p2a)) == n - m == max(p2a):
			ans.append(m)
		if len(set(p1b)) == n - m == max(p1b) and len(set(p2b)) == m == max(p2b) and (m != n - m):
			ans.append(n - m)
		print(len(ans))
		for a in ans:
			print(a, n - a)


def func(arr):
	nombers = set()
	for i in range(len(arr)):
		if arr[i] in nombers:
			return i
		else:
			nombers.add(arr[i])
	return -1

def test(arr):
	new_arr = sorted(arr)
	for i in range(1, len(arr) + 1):
		if new_arr[i - 1] != i:
			return False
	return True
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	ans = 0
	ans_output = []
	s = func(arr)
	if s != -1:
		if test(arr[:s]) and test(arr[s:]):
			ans += 1
			ans_output.append((s, n - s))
	arr.reverse()
	s = func(arr)
	if s != -1:
		if test(arr[:s]) and test(arr[s:]):
			dop = (n - s, s)
			if ans == 0 or ans_output[0] != dop:
				ans_output.append(dop)
				ans += 1
	print(ans)
	for i in ans_output:
		print(*i)


check = lambda s, n: all((i + 1 in s for i in range(max(n, 1))))
for _ in range(int(input())):
	a = [list(map(int, input().split())) for i in '..'][1]
	(mx, n, res) = (max(a), len(a), set())
	if check(set(a[:mx]), mx) and check(set(a[mx:]), n - mx):
		res.add((mx, n - mx))
	if check(set(a[:n - mx]), n - mx) and check(set(a[n - mx:]), mx):
		res.add((n - mx, mx))
	print(len(res))
	for r in res:
		print(*r)


t = int(input())
for i in range(t):
	good = []
	n = int(input())
	a = list(map(int, input().split()))
	m = max(a)
	s = set(a[0:m])
	sc = set(a[m:n])
	if len(s) == m and max(sc) == n - m and (len(sc) == n - m):
		good.append(str(m) + ' ' + str(n - m))
	p = set(a[-m:n])
	pc = set(a[0:-m])
	if len(p) == m and max(pc) == n - m and (len(pc) == n - m):
		good.append(str(n - m) + ' ' + str(m))
	if len(good) == 1:
		print(1)
		print(good[0])
	elif len(good) == 2 and m * 2 != n:
		print(2)
		print(good[0])
		print(good[1])
	elif len(good) == 2 and m * 2 == n:
		print(1)
		print(good[0])
	else:
		print(0)


import heapq
t = input()
t = int(t)

def cek(lst):
	nn = len(lst)
	dct = {}
	for i in lst:
		try:
			dct[i] += 1
			return False
		except:
			dct[i] = 1
	for i in range(1, nn + 1):
		try:
			b = dct[i]
		except:
			return False
	return True
for case in range(t):
	a = input().split()
	n = int(a[0])
	a = input().split()
	lst = [int(i) for i in a]
	ans = []
	maxi = max(lst)
	l = lst[:maxi]
	r = lst[maxi:]
	if cek(l) and cek(r):
		ans.append([maxi, n - maxi])
	if n - maxi != maxi:
		maxi = n - maxi
		l = lst[:maxi]
		r = lst[maxi:]
		if cek(l) and cek(r):
			ans.append([maxi, n - maxi])
	print(len(ans))
	for i in ans:
		print(i[0], i[1])


def check(a, b, n, m):
	for i in range(1, n + 1):
		if i not in a:
			return False
	for i in range(1, m + 1):
		if i not in b:
			return False
	return True
from math import *
T = int(input())
for _ in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	Arr = [0] * max(arr)
	for i in arr:
		Arr[i - 1] += 1
	flag = 0
	for i in range(1, len(Arr)):
		if Arr[i] > Arr[i - 1]:
			flag = 1
			break
		if Arr[i] == 0 or Arr[i - 1] == 0:
			flag = 1
			break
	Max = max(Arr)
	Min = min(Arr)
	if flag == 0 and Max == 2:
		a = max(arr)
		b = n - a
		Dict1 = {arr[i]: 1 for i in range(a)}
		Dict2 = {arr[i]: 1 for i in range(a, n)}
		Dict3 = {arr[i]: 1 for i in range(b)}
		Dict4 = {arr[i]: 1 for i in range(b, n)}
		A = check(Dict1, Dict2, a, b)
		B = check(Dict3, Dict4, b, a)
		if A == True and B == True and (a != b):
			print(2)
			print(a, b)
			print(b, a)
		elif A == True:
			print(1)
			print(a, b)
		elif B == True:
			print(1)
			print(b, a)
		else:
			print(0)
	else:
		print(0)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = set()
	m = 0
	ans = set()
	for i in range(n):
		if a[i] > m and a[i] in s:
			m = a[i]
		s.add(a[i])
	if sorted(a[:m]) == list(range(1, m + 1)) and sorted(a[m:]) == list(range(1, n - m + 1)):
		ans.add(m)
	if sorted(a[:n - m]) == list(range(1, n - m + 1)) and sorted(a[n - m:]) == list(range(1, m + 1)):
		ans.add(n - m)
	print(len(ans))
	for i in ans:
		print(i, n - i)


t = int(input())
for i in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	s = max(b)
	p = n - s
	q = b.copy()
	q.reverse()
	a = [-1] * n
	c = [-1] * n
	for j in range(n):
		if a[b[j]] == -1:
			a[b[j]] = j
	for j in range(n):
		if c[q[j]] == -1:
			c[q[j]] = j
	l = -1
	f = 0
	for j in range(1, s + 1):
		if a[j] == -1:
			f = 1
			break
		l = max(l, a[j])
	if f == 0:
		if l == s - 1:
			f = 0
		else:
			f = 1
	if f == 0:
		l = -1
		for j in range(1, p + 1):
			if c[j] == -1:
				f = 1
				break
			l = max(l, c[j])
		if f == 0:
			if l == p - 1:
				f = 0
			else:
				f = 1
	l = -1
	g = 0
	for j in range(1, s + 1):
		if c[j] == -1:
			g = 1
			break
		l = max(l, c[j])
	if g == 0:
		if l == s - 1:
			g = 0
		else:
			g = 1
	if g == 0:
		l = -1
		for j in range(1, p + 1):
			if a[j] == -1:
				g = 1
				break
			l = max(l, a[j])
		if g == 0:
			if l == p - 1:
				g = 0
			else:
				g = 1
	if f == 1 and g == 1:
		print(0)
	elif f == 1 and g == 0:
		print(1)
		print(n - s, s)
	elif f == 0 and g == 1:
		print(1)
		print(s, n - s)
	elif f == 0 and g == 0:
		if s != n - s:
			print(2)
			print(s, n - s)
			print(n - s, s)
		else:
			print(1)
			print(s, n - s)


t = int(input())
while t != 0:
	n = int(input())
	list1 = list(map(int, input().split()))
	p = max(list1)
	p1 = set(list1[:p])
	ans = list()
	if p1 == set(range(1, p + 1)):
		q1 = set(list1[p:])
		if q1 == set(range(1, n - p + 1)):
			ans.append(p)
	p2 = set(list1[:n - p])
	if p2 == set(range(1, n - p + 1)):
		q2 = set(list1[n - p:])
		if q2 == set(range(1, p + 1)):
			ans.append(n - p)
	ans = set(ans)
	print(len(ans))
	for i in ans:
		print(i, n - i)
	t -= 1


def naive():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		val = 0
		case = []
		for l1 in range(1, n):
			string_1 = sorted(a[0:l1])
			string_2 = sorted(a[l1:])
			if [x for x in range(1, l1 + 1)] == string_1:
				if string_2 == [x for x in range(1, n - l1 + 1)]:
					val += 1
					case.append((l1, n - l1))
		print(val)
		for c in case:
			print(c[0], c[1])

def fast():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		m = max(a)
		if n == m:
			print(0)
		else:
			l1 = [m, n - m]
			case = set()
			for i in l1:
				if sorted(a[:i]) == [x for x in range(1, i + 1)]:
					if sorted(a[i:]) == [x for x in range(1, n - i + 1)]:
						case.add((i, n - i))
			print(len(case))
			for c in case:
				print(c[0], c[1])
fast()


t = int(input())
for i in range(t):
	n = int(input())
	sp = list(map(int, input().split()))
	ma = max(sp)
	count = 0
	ans = []
	if len(set(sp[:ma])) == ma and len(set(sp[ma:])) == n - ma and (max(sp[:ma]) == ma) and (max(sp[ma:]) == n - ma):
		count += 1
		ans.append((ma, n - ma))
	if len(set(sp[:n - ma])) == n - ma and len(set(sp[n - ma:])) == ma and (max(sp[:n - ma]) == n - ma) and (max(sp[n - ma:]) == ma):
		count += 1
		ans.append((n - ma, ma))
	ans = set(ans)
	print(len(ans))
	for i in ans:
		print(i[0], i[1])


cases = int(input())
for case in range(cases):
	n = int(input())
	l = list(map(int, input().split()))
	v = set()
	pos = set()
	maxi = 0
	for i in range(n):
		maxi = max(maxi, l[i])
		v.add(l[i])
		if len(v) == i + 1 and maxi == i + 1:
			pos.add(i + 1)
	posf = []
	v = set()
	maxi = 0
	l = l[::-1]
	for i in range(n):
		maxi = max(maxi, l[i])
		v.add(l[i])
		if n - i - 1 in pos and len(v) == i + 1 and (maxi == i + 1):
			posf.append(n - i - 1)
	print(len(posf))
	for p in posf:
		print(p, n - p)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	k = [0] * n
	f = False
	p = 1
	r = 0
	for i in range(n):
		k[a[i] - 1] += 1
	if k[0] != 2:
		f = True
	else:
		for i in range(1, n):
			if k[i] > k[i - 1]:
				f = True
			if k[i] == 2:
				p += 1
			if k[i] == 1:
				r += 1
	c = 0
	b = []
	maxi = -1
	used = [0] * n
	for i in range(n - 1):
		if used[a[i] - 1] != 0:
			break
		used[a[i] - 1] = 1
		if k[i] == 2:
			p -= 1
		if k[i] == 1:
			r -= 1
		if a[i] > maxi:
			maxi = a[i]
		if maxi == i + 1:
			if n - i - 1 > i:
				if k[i] == 2 and p == 0:
					c += 1
					b.append(i + 1)
			elif k[n - i - 2] == 2 and p == 0:
				c += 1
				b.append(i + 1)
	if f:
		print(0)
	else:
		print(c)
		for i in b:
			print(i, n - i)


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	v = [0] * n
	i = 1
	s = 0
	r = 1
	r1 = 1
	for x in a:
		v[x] += 1
	if v[1] <= 1:
		print(0)
	elif n == 2:
		if a[0] == 1 and a[1] == 1:
			print(1)
			print('1 1')
		else:
			print(0)
	else:
		while v[i] >= 2:
			s += 1
			i += 1
		b = sorted(a[0:s])
		e = sorted(a[s:])
		b1 = sorted(a[n - s:])
		e1 = sorted(a[0:n - s])
		for i in range(len(b)):
			if b[i] != i + 1:
				r = 0
				break
		for i in range(len(e)):
			if e[i] != i + 1:
				r = 0
				break
		for i in range(len(b1)):
			if b1[i] != i + 1:
				r1 = 0
				break
		for i in range(len(e1)):
			if e1[i] != i + 1:
				r1 = 0
				break
		if r == 0 and r1 == 0:
			print(0)
		elif r == 1 and r1 == 1:
			if len(b) != len(e):
				print(2)
				print(len(b), len(e))
				print(len(e1), len(b1))
			else:
				print(1)
				print(len(b), len(e))
		elif r == 1:
			print(1)
			print(len(b), len(e))
		else:
			print(1)
			print(len(e1), len(b1))


t = int(input())
for _ in range(t):
	n = int(input())
	x = list(map(int, input().split()))
	(check, yes1, yes2) = ([0] * (n + 1), [0] * (n + 1), [0] * (n + 1))
	(ans, ma) = (0, 0)
	ans2 = []
	for i in range(n):
		if check[x[i]] == 1:
			break
		else:
			ma = max(ma, x[i])
			if i == ma - 1:
				yes1[i] = 1
			check[x[i]] = 1
	(check, ma) = ([0] * (n + 1), 0)
	for i in range(n - 1, -1, -1):
		if check[x[i]] == 1:
			break
		else:
			ma = max(ma, x[i])
			if n - i == ma:
				yes2[i] = 1
			check[x[i]] = 1
	for i in range(n - 1):
		if yes1[i] == 1 and yes2[i + 1] == 1:
			ans += 1
			ans2.append(i + 1)
	print(ans)
	for i in range(ans):
		print(ans2[i], n - ans2[i])


def per(X):
	S = set(X)
	if not len(X) == len(S):
		return False
	for i in range(1, len(X) + 1):
		if i not in S:
			return False
	return True
for y in range(int(input())):
	n = int(input())
	L = list(map(int, input().split()))
	m = max(L)
	r = []
	if n != m:
		if per(L[:m]) and per(L[m:]):
			r.append((m, n - m))
		if per(L[-m:]) and per(L[:-m]):
			r.append((n - m, m))
	r = list(set(r))
	print(len(r))
	for (a, b) in r:
		print(a, b)


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
import random
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

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 solve(n):
	return n * (n + 1) // 2
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l1 = []
	l2 = []
	max1 = 0
	min1 = inf
	hash = []
	set1 = set()
	for i in range(n):
		hash.append(True)
		if l[i] > max1:
			max1 = l[i]
		set1.add(l[i])
		if len(set1) != i + 1:
			hash[i] = False
		if l[i] < min1:
			min1 = l[i]
		l1.append([min1, max1])
	max1 = 0
	min1 = inf
	set1 = set()
	for i in range(n - 1, -1, -1):
		if l[i] > max1:
			max1 = l[i]
		if l[i] < min1:
			min1 = l[i]
		set1.add(l[i])
		if len(set1) != n - i:
			hash[i - 1] = False
		l2.append([min1, max1])
	l2.pop()
	l1.pop()
	ans = []
	for i in range(len(l1)):
		(a, b) = l1[i]
		(c, d) = l2[len(l1) - i - 1]
		len1 = i + 1
		len2 = n - i - 1
		if b - a + 1 == len1 and d - c + 1 == len2 and (a == 1) and (c == 1) and (hash[i] == True):
			ans.append(str(len1) + ' ' + str(len2))
	print(len(ans))
	print('\n'.join(ans))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = set()
	m = 0
	k = 0
	ans = []
	for i in range(n):
		if not a[i] in d:
			d.add(a[i])
			m = max(m, a[i])
		else:
			break
	if m != len(d) or len(d) == n:
		k = 0
	else:
		d = set()
		p = m
		m = 0
		for i in range(p, n):
			if not a[i] in d:
				d.add(a[i])
				m = max(m, a[i])
			else:
				break
		if m != len(d) or len(d) == n or p + m != n:
			k = 0
		else:
			k = 1
			ans.append([p, n - p])
	d = set()
	m = 0
	for i in range(n - 1, -1, -1):
		if not a[i] in d:
			d.add(a[i])
			m = max(m, a[i])
		else:
			break
	if m != len(d) or len(d) == n:
		m = 0
	else:
		s = [n - m, m]
		d = set()
		m = 0
		if len(ans) == 0 or s != ans[-1]:
			for i in range(s[0] - 1, -1, -1):
				if not a[i] in d:
					d.add(a[i])
					m = max(m, a[i])
				else:
					break
			if m != len(d) or len(d) == n or s[1] + m != n:
				m = 0
			elif k == 1:
				k = 2
				ans.append(s)
			else:
				k = 1
				ans.append(s)
	if k == 0:
		print(k)
	elif k == 1:
		print(k)
		print(*ans[-1])
	else:
		print(k)
		print(*ans[0])
		print(*ans[1])


def sol(p):
	arr = sorted(p)
	for i in range(len(arr)):
		if arr[i] != i + 1:
			return False
	return True
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	mx = max(a)
	res = []
	(p1, p2) = (a[0:n - mx], a[n - mx:n])
	if sol(p1) and sol(p2):
		res.append(n - mx)
	(p1, p2) = (a[0:mx], a[mx:n])
	if sol(p1) and sol(p2):
		res.append(mx)
	res = set(res)
	print(len(res))
	for a in res:
		print(a, n - a)


import math

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		arr = [int(i) for i in input().split()]
		counters = {}
		repeated = set()
		for el in arr:
			if el not in counters:
				counters[el] = 1
			else:
				counters[el] += 1
				repeated.add(el)
		reverse_max = list(arr)
		for i in range(n - 2, -1, -1):
			reverse_max[i] = max(reverse_max[i], reverse_max[i + 1])
		current = set()
		big = -math.inf
		answer = []
		for index in range(n - 1):
			el = arr[index]
			if el in current:
				break
			current.add(el)
			counters[el] -= 1
			if counters[el] == 1 and el in repeated:
				repeated.remove(el)
			big = max(big, el)
			if big != len(current):
				continue
			if len(repeated) != 0 or reverse_max[index + 1] != n - index - 1:
				continue
			answer.append((index + 1, n - index - 1))
		print(len(answer))
		for part in answer:
			print(*part)
main()


import sys
input = sys.stdin.readline
inputr = lambda : range(int(input()))
inputi = lambda : map(int, input().split())
inputl = lambda : list(inputi())
from math import *
from heapq import *
from bisect import *
from functools import reduce, lru_cache
from collections import Counter, defaultdict
for _ in inputr():
	(n,) = inputi()
	A = inputl()
	t = []
	m1 = max(A)
	m2 = n - m1
	for (i, z) in enumerate(sorted(A[:m1]), 1):
		if i != z:
			break
	else:
		for (i, z) in enumerate(sorted(A[m1:n]), 1):
			if i != z:
				break
		else:
			t.append((m1, m2))
	for (i, z) in enumerate(sorted(A[:m2]), 1):
		if i != z:
			break
	else:
		for (i, z) in enumerate(sorted(A[m2:n]), 1):
			if i != z:
				break
		else:
			t.append((m2, m1))
	if len(t) == 2 and t[0] == t[1]:
		print(1)
		print(*t[0])
	else:
		print(len(t))
		for l in t:
			print(*l)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	k = int(input())
	a = list(map(int, input().split()))
	a_c = [0] * (max(a) + 1)
	for i in range(k):
		a_c[a[i]] += 1
	if a_c[1] != 2:
		print(0)
		continue
	flag = True
	u = int(100000000.0)
	for i in range(2, len(a_c)):
		if a_c[i] == 2 and a_c[i - 1] >= a_c[i]:
			pass
		elif a_c[i] == 1 and a_c[i - 1] >= a_c[i]:
			u = min(u, i)
		else:
			flag = False
	if not flag:
		print(0)
		continue
	elif a_c[-1] == 2:
		if len(a_c) - 1 == len(set(a[0:len(a_c) - 1])):
			print(1)
			print(len(a_c) - 1, len(a_c) - 1)
		else:
			print(0)
	else:
		ans_l = []
		if u - 1 == max(a[0:u - 1]) and len(set(a[0:u - 1])) == u - 1:
			ans_l.append([u - 1, k - u + 1])
		if u - 1 == max(a[k - u + 1:]) and len(set(a[k - u + 1:])) == u - 1:
			ans_l.append([k - u + 1, u - 1])
		print(len(ans_l))
		for i in range(len(ans_l)):
			print(*ans_l[i])


testCases = int(input())
for _ in range(testCases):
	n = int(input())
	a = list(map(int, input().split()))
	mx = max(a)
	mx_ = n - mx
	range1 = set(range(1, mx + 1))
	range2 = set(range(1, mx_ + 1))
	d = set()
	if set(a[:mx]) == range1 and set(a[mx:]) == range2:
		d.add(mx)
	if set(a[:mx_]) == range2 and set(a[mx_:]) == range1:
		d.add(mx_)
	print(len(d))
	for x in d:
		print(x, n - x)


import os
import sys
from io import BytesIO, IOBase

def solution(arr, n):
	arr.insert(0, 0)
	(seen, res) = (set(), set())
	seen_end = set()
	(pre, use_s, use_e) = ([0] * (n + 1), [0] * (n + 1), [0] * (n + 1))
	sums = [0] * (n + 1)
	use_s[0] = -1
	use_e[0] = -1
	for i in range(1, n + 1):
		pre[i] = pre[i - 1] + arr[i]
		seen.add(arr[i])
		use_s[i] = len(seen)
		sums[i] = i * (i + 1) // 2
	for i in range(1, n + 1):
		seen_end.add(arr[n - i + 1])
		use_e[i] = len(seen_end)
	for i in range(1, n):
		if pre[i] == sums[i] and pre[n] - pre[i] == sums[n - i]:
			if use_s[i] == i and use_e[n - i] == n - i:
				res.add((i, n - i))
	if res:
		write(len(res))
		for (a, b) in res:
			write(a, b)
	else:
		write(0)

def main():
	for _ in range(r_int()):
		n = r_int()
		arr = r_array()
		solution(arr, n)
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))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	mx = max(a)
	(l1, l2) = (a[0:mx], a[mx:])
	s1 = set(l1)
	s2 = set(l2)
	if len(s1) == len(l1) and len(s1) == max(s1) and (len(s2) == len(l2)) and (len(s2) == max(s2)):
		ans.append([mx, n - mx])
	(l1, l2) = (a[0:n - mx], a[n - mx:])
	s1 = set(l1)
	s2 = set(l2)
	if len(s1) == len(l1) and len(s1) == max(s1) and (len(s2) == len(l2)) and (len(s2) == max(s2)):
		if [n - mx, mx] != [mx, n - mx]:
			ans.append([n - mx, mx])
	print(len(ans))
	for i in ans:
		print(i[0], i[1])


def check(lst):
	lst.sort()
	return len(lst) > 0 and all((i + 1 == lst[i] for i in range(len(lst))))
for j in range(int(input())):
	n = int(input())
	lsta = list(map(int, input().split()))
	if lsta.count(1) == 2:
		result = set()
		mx = max(lsta)
		if check(lsta[:mx]) and check(lsta[mx:]):
			result.add((mx, n - mx))
		if check(lsta[:n - mx]) and check(lsta[n - mx:]):
			result.add((n - mx, mx))
		print(len(result))
		for i in result:
			print(*i)
	else:
		print(0)


from collections import defaultdict
import sys, math
f = None
try:
	f = open('q1.input', 'r')
except IOError:
	f = sys.stdin
if 'xrange' in dir(__builtins__):
	range = xrange
sys.setrecursionlimit(10 ** 2)

def print_case_iterable(case_num, iterable):
	print('Case #{}: {}'.format(case_num, ' '.join(map(str, iterable))))

def print_case_number(case_num, iterable):
	print('Case #{}: {}'.format(case_num, iterable))

def print_iterable(A):
	print(' '.join(A))

def read_int():
	return int(f.readline().strip())

def read_int_array():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def read_string():
	return list(f.readline().strip())

def ri():
	return int(f.readline().strip())

def ria():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def rs():
	return list(f.readline().strip())

def bi(x):
	return bin(x)[2:]
from collections import deque
import math
NUMBER = 10 ** 9 + 7

def factorial(n):
	M = NUMBER
	f = 1
	for i in range(1, n + 1):
		f = f * i % M
	return f

def mult(a, b):
	return a * b % NUMBER

def minus(a, b):
	return (a - b) % NUMBER

def plus(a, b):
	return (a + b) % NUMBER

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, y, x) = egcd(b % a, a)
		return (g, x - b // a * y, y)

def modinv(a):
	m = NUMBER
	(g, x, y) = egcd(a, m)
	if g != 1:
		raise Exception('modular inverse does not exist')
	else:
		return x % m

def choose(n, k):
	if n < k:
		assert false
	return mult(factorial(n), modinv(mult(factorial(k), factorial(n - k))))
from collections import deque, defaultdict
import heapq

def solution(a, n):
	d = defaultdict(int)
	for x in a:
		d[x] += 1
		if d[x] == 3:
			return 0
	first_perm = list(set(a))
	second_perm = [x for x in d if d[x] == 2]
	n1 = len(first_perm)
	n2 = len(second_perm)
	if n1 * n2 == 0:
		return 0
	if sorted(first_perm) != sorted(range(1, n1 + 1)):
		return 0
	if sorted(second_perm) != sorted(range(1, n2 + 1)):
		return 0
	sol = []
	if set(a[:n1]) == set(first_perm):
		sol.append([n1, n2])
	if set(a[:n2]) == set(second_perm):
		sol.append([n2, n1])
	if not sol:
		return 0
	if n1 == n2:
		sol = [[n1, n2]]
	print(len(sol))
	return '\n'.join([' '.join(map(str, x)) for x in sol])

def main():
	T = ri()
	for i in range(T):
		n = ri()
		a = ria()
		x = solution(a, n)
		if 'xrange' not in dir(__builtins__):
			print(x)
		else:
			(print >> output, str(x))
	if 'xrange' in dir(__builtins__):
		print(output.getvalue())
		output.close()
if 'xrange' in dir(__builtins__):
	import cStringIO
	output = cStringIO.StringIO()
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	st = []
	vis1 = [0] * n
	vis2 = [0] * n
	while a:
		if vis1[a[-1]] == 0:
			st.append(a.pop())
			vis1[st[-1]] = 1
		else:
			break
	fl = 0
	for i in a:
		if vis2[i] == 0:
			vis2[i] += 1
		else:
			fl = 1
			break
	ans = []
	if sum(vis2) == max(a) and sum(vis1) == max(st) and (fl == 0):
		ans.append([len(a), len(st)])
	a += st[::-1]
	a = a[::-1]
	st = []
	vis1 = [0] * n
	vis2 = [0] * n
	while a:
		if vis1[a[-1]] == 0:
			st.append(a.pop())
			vis1[st[-1]] = 1
		else:
			break
	fl = 0
	for i in a:
		if vis2[i] == 0:
			vis2[i] += 1
		else:
			fl = 1
			break
	if sum(vis2) == max(a) and sum(vis1) == max(st) and (fl == 0) and (not ans or ans[-1] != [len(st), len(a)]):
		ans.append([len(st), len(a)])
	print(len(ans))
	for i in ans:
		print(*i)


t = int(input())
for _ in range(t):
	n = [int(x) for x in input().split()][0]
	ar = [int(x) for x in input().split()]
	d = {}
	invalid = False
	for element in ar:
		d[element] = d.get(element, 0) + 1
		if d[element] > 3:
			invalid = True
	max1 = 0
	max2 = 0
	for key in d:
		if d[key] > 1 and key > max2:
			max2 = key
		if key > max1:
			max1 = key
		if d[key] < 1 or 2 < d[key]:
			invalid = True
	if max2 < 1:
		invalid = True
	for i in range(1, max2 + 1):
		if d.get(i, 0) != 2:
			invalid = True
			break
	for i in range(max2 + 1, max1 + 1):
		if d.get(i, 0) != 1:
			invalid = True
			break
	if invalid:
		print(0)
	else:
		d = {}
		for element in ar[:max2]:
			d[element] = d.get(element, 0) + 1
		val1 = True
		for i in range(1, max2 + 1):
			if d.get(i, 0) != 1:
				val1 = False
				break
		d = {}
		for element in ar[::-1][:max2]:
			d[element] = d.get(element, 0) + 1
		val2 = True
		for i in range(1, max2 + 1):
			if d.get(i, 0) != 1:
				val2 = False
				break
		if val1 and val2:
			if max1 == max2:
				print(1)
				print(max1, max2)
			else:
				print(2)
				print(max1, max2)
				print(max2, max1)
		elif val1:
			print(1)
			print(max2, max1)
		elif val2:
			print(1)
			print(max1, max2)
		else:
			print(0)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	fwd = set()
	missing = set()
	extra = set()
	passed = set()
	for (i, x) in enumerate(a, 1):
		if x in passed:
			break
		else:
			passed.add(x)
		if i in extra:
			extra.remove(i)
		else:
			missing.add(i)
		if x in missing:
			missing.remove(x)
		else:
			extra.add(x)
		if len(missing) == 0 and len(extra) == 0:
			fwd.add((i, n - i))
	rev = set()
	missing = set()
	extra = set()
	passed = set()
	for (i, x) in enumerate(reversed(a), 1):
		if x in passed:
			break
		else:
			passed.add(x)
		if i in extra:
			extra.remove(i)
		else:
			missing.add(i)
		if x in missing:
			missing.remove(x)
		else:
			extra.add(x)
		if len(missing) == 0 and len(extra) == 0:
			rev.add((n - i, i))
	vars = fwd & rev
	print(len(vars))
	for (l1, l2) in vars:
		print(l1, l2)


for _ in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	a = [0] * n
	b = [0] * n
	c = dict()
	d = dict()
	c1 = 0
	c2 = 0
	count = 0
	p = []
	max1 = 0
	max2 = 0
	for i in range(n):
		if l[i] not in c:
			c[l[i]] = 1
			c1 += 1
			if l[i] > max1:
				max1 = l[i]
			if max1 == c1:
				a[i] = 1
		else:
			break
	for i in range(n - 1, -1, -1):
		if l[i] not in d:
			d[l[i]] = 1
			c2 += 1
			if l[i] > max2:
				max2 = l[i]
			if c2 == max2:
				b[i] = 1
		else:
			break
	for i in range(n - 1):
		if a[i] == 1 and b[i + 1] == 1:
			count += 1
			p.append([i + 1, n - i - 1])
	print(count)
	for i in p:
		print(*i)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	occur1 = set()
	pos1 = set()
	max1 = 0
	for i in range(n):
		if a[i] in occur1:
			break
		occur1.add(a[i])
		max1 = max(max1, a[i])
		if len(occur1) == max1:
			pos1.add(i)
	occur2 = set()
	pos2 = set()
	max2 = 0
	for j in range(n):
		i = n - j - 1
		if a[i] in occur2:
			break
		occur2.add(a[i])
		max2 = max(max2, a[i])
		if len(occur2) == max2:
			pos2.add(i - 1)
	ans = 0
	pointer = []
	for i in pos1:
		if i in pos2:
			ans += 1
			pointer.append(i)
	print(ans)
	for i in pointer:
		print(i + 1, n - i - 1)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split(' ', n - 1)))
	ma = int(max(a))
	i = 0
	logic1 = sorted(a[:ma]) == [k for k in range(1, ma + 1)] and sorted(a[ma:]) == [j for j in range(1, n - ma + 1)]
	logic2 = sorted(a[:n - ma]) == [p for p in range(1, n - ma + 1)] and sorted(a[n - ma:]) == [q for q in range(1, ma + 1)]
	if logic1:
		i = i + 1
	if ma == n - ma:
		logic2 = False
	if logic2:
		i = i + 1
	print(i)
	if logic1:
		print(ma, n - ma)
	if logic2:
		print(n - ma, ma)


def check(arr, n):
	f = arr[0:n]
	l = arr[n:]
	freqf = [False] * n
	freql = [False] * (len(arr) - n)
	for i in f:
		try:
			freqf[i - 1] = True
		except:
			pass
	for i in l:
		try:
			freql[i - 1] = True
		except:
			pass
	for i in freqf:
		if not i:
			return False
	for i in freql:
		if not i:
			return False
	return True
for _ in range(int(input())):
	n = int(input())
	arr = [int(s) for s in input().split()]
	max = 0
	for i in arr:
		if i > max:
			max = i
	count = 0
	ans = ''
	if check(arr, max):
		count += 1
		ans += str(max) + ' ' + str(n - max) + '\n'
	if max != n - max and check(arr, n - max):
		count += 1
		ans += str(n - max) + ' ' + str(max) + '\n'
	print(count)
	print(ans, end='')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(d, c, f, g) = ([], [], [], [])
	for i in range(max(a)):
		d.append(a[i])
	for j in range(max(a), n):
		c.append(a[j])
	d = list(set(d))
	c = list(set(c))
	for i in range(len(c)):
		f.append(a[i])
	for j in range(len(c), n):
		g.append(a[j])
	f = list(set(f))
	g = list(set(g))
	r = 0
	if max(d) == len(d) and max(c) == len(c) and (len(c) + len(d) == n):
		r = 1
		if len(d) == len(c):
			r = 4
	if max(f) == len(f) and max(g) == len(g) and (len(f) + len(g) == n):
		if r == 1:
			r = 2
		else:
			r = 3
	if r == 0:
		print(0)
	elif r == 4:
		print(1)
		print(len(d, len(c)))
	elif r == 3:
		print(1)
		print(len(f), len(g))
	elif r == 1:
		print(1)
		print(len(d), len(c))
	elif r == 2:
		print(2)
		print(len(d), len(c))
		print(len(c), len(d))


tc = int(input())
for _ in range(int(tc)):
	n = int(input())
	a = list(map(int, input().split()))
	mx = max(a)
	d = []
	if set(a[:mx]) == set(range(1, mx + 1)) and set(a[mx:n]) == set(range(1, n - mx + 1)):
		d.append(mx)
	if set(a[:n - mx]) == set(range(1, n - mx + 1)) and set(a[n - mx:n]) == set(range(1, mx + 1)):
		d.append(n - mx)
	d = set(d)
	print(len(d))
	for i in d:
		print(i, n - i)


T = int(input())
n = [0] * T
ns = [0] * T
for t in range(T):
	n[t] = int(input())
	ns[t] = [int(i) for i in input().split(' ')]

def check(l):
	if len(l) == len(set(l)) and min(l) == 1 and (max(l) == len(l)):
		return True
	return False
for t in range(T):
	ans = []
	n1 = len(set(ns[t]))
	if check(ns[t][:n1]) and check(ns[t][n1:]):
		ans.append((n1, n[t] - n1))
	if check(ns[t][:n[t] - n1]) and check(ns[t][n[t] - n1:]):
		ans.append((n[t] - n1, n1))
	ans = set(ans)
	print(len(ans))
	for i in ans:
		print(i[0], i[1])


import math

def quadratic(a, b, c):
	if a == 0:
		return (int(-c / b), int(-c / b))
	elif b * b - 4 * a * c < 0:
		raise Exception
	elif b * b - 4 * a * c == 0:
		return (int(-b / (2 * a)), int(-b / (2 * a)))
	else:
		return (int((-b - math.sqrt(b * b - 4 * a * c)) / (2 * a)), int((-b + math.sqrt(b * b - 4 * a * c)) / (2 * a)))

def check(arr):
	arr.sort()
	for (i, val) in enumerate(arr):
		if i == val - 1:
			continue
		else:
			return False
	return True
t = int(input().strip())
for _ in range(t):
	n = int(input().strip())
	a = [int(_) for _ in input().strip().split()]
	try:
		(l1, l2) = quadratic(2, -2 * n, n * n + n - 2 * sum(a))
		if l1 == 0 or l2 == 0 or l1 + l2 != n:
			print(0)
		elif l1 != l2:
			flag0 = check(a[:l1]) and check(a[l1:])
			flag1 = check(a[:l2]) and check(a[l2:])
			if flag0 and flag1:
				print(2)
				print(l1, l2)
				print(l2, l1)
			elif flag0:
				print(1)
				print(l1, l2)
			elif flag1:
				print(1)
				print(l2, l1)
			else:
				print(0)
		else:
			flag0 = check(a[:l1]) and check(a[l1:])
			if flag0:
				print(1)
				print(l1, l1)
			else:
				print(0)
	except Exception as e:
		print(0)


R = lambda : map(int, input().split())
t = int(input())

def check(a):
	n = len(a)
	b = [0] * (n + 1)
	for x in a:
		if x > n or 1 > x:
			return False
		b[x] = 1
	return sum(b) == n

def solve(a, n):
	b = [0] * n
	for x in a:
		b[x] += 1
	if 2 not in b:
		print(0)
		return
	if 1 not in b:
		if n % 2:
			print(0)
			return
		elif b[1:n // 2 + 1] != [2] * (n // 2):
			print(0)
			return
		else:
			z1 = check(a[:n // 2])
			z2 = check(a[n // 2:])
			print(int(z1 and z2))
			if z1 and z2:
				print(n // 2, n // 2)
			return
	first = b.index(1)
	if first < 2:
		print(0)
		return
	if b[1:first] != [2] * (first - 1) or b[first:n - first + 2] != [1] * (n - 2 * first + 2):
		print(0)
		return
	z1 = check(a[:first - 1]) and check(a[first - 1:])
	z2 = check(a[1 - first:]) and check(a[1 - first:])
	print(int(z1) + int(z2))
	if z1:
		print(first - 1, n - first + 1)
	if z2:
		print(n - first + 1, first - 1)
for _ in range(t):
	n = int(input())
	a = list(R())
	solve(a, n)


for _ in [0] * int(input()):
	a = int(input())
	b = list(map(int, input().split()))
	z = max(b)
	d = []
	for i in range(2):
		if set(b[:z]) == set(range(1, z + 1)) and set(b[z:]) == set(range(1, a - z + 1)):
			d.append(z)
		z = a - z
	d = set(d)
	print(len(d))
	for i in d:
		print(i, a - i)


def check(l, i, j):
	r = [0] * (j - i + 1)
	try:
		for x in range(j - i + 1):
			if r[l[x + i] - 1] == 0:
				r[l[x + i] - 1] = l[x + i]
			else:
				return False
	except:
		return False
	return True

def sol(l):
	M = max(l)
	m = len(l) - M
	r = 0
	if check(l, 0, m - 1) and check(l, m, len(l) - 1):
		r += 1
	if check(l, 0, M - 1) and check(l, M, len(l) - 1):
		r += 2
	if r == 0:
		print(0)
	elif r == 1:
		print(1)
		print(m, M)
	elif r == 2:
		print(1)
		print(M, m)
	elif r == 3:
		if m != M:
			print(2)
			print(m, M)
			print(M, m)
		else:
			print(1)
			print(m, M)
t = int(input())
for _ in range(t):
	length = int(input())
	l = list(map(int, input().split()))
	sol(l)


import sys
read = sys.stdin.buffer.readline
for _ in range(int(read())):
	n = int(read())
	a = list(map(int, read().split()))
	ans = set()
	mx = max(a)
	for i in range(2):
		if set(a[:mx]) == set(range(1, mx + 1)) and set(a[mx:]) == set(range(1, n - mx + 1)):
			ans.add(mx)
		mx = n - mx
	print(len(ans))
	for i in ans:
		print(i, n - i)


from collections import Counter
for _ in range(int(input())):
	_ = input()
	a = list(map(int, input().split()))
	ma = max(a)
	mai = len(a) - ma
	ans = []
	if set(a[:ma]) == set(range(1, ma + 1)) and set(a[ma:]) == set(range(1, mai + 1)):
		ans.append([ma, mai])
	if set(a[:mai]) == set(range(1, mai + 1)) and set(a[mai:]) == set(range(1, ma + 1)) and (ma != mai):
		ans.append([mai, ma])
	print(len(ans))
	for i in ans:
		print(' '.join(list(map(str, i))))


def fun1(l):
	if len(l) == 0:
		return 0
	flag1 = False
	mx = max(l)
	n = len(l)
	s = [0 for i in range(mx)]
	for i in range(n):
		if s[l[i] - 1] == 0:
			s[l[i] - 1] = 1
		else:
			flag1 = False
			break
	else:
		if min(s) != 0:
			flag1 = True
	if flag1:
		return mx
	return 0
import sys
from collections import Counter
from copy import deepcopy
for t in range(int(sys.stdin.readline().strip())):
	n = int(sys.stdin.readline().strip())
	l = [int(j) for j in sys.stdin.readline().split()]
	sol = []
	d = dict()
	flag = True
	for i in range(n):
		if l[i] not in d:
			d[l[i]] = i
		else:
			flag = False
			break
	else:
		if len(l) == 1 and l[0] == 0:
			print(1)
		else:
			print(0)
	if not flag:
		brk = i - 1
		x = fun1(l[:brk + 1])
		y = fun1(l[brk + 1:])
		if x != 0 and y != 0:
			sol.append((x, y))
		l = l[::-1]
		d = dict()
		for i in range(n):
			if l[i] not in d:
				d[l[i]] = i
			else:
				break
		else:
			pass
		if l[i] in d:
			brk = i - 1
			x = fun1(l[:brk + 1])
			y = fun1(l[brk + 1:])
		if x != 0 and y != 0:
			sol.append((y, x))
		if len(sol) == 0:
			print(0)
		elif len(sol) == 2:
			if sol[0][0] == sol[1][0] and sol[0][1] == sol[1][1]:
				print(1)
				print(sol[0][0], sol[0][1])
			else:
				print(len(sol))
				for i in range(len(sol)):
					print(sol[i][0], sol[i][1])
		else:
			print(len(sol))
			for i in range(len(sol)):
				print(sol[i][0], sol[i][1])


def f(l):
	x = set()
	y = set()
	i = 0
	while True:
		x.add(l[i])
		if len(x) != i + 1:
			break
		i += 1
	y = set(l[i:])
	return (x, y, i)
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ans = []
	(x, y, i) = f(l)
	if len(y) == max(y) == n - i and len(x) == max(x):
		ans.append([len(x), n - len(x)])
	l.reverse()
	(x, y, i) = f(l)
	if len(y) == max(y) == n - i and len(x) == max(x):
		ans.append([n - len(x), len(x)])
	if len(ans) == 2:
		if ans[0] == ans[1]:
			ans.pop()
	print(len(ans))
	if len(ans):
		for i in ans:
			print(*i)


I = input
pr = print

def main():
	for _ in range(int(I())):
		n = int(I())
		ar = list(map(int, I().split()))
		i = max(ar)
		d = []
		for c in range(2):
			if set(ar[:i]) == set(range(1, i + 1)) and set(ar[i:]) == set(range(1, n - i + 1)):
				d.append(i)
			i = n - i
		d = set(d)
		pr(len(d))
		for x in d:
			pr(x, n - x)
main()


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
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))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

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

def stringlis():
	return list(map(str, inp().split()))

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

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

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

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

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

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve(case):
	n = int(inp())
	a = lis()
	left = {}
	right = {}
	curr = set()
	mx = 0
	for i in range(n):
		prev = len(curr)
		curr.add(a[i])
		mx = max(mx, a[i])
		if len(curr) == i + 1 and mx == i + 1:
			left[i] = True
		if prev == len(curr):
			break
	curr = set()
	mx = 0
	for i in range(n - 1, -1, -1):
		prev = len(curr)
		curr.add(a[i])
		mx = max(mx, a[i])
		if len(curr) == n - i and mx == n - i:
			right[i] = True
		if prev == len(curr):
			break
	ans = []
	for i in left:
		if i + 1 in right:
			ans.append([i + 1, n - (i + 1)])
	print(len(ans))
	for i in range(len(ans)):
		print(*ans[i])
testcase(int(inp()))


t = int(input())
for i in range(t):
	T = True
	n = int(input())
	a = list(map(int, input().split()))
	b = max(a)
	c = a[:b].copy()
	e = a[b:].copy()
	d = a[n - b:].copy()
	f = a[:n - b].copy()
	m = 0
	c.sort()
	e.sort()
	d.sort()
	f.sort()
	if b == n / 2:
		if c == list(range(1, max(c) + 1)) and e == list(range(1, max(e) + 1)):
			m += 1
	else:
		if c == list(range(1, max(c) + 1)) and e == list(range(1, max(e) + 1)):
			m += 1
		if d == list(range(1, max(d) + 1)) and f == list(range(1, max(f) + 1)):
			m += 1
			T = False
	print(m)
	if m == 2:
		print(len(c), len(e))
		print(len(f), len(d))
	elif m == 1 and T == True:
		print(len(c), len(e))
	elif m == 1 and T == False:
		print(len(f), len(d))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []

	def find(a):
		seen = set()
		(mx, mn) = (1, 3 * 10 ** 5)
		ans = []
		for i in range(len(a)):
			mx = max(mx, a[i])
			mn = min(mn, a[i])
			seen.add(a[i])
			if mn == 1 and mn + i == mx and (len(seen) == i + 1):
				ans.append(True)
			else:
				ans.append(False)
		return ans
	ans1 = find(a)
	ans2 = find(a[::-1])
	ans2 = ans2[::-1]
	for i in range(n - 1):
		if ans1[i] and ans2[i + 1]:
			ans.append([i + 1, n - (i + 1)])
	print(len(ans))
	for ent in ans:
		print(*ent)


from collections import deque
t = int(input())
for _ in range(t):
	n = int(input())
	liste = list(map(int, input().split()))
	vis = [0 for i in range(n)]
	can = [0 for i in range(n)]
	can2 = [0 for i in range(n)]
	maxi = 0
	for i in range(1, n):
		if vis[liste[i - 1]]:
			break
		vis[liste[i - 1]] = 1
		maxi = max(maxi, liste[i - 1])
		if maxi == i:
			can[maxi] = 1
	liste = liste[::-1]
	maxi = 0
	vis = [0 for i in range(n)]
	for i in range(1, n):
		if vis[liste[i - 1]]:
			break
		vis[liste[i - 1]] = 1
		maxi = max(maxi, liste[i - 1])
		if maxi == i:
			can2[maxi] = 1
	count = 0
	for i in range(1, n):
		if can[i] and can2[n - i]:
			count += 1
	print(count)
	for i in range(1, n):
		if can[i] and can2[n - i]:
			print(i, n - i)


def solve(seq, n):
	visited = [0 for i in range(n)]
	for (i, val) in enumerate(seq):
		visited[val - 1] += 1
		if visited[val - 1] == 2:
			for j in range(i):
				if visited[j] == 0:
					return 0
			visited = [0 for i in range(n)]
			for val2 in seq[i:]:
				visited[val2 - 1] += 1
			for j in range(n - i):
				if visited[j] == 0:
					return 0
			return i
	return 0
for _ in range(int(input())):
	n = int(input())
	seq = [int(x) for x in input().split()]
	ans1 = solve(seq, n)
	ans2 = solve(seq[::-1], n)
	if ans1 != 0 and ans2 != 0 and (ans1 != n - ans2):
		print(2)
		print(ans1, n - ans1)
		print(n - ans2, ans2)
	elif ans1 != 0:
		print(1)
		print(ans1, n - ans1)
	elif ans2 != 0:
		print(1)
		print(n - ans2, ans2)
	else:
		print(0)


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def case():
	n = I()
	a = li()
	d = defaultdict(int)
	pre = [0] * n
	c = 1
	ans = []
	k = 0
	for i in range(n):
		if a[i] == c:
			pre[i] = 1
			d[a[i]] = 1
			while c in d:
				c += 1
			if c - 1 == i + 1:
				ans.append(i + 1)
				k = i
		else:
			d[a[i]] == 1
	b = a.copy()
	req = ans.copy()
	a = a[::-1]
	d = defaultdict(int)
	pre = [0] * n
	c = 1
	ans = []
	k = 0
	for i in range(n):
		if a[i] == c:
			pre[i] = 1
			d[a[i]] = 1
			while c in d:
				c += 1
			if c - 1 == i + 1:
				ans.append(i + 1)
				k = i
		else:
			d[a[i]] == 1
	i = 0
	j = 0
	pink = []
	c = Counter(req)
	d = Counter(ans)
	for i in c:
		if n - i in d:
			pink.append([i, n - i])
	print(len(pink))
	for i in pink:
		print(*i)
for _ in range(int(input())):
	case()


t = int(input())
for _ in range(0, t):
	n = int(input())
	aa = [int(i) for i in input().split()]
	maxi = max(aa)
	ans = []
	if sorted(aa[:maxi]) == [int(i) for i in range(1, maxi + 1)] and sorted(aa[maxi:]) == [int(i) for i in range(1, n - maxi + 1)]:
		ans.append((maxi, n - maxi))
	aa = aa[::-1]
	if sorted(aa[:maxi]) == [int(i) for i in range(1, maxi + 1)] and sorted(aa[maxi:]) == [int(i) for i in range(1, n - maxi + 1)] and (len(aa) != 2 * maxi):
		ans.append((n - maxi, maxi))
	if len(ans):
		print(len(ans))
		for i in ans:
			print(*i)
	else:
		print(0)


import sys
import bisect
from collections import deque
RI = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

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

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

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

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

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

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

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

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

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(int(ri())):
	n = int(ri())
	a = RI()
	dic = {}
	cnt = 0
	maxx = -1
	lis = []
	bool1 = [False] * n
	bool2 = [False] * n
	for i in range(len(a)):
		if a[i] not in dic:
			dic[a[i]] = 1
			if maxx == -1:
				maxx = a[i]
				cnt += 1
			elif a[i] < maxx:
				cnt += 1
			else:
				maxx = a[i]
				cnt += 1
		else:
			break
		if maxx == cnt:
			bool1[i] = True
			lis.append(i)
	dic = {}
	cnt = 0
	maxx = -1
	for i in range(len(a) - 1, -1, -1):
		if a[i] not in dic:
			dic[a[i]] = 1
			if maxx == -1:
				maxx = a[i]
				cnt += 1
			elif a[i] < maxx:
				cnt += 1
			else:
				maxx = a[i]
				cnt += 1
		else:
			break
		if maxx == cnt:
			bool2[i] = True
	ans = []
	for i in range(n - 1):
		if bool1[i] and bool2[i + 1]:
			ans.append([i + 1, n - (i + 1)])
	print(len(ans))
	for i in ans:
		print(*i)


import sys
import collections
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		N = int(input())
		A = [int(x) for x in input().split()]
		before = [0] * (N + 1)
		beforeset = set()
		ma = 0
		f = False
		for (i, a) in enumerate(A):
			if a == 1:
				f = True
			ma = max(a, ma)
			beforeset.add(a)
			if ma == i + 1 and f and (len(beforeset) == i + 1):
				before[i + 1] = 1
		after = [0] * (N + 1)
		afterset = set()
		ma = 0
		f = False
		for (i, a) in enumerate(A[::-1]):
			if a == 1:
				f = True
			ma = max(a, ma)
			afterset.add(a)
			if ma == i + 1 and f and (len(afterset) == i + 1):
				after[N - i] = 1
		ans = 0
		lans = []
		for i in range(1, N):
			if before[i] == 1 and after[i + 1] == 1:
				ans += 1
				lans.append([i, N - i])
		if ans == 0:
			print(0)
		else:
			print(ans)
			for a in lans:
				print(*a)
main()


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	c = 0
	m1 = max(a)
	tem = []
	for j in range(1, m1 + 1):
		tem.append(j)
	p11 = a[:m1]
	p12 = a[m1:]
	p21 = a[:n - m1]
	p22 = a[n - m1:]
	solutions = []
	if sorted(p11) == tem[:m1] and sorted(p12) == tem[:n - m1] and (n != m1):
		c += 1
		solutions.append([m1, n - m1])
	if sorted(p21) == tem[:n - m1] and sorted(p22) == tem[:m1] and (n != m1) and (m1 != n - m1):
		c += 1
		solutions.append([n - m1, m1])
	print(c)
	for j in solutions:
		print(j[0], end=' ')
		print(j[1])


def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		(x1, x2, k) = (sum(a), 0, 0)
		l = []
		s1 = set()
		s2 = set(a)
		for i in range(n):
			if x1 - a[i] == (n - i - 1) * (n - i) // 2 and x2 + a[i] == (i + 1) * (i + 2) // 2 and (i != n - 1) and (set(a[:i + 1]).__len__() == i + 1) and (set(a[i + 1:]).__len__() == n - i - 1):
				l.append([i + 1, n - i - 1])
				k += 1
			x1 -= a[i]
			x2 += a[i]
		print(k)
		for i in range(k):
			print(l[i][0], l[i][1])
main()


def n_perm(arr, n):
	temp = [0] * (n + 1)
	for i in range(n):
		if arr[i] > n:
			return False
		if temp[arr[i]] == 1:
			return False
		temp[arr[i]] = 1
	return True

def help():
	n = int(input())
	arr = list(map(int, input().split(' ')))
	arr1 = [0] * n
	done = 0
	i = 0
	for i in range(n):
		if arr[i] >= n:
			print(0)
			return
		arr1[arr[i]] += 1
	done = 0
	for i in range(n):
		if i > 1 and arr1[i] > arr1[i - 1]:
			print(0)
			return
		if arr1[i] == 2:
			done += 1
		if arr1[i] > 2:
			print(0)
			return
	ans = 0
	oo = False
	ob = False
	if n_perm(arr[:done], done) and n_perm(arr[done:], n - done):
		oo = True
		ans += 1
	if done == n - done:
		print(ans)
		if oo:
			print(done, n - done)
		return
	if n_perm(arr[:n - done], n - done) and n_perm(arr[n - done:], done):
		ob = True
		ans += 1
	print(ans)
	if oo:
		print(done, n - done)
	if ob:
		print(n - done, done)
for qw in range(int(input())):
	help()


def solve(arr):
	ans = []
	ans_left = [False for i in range(len(arr))]
	ans_right = [False for i in range(len(arr))]
	totalSum = sum(arr)
	partial_sum = 0
	isPresent = [0 for i in range(0, len(arr) + 1)]
	for i in range(1, len(arr) + 1):
		if arr[i - 1] < len(isPresent) and isPresent[arr[i - 1]] == 1:
			break
		else:
			isPresent[arr[i - 1]] = 1
		partial_sum += arr[i - 1]
		if partial_sum == i * (i + 1) // 2:
			ans_left[i - 1] = True
	partial_sum = 0
	isPresent = [0 for i in range(0, len(arr) + 1)]
	for i in range(1, len(arr) + 1):
		ind = len(arr) - i
		if arr[ind] < len(isPresent) and isPresent[arr[ind]] == 1:
			break
		else:
			isPresent[arr[ind]] = 1
		partial_sum += arr[ind]
		if partial_sum == i * (i + 1) // 2:
			ans_right[ind] = True
	if ans_right[0] == True:
		ans.append([0, len(arr)])
		ans.append([0, len(arr)])
	for i in range(0, len(arr) - 1):
		if ans_left[i] == True and ans_right[i + 1] == True:
			ans.append([i + 1, len(arr) - i - 1])
	print(len(ans))
	for lt in ans:
		print(' '.join(list(map(lambda x: str(x), lt))))
t = int(input())
for i in range(0, t):
	input()
	arr = list(map(lambda x: int(x), input().split()))
	solve(arr)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	d2 = {}
	f = 0
	f1 = 0
	ans = []
	for i in range(n):
		if f == 0:
			try:
				d[a[i]] += 1
			except:
				d[a[i]] = 1
			if d[a[i]] == 2:
				f = 1
				d[a[i]] = 1
				d2[a[i]] = 1
				continue
		else:
			try:
				d2[a[i]] += 1
			except:
				d2[a[i]] = 1
			if d2[a[i]] == 2:
				f1 = 1
				break
	for i in range(1, len(d) + 1):
		try:
			if d[i] != 1:
				break
		except:
			f1 = 1
			break
	for i in range(1, len(d2) + 1):
		try:
			if d2[i] != 1:
				break
		except:
			f1 = 1
			break
	if f1 == 0:
		ans.append((len(d), len(d2)))
	a = a[::-1]
	d = {}
	d2 = {}
	f = 0
	f1 = 0
	for i in range(n):
		if f == 0:
			try:
				d[a[i]] += 1
			except:
				d[a[i]] = 1
			if d[a[i]] == 2:
				f = 1
				d[a[i]] = 1
				d2[a[i]] = 1
				continue
		else:
			try:
				d2[a[i]] += 1
			except:
				d2[a[i]] = 1
			if d2[a[i]] == 2:
				f1 = 1
				break
	for i in range(1, len(d) + 1):
		try:
			if d[i] != 1:
				break
		except:
			f1 = 1
			break
	for i in range(1, len(d2) + 1):
		try:
			if d2[i] != 1:
				break
		except:
			f1 = 1
			break
	if f1 == 0:
		ans.append((len(d2), len(d)))
	ans = list(set(ans))
	print(len(ans))
	for i in ans:
		print(*i)


T = int(input())

def check_permute(x):
	w = len(x)
	return set(x) == set([i for i in range(1, w + 1)])
for t in range(T):
	n = int(input())
	A = [int(i) for i in input().split()]
	max_A = max(A)
	ans_count = 0
	case1 = False
	case2 = False
	if check_permute(A[:max_A]) and check_permute(A[max_A:]):
		case1 = True
		ans_count += 1
	if check_permute(A[:n - max_A]) and check_permute(A[n - max_A:]):
		case2 = True
		ans_count += 1
	if case1 and case2 and ((max_A, n - max_A) == (n - max_A, max_A)):
		print(1)
		print(max_A, n - max_A)
	else:
		print(ans_count)
		if case1:
			print(max_A, n - max_A)
		if case2:
			print(n - max_A, max_A)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = set()
	(ans, mx) = (set(), 0)
	(pre, suf) = ([], [])
	for i in range(n):
		mx = max(mx, a[i])
		s.add(a[i])
		pre.append(mx == len(s) == i + 1)
	mx = 0
	s = set()
	for i in range(n - 1, -1, -1):
		mx = max(mx, a[i])
		s.add(a[i])
		suf.append(mx == len(s) == n - i)
	suf = list(reversed(suf))
	for i in range(n):
		if pre[i] and suf[i + 1]:
			ans.add((i + 1, n - i - 1))
	if ans == []:
		print(0)
	else:
		print(len(ans))
		for i in ans:
			print(i[0], i[1])


from collections import Counter, defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	ls = list(map(int, input().strip().split()))
	freq_dic = Counter(ls)
	poss_ans = []
	maxi = 0
	f = 0
	for (key, val) in freq_dic.items():
		if val == 3:
			f = 3
			break
		if val == 2:
			if key > maxi:
				maxi = key
	if f == 3:
		print('0')
	else:
		c = 0
		ans = []
		dic = defaultdict(int)
		if True:
			f1 = Counter(ls[:maxi])
			f2 = Counter(ls[maxi:])
			f = 0
			for i in range(1, maxi + 1):
				if f1[i] != 1:
					f = 1
					break
			if f == 0:
				for i in range(1, n - maxi + 1):
					if f2[i] != 1:
						f = 1
						break
			if f == 0:
				if maxi == n - maxi:
					if (maxi, n - maxi) not in dic:
						c += 1
						dic[maxi, n - maxi] = 1
						ans.append(maxi)
						ans.append(n - maxi)
				else:
					c += 1
					dic[maxi, n - maxi] = 1
					ans.append(maxi)
					ans.append(n - maxi)
			f1 = Counter(ls[:n - maxi])
			f2 = Counter(ls[n - maxi:])
			f = 0
			for i in range(1, n - maxi + 1):
				if f1[i] != 1:
					f = 1
					break
			if f == 0:
				for i in range(1, maxi + 1):
					if f2[i] != 1:
						f = 1
						break
			if f == 0:
				if maxi == n - maxi:
					if (maxi, n - maxi) not in dic:
						c += 1
						dic[n - maxi, maxi] = 1
						ans.append(n - maxi)
						ans.append(maxi)
				else:
					c += 1
					dic[n - maxi, maxi] = 1
					ans.append(n - maxi)
					ans.append(maxi)
		print(c)
		if c > 0:
			for i in range(0, len(ans), 2):
				print(ans[i], ans[i + 1])


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	m = max(l)
	s = set(l)
	if m == len(s):
		a1 = l[:n - m]
		a2 = l[n - m:]
		a3 = l[:m]
		a4 = l[m:]
		s1 = set(a1)
		s2 = set(a2)
		s3 = set(a3)
		s4 = set(a4)
		f1 = False
		f2 = False
		if len(s1) == max(a1) and len(s2) == max(a2) and (max(a1) == n - m) and (max(a2) == m):
			f1 = True
		if len(s3) == max(a3) and len(s4) == max(a4) and (max(a3) == m) and (max(a4) == n - m):
			f2 = True
		if f1 == True and f2 == True:
			if n - m != m:
				print(2)
				print(n - m, m)
				print(m, n - m)
			else:
				print(1)
				print(n - m, m)
		elif f1 == True:
			print(1)
			print(n - m, m)
		elif f2 == True:
			print(1)
			print(m, n - m)
		else:
			print(0)
	else:
		print(0)


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	m = max(a)
	r = 1
	r1 = 1
	l = sorted(a[:n - m])
	e = sorted(a[n - m:])
	l1 = sorted(a[:m])
	e1 = sorted(a[m:])
	for i in range(len(l)):
		if l[i] != i + 1:
			r = 0
			break
	for i in range(len(e)):
		if e[i] != i + 1:
			r = 0
			break
	for i in range(len(l1)):
		if l1[i] != i + 1:
			r1 = 0
			break
	for i in range(len(e1)):
		if e1[i] != i + 1:
			r1 = 0
			break
	if r == 0 and r1 == 0:
		print(0)
	elif r == 1 and r1 == 1:
		if n - m == m:
			print(1)
			print(n - m, m)
		else:
			print(2)
			print(n - m, m)
			print(m, n - m)
	elif r == 1:
		print(1)
		print(n - m, m)
	else:
		print(1)
		print(m, n - m)


testCases = int(input())
for _ in range(testCases):
	n = int(input())
	a = list(map(int, input().split()))
	mx = max(a)
	d = set()
	for c in range(2):
		if set(a[:mx]) == set(range(1, mx + 1)) and set(a[mx:]) == set(range(1, n - mx + 1)):
			d.add(mx)
		mx = n - mx
	print(len(d))
	for x in d:
		print(x, n - x)


import sys, math, bisect
inf = float('inf')
mod = 998244353

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

def gcd(a, b):
	return int(math.gcd(a, b))

def tobinary(n):
	return bin(n)[2:]

def binarySearch(a, x):
	i = bisect.bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	else:
		return -1

def lowerBound(a, x):
	i = bisect.bisect_left(a, x)
	if i:
		return i - 1
	else:
		return -1

def upperBound(a, x):
	i = bisect.bisect_right(a, x)
	if i != len(a) + 1 and a[i - 1] == x:
		return i - 1
	else:
		return -1

def primesInRange(n):
	ans = []
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			ans.append(p)
	return ans

def primeFactors(n):
	factors = []
	while n % 2 == 0:
		factors.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			factors.append(i)
			n = n // i
	if n > 2:
		factors.append(n)
	return factors
from collections import deque, defaultdict, Counter
import heapq

def check(a):
	a.sort()
	b = [i + 1 for i in range(len(a))]
	if a == b:
		return True
	else:
		return False
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = max(a)
	c = []
	if check(a[:b]) and check(a[b:]):
		c.append((b, n - b))
	if check(a[:n - b]) and check(a[n - b:]):
		c.append((n - b, b))
	c = list(set(c))
	print(len(c))
	for i in c:
		print(*i)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	sol = []
	ma = max(l)
	flag1 = False
	flag2 = False
	temp = [0] * ma
	for i in range(ma):
		if l[i] - 1 <= ma - 1:
			temp[l[i] - 1] = 1
	if 0 not in temp:
		flag1 = True
	temp = [0] * (n - ma)
	for i in range(n - ma):
		if l[i + ma] - 1 <= n - ma - 1:
			temp[l[i + ma] - 1] = 1
	if 0 not in temp:
		flag2 = True
	if flag1 and flag2:
		sol.append([ma, n - ma])
	if ma * 2 != n:
		flag1 = False
		flag2 = False
		temp = [0] * (n - ma)
		for i in range(n - ma):
			if l[i] - 1 <= n - ma - 1:
				temp[l[i] - 1] = 1
		if 0 not in temp:
			flag1 = True
		temp = [0] * ma
		for i in range(ma):
			if l[n - ma + i] - 1 <= ma - 1:
				temp[l[n - ma + i] - 1] = 1
		if 0 not in temp:
			flag2 = True
		if flag1 and flag2:
			sol.append([n - ma, ma])
		print(len(sol))
		for i in range(len(sol)):
			print(sol[i][0], sol[i][1])
	else:
		print(len(sol))
		for i in range(len(sol)):
			print(sol[i][0], sol[i][1])


t = int(input())
for tt in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	mx = max(a)
	p1 = {*range(1, mx + 1)}
	p2 = {*range(1, n - mx + 1)}
	fmx = set(a[:mx])
	fmi = set(a[:-mx])
	lmx = set(a[-mx:])
	lmi = set(a[mx:])
	ans = []
	if fmx == p1 and lmi == p2:
		ans.append((mx, n - mx))
	if lmx == p1 and fmi == p2:
		ans.append((n - mx, mx))
	if n == 2 * mx:
		print(min(1, len(ans)))
		if ans:
			print(*ans[0])
	else:
		print(len(ans))
		for i in ans:
			print(*i)


t = int(input())
for z in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	l = set()
	r = set()
	for i in a:
		if i not in l:
			l.add(i)
		else:
			break
	a.reverse()
	for i in a:
		if i not in r:
			r.add(i)
		else:
			break
	if max(len(l), len(r)) == n:
		print(0)
	else:
		a.reverse()
		f1 = 1
		f2 = 1
		for i in range(1, len(l) + 1):
			if i not in l:
				f1 = 0
				break
		lv = set(a[len(l):])
		for i in range(1, n - len(l) + 1):
			if i not in lv:
				f1 = 0
				break
		for i in range(1, len(r) + 1):
			if i not in r:
				f2 = 0
				break
		rv = set(a[:n - len(r)])
		for i in range(1, n - len(r) + 1):
			if i not in rv:
				f2 = 0
				break
		if f1 == 1 and f2 == 1:
			if len(l) + len(r) == n:
				print(1)
				print(len(l), len(r))
			else:
				print(2)
				print(len(l), n - len(l))
				print(n - len(r), len(r))
		elif f1 == 1 and f2 == 0:
			print(1)
			print(len(l), n - len(l))
		elif f1 == 0 and f2 == 1:
			print(1)
			print(n - len(r), len(r))
		else:
			print(0)


def find(a):
	n = len(a)
	(minn1, minn2, maxx1, maxx2) = ([10 ** 9], [10 ** 9], [0], [0])
	k = []
	(f1, f2) = ([], [])
	k = {}
	for i in range(n):
		if a[i] not in k:
			k[a[i]] = 'A'
		if len(k) == i + 1:
			f1.append(True)
		else:
			f1.append(False)
		minn1.append(min(minn1[-1], a[i]))
		maxx1.append(max(maxx1[-1], a[i]))
	a = a[::-1]
	kk = {}
	for i in range(n):
		if a[i] not in kk:
			kk[a[i]] = 'A'
		if len(kk) == i + 1:
			f2.append(True)
		else:
			f2.append(False)
		minn2.append(min(minn2[-1], a[i]))
		maxx2.append(max(maxx2[-1], a[i]))
	return (minn1[1:], minn2[::-1][1:-1], maxx1[1:], maxx2[::-1][1:-1], f1, f2[::-1][1:])
for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	(minf, minb, maxf, maxb, fir, sec) = find(a)
	f = []
	for i in range(n - 1):
		if minf[i] == 1 and maxf[i] == i + 1 and fir[i] and (minb[i] == 1) and (maxb[i] == n - i - 1) and sec[i]:
			f.append([i + 1, n - i - 1])
	if len(f) == 0:
		print(0)
	else:
		print(len(f))
		for x in f:
			print(x[0], x[1])


R = lambda : map(int, input().split())

def f(a):
	s = set()
	mi = 10 ** 9
	ma = 0
	ans = 0
	for i in range(len(a) - 1):
		x = a[i]
		ma = max(ma, x)
		mi = min(mi, x)
		s.add(x)
		if len(s) == i + 1 == ma and mi == 1:
			ans = ma
	if len(set(a[ans:])) == len(a) - ans == max(a[ans:]):
		return ans
	return 0
for _ in range(int(input())):
	n = int(input())
	a = list(R())
	ans = []
	ans1 = f(a)
	if ans1:
		ans.append(ans1)
	ans2 = f(a[::-1])
	if ans2 and ans1 + ans2 != n:
		ans.append(n - ans2)
	print(len(ans))
	for x in ans:
		print(x, n - x)


def check1(l):
	l = sorted(l)
	for i in range(len(l)):
		if l[i] != i + 1:
			return False
	return True
t = int(input())
for i in range(t):
	n = int(input())
	an = list(map(int, input().split()))
	mm = an.index(max(an))
	maxx = max(an)
	works1 = 0
	works2 = 0
	if check1(an[:maxx]) and check1(an[maxx:]):
		works1 = 1
	if check1(an[:len(an) - maxx]) and check1(an[len(an) - maxx:]) and (not len(an) == maxx * 2):
		works2 = 1
	print(works1 + works2)
	if works1 == 1:
		print(maxx, len(an) - maxx)
	if works2 == 1:
		print(len(an) - maxx, maxx)


def check(a):
	a.sort()
	b = [i + 1 for i in range(len(a))]
	if b == a:
		return 1
	else:
		return 0
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = max(a)
	c = []
	if check(a[:b]) and check(a[b:]):
		c.append((b, n - b))
	if check(a[:n - b]) and check(a[n - b:]):
		c.append((n - b, b))
	c = list(set(c))
	print(len(c))
	for i in range(len(c)):
		print(*c[i])


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	m = max(a)
	f = []
	if m >= len(a):
		print(0)
		continue
	else:
		l1 = a[:m]
		l2 = a[m:]
		if max(l1) == m and len(l1) == len(set(l1)):
			if max(l2) == n - m and len(l2) == len(set(l2)):
				f.append([m, n - m])
		l2 = a[:n - m]
		l1 = a[n - m:]
		if max(l1) == m and len(l1) == len(set(l1)):
			if max(l2) == n - m and len(l2) == len(set(l2)):
				f.append([n - m, m])
		if len(f) == 2:
			if f[0] != f[1]:
				print(2)
				print(*f[0])
				print(*f[1])
			else:
				print(1)
				print(*f[0])
		else:
			print(len(f))
			for i in f:
				print(*i)


import sys
import math

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

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

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

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

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

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
import bisect
INF = 10 ** 18
mod = 10 ** 9 + 7

def check(C):
	C.sort()
	j = 1
	for i in C:
		if i != j:
			return False
		j += 1
	return True
for _ in range(int(input())):
	n = int(input())
	A = alele()
	D = set()
	maxi = 0
	Ans = []
	for i in range(n):
		maxi = max(maxi, A[i])
		D.add(A[i])
		if len(D) == i + 1 and maxi == i + 1:
			if check(A[i + 1:]):
				Ans.append((i + 1, n - i - 1))
	print(len(Ans))
	for (i, j) in Ans:
		print(i, j)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	mx = max(l)
	num = 0
	s = []
	if set(l[0:mx]) == set(range(1, mx + 1)) and set(l[mx:n + 1]) == set(range(1, n - mx + 1)):
		num += 1
		s.append((mx, n - mx))
	if 2 * mx != n and set(l[n - mx:n]) == set(range(1, mx + 1)) and (set(l[0:n - mx]) == set(range(1, n - mx + 1))):
		num += 1
		s.append((n - mx, mx))
	if num == 0:
		print(num)
	else:
		print(num)
		for p in s:
			print(*p)


def f(A, n):
	flag = 0
	d = {}
	i = 0
	m = A[0]
	ls = []
	while i < n:
		if A[i] not in d:
			d[A[i]] = 1
			if A[i] > m:
				m = A[i]
			i = i + 1
		elif A[i] in d:
			if i == m:
				j = i
				k = A[j]
				d = {}
				while j < n:
					if A[j] not in d:
						d[A[j]] = 1
						if A[j] > k:
							k = A[j]
						j = j + 1
					elif A[j] in d:
						flag = 1
						break
				if flag == 0:
					if n - i == k:
						ls.append([i, n - i])
						break
					else:
						flag = 1
						break
				else:
					flag = 1
					break
			else:
				flag = 1
				break
	if flag == 0:
		return ls
	else:
		return False
t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	a = input()
	A = list(map(int, list(a.split())))
	B = A[::-1]
	if f(A, n) != False:
		ls = f(A, n)
	else:
		ls = 0
	if f(B, n) != False:
		q = f(B, n)
	else:
		q = 0
	if ls != 0 and q != 0:
		if ls[0][0] != q[0][1]:
			print(2)
			print(ls[0][0], end=' ')
			print(ls[0][1])
			print(q[0][1], end=' ')
			print(q[0][0])
		else:
			print(1)
			print(ls[0][0], end=' ')
			print(ls[0][1])
	elif ls != 0 and q == 0:
		print(1)
		print(ls[0][0], end=' ')
		print(ls[0][1])
	elif ls == 0 and q != 0:
		print(1)
		print(q[0][1], end=' ')
		print(q[0][0])
	else:
		print(0)


def f(n, a, b=0):
	siz = 0
	was = [0] * n
	cnt = [0] * n
	for x in a:
		cnt[x] += 1
		if cnt[x] > 2:
			return []
	cntcnt = [0] * 10
	for x in cnt:
		cntcnt[x] += 1
	ans = []
	for i in range(n - 1):
		siz = max(siz, max(a[i], i + 1))
		was[a[i]] += 1
		if was[a[i]] == 2:
			break
		cntcnt[cnt[a[i]]] -= 1
		cnt[a[i]] -= 1
		cntcnt[cnt[a[i]]] += 1
		if cntcnt[2] == 0 and siz == i + 1:
			if not b:
				ans += [(i + 1, n - i - 1)]
			else:
				ans += [(n - i - 1, i + 1)]
	return ans
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	x = f(n, a)
	y = f(n, a[::-1], 1)
	z = list(set(x) & set(y))
	print(len(z))
	for i in z:
		print(*i)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c = {}
	for x in a:
		c[x] = c.get(x, 0) + 1
	b = 0
	for x in sorted(c):
		if c[x] == 2:
			if x == b + 1:
				b += 1
			else:
				print(0)
				break
		elif c[x] != 1:
			print(0)
			break
	else:
		if set(c) == set(range(1, n - b + 1)):
			v = set()
			if set(range(1, b + 1)) == set(a[:b]):
				v.add(b)
			if set(range(1, n - b + 1)) == set(a[:n - b]):
				v.add(n - b)
			print(len(v))
			for x in v:
				print(x, n - x)
		else:
			print(0)


for _ in range(int(input())):
	count = 0
	countt = 0
	n = int(input())
	ai = list(map(int, input().split()))
	maxim = int(max(ai))
	a = set(ai[0:maxim])
	summa = sum(a)
	c = set(ai[maxim:n])
	summc = sum(c)
	b = set(ai[n - maxim:n])
	summb = sum(b)
	d = set(ai[0:n - maxim])
	summd = sum(d)
	if len(a) == maxim:
		if summa == len(a) * (len(a) + 1) // 2:
			if len(c) == n - maxim:
				if summc == len(c) * (len(c) + 1) // 2:
					count += 1
	if len(b) == maxim:
		if summb == len(b) * (len(b) + 1) // 2:
			if len(d) == n - maxim:
				if summd == len(d) * (len(d) + 1) // 2:
					countt += 1
	if count == 1 and countt == 1:
		if (len(a), len(c)) != (len(d), len(b)):
			print(2)
			print(len(a), len(c))
			print(len(d), len(b))
		else:
			print(1)
			print(len(a), len(c))
	elif count == 1 and countt != 1:
		print(1)
		print(len(a), len(c))
	elif count != 1 and countt == 1:
		print(1)
		print(len(d), len(b))
	else:
		print('0')


from collections import Counter
from sys import stdin, stdout
for t in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	m1 = max(a)
	m2 = n - m1
	f1 = f2 = f3 = f4 = 1
	s1 = set(a[:m1])
	s2 = set(a[m1:])
	s3 = set(a[:m2])
	s4 = set(a[m2:])
	for v in range(1, m1 + 1):
		if f1 and v not in s1:
			f1 = 0
		if f4 and v not in s4:
			f4 = 0
	for v in range(1, m2 + 1):
		if f2 and v not in s2:
			f2 = 0
		if f3 and v not in s3:
			f3 = 0
	if f1 and f2 and f3 and f4:
		if m1 == m2:
			print(1)
			print(m1, m2)
		else:
			print(2)
			print(m1, m2)
			print(m2, m1)
	elif f1 and f2:
		print(1)
		print(m1, m2)
	elif f3 and f4:
		print(1)
		print(m2, m1)
	else:
		print(0)


import sys
inp = sys.stdin.readline

def input():
	return inp().strip()
flush = sys.stdout.flush

def iin():
	return int(input())

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

def main():
	T = iin()
	for _ in range(T):
		n = iin()
		a = lin()
		a1 = []
		mx = 0
		did = set()
		br = 0
		for (j, i) in enumerate(a):
			if br:
				a1.append(0)
			else:
				mx = max(mx, i)
				if i in did:
					a1.append(0)
					br = 1
				else:
					did.add(i)
					if mx == j + 1:
						a1.append(mx)
					else:
						a1.append(0)
		a = a[::-1]
		a2 = []
		mx = 0
		did = set()
		br = 0
		for (j, i) in enumerate(a):
			if br:
				a2.append(0)
			else:
				mx = max(mx, i)
				if i in did:
					a2.append(0)
					br = 1
				else:
					did.add(i)
					if mx == j + 1:
						a2.append(mx)
					else:
						a2.append(0)
		a2 = a2[::-1]
		ans = []
		for i in range(n - 1):
			if a1[i] and a2[i + 1]:
				ans.append([a1[i], a2[i + 1]])
		print(len(ans))
		for (i, j) in ans:
			print(i, j)
main()


def calcPer():
	N = int(input())
	nums = list(map(int, input().split()))
	M = max(nums)
	counts = [0 for i in range(M)]
	rang = [0, N]
	dup_num = 0
	for i in range(N):
		counts[nums[i] - 1] += 1
		n = counts[nums[i] - 1]
		if n > 2:
			print(0)
			return
		if n == 2 and dup_num == 0:
			dup_num = nums[i]
			rang[1] = i
			rang[0] = nums.index(nums[i])
	if 0 in counts:
		print(0)
		return
	for i in range(rang[0] + 1, rang[1]):
		if counts[nums[i] - 1] == 2:
			rang[0] = i
	if rang == [0, N]:
		print(0)
		return
	outs = []
	count_w = 0
	lis1 = nums[0:rang[0] + 1]
	lis2 = nums[rang[0] + 1:N]
	m1 = max(lis1)
	counts = [0 for i in range(m1)]
	for l in lis1:
		counts[l - 1] += 1
	(valid1, valid2) = (1, 1)
	for c in counts:
		if c != 1:
			valid1 = 0
			break
	if valid1:
		m2 = max(lis2)
		counts = [0 for i in range(m2)]
		for l in lis2:
			counts[l - 1] += 1
		for c in counts:
			if c != 1:
				valid2 = 0
				break
	if valid1 and valid2:
		count_w += 1
		x = len(lis1)
		outs.append([x, N - x])
	if rang[1] - rang[0] > 1:
		lis1 = nums[0:rang[1]]
		lis2 = nums[rang[1]:N]
		m1 = max(lis1)
		counts = [0 for i in range(m1)]
		for l in lis1:
			counts[l - 1] += 1
		(valid1, valid2) = (1, 1)
		for c in counts:
			if c != 1:
				valid1 = 0
				break
		if valid1:
			m2 = max(lis2)
			counts = [0 for i in range(m2)]
			for l in lis2:
				counts[l - 1] += 1
			for c in counts:
				if c != 1:
					valid2 = 0
					break
		if valid1 and valid2:
			count_w += 1
			x = len(lis1)
			outs.append([x, N - x])
	print(count_w)
	for x in outs:
		print(x[0], x[1])
T = int(input())
for t in range(T):
	calcPer()


t = int(input())
for case in range(t):
	n = int(input())
	al = [int(a) for a in input().split()]
	aset = set()
	bset = set()
	amax = 0
	bmax = 0
	for i in range(n):
		if al[n - i - 1] not in bset:
			bset.add(al[n - i - 1])
			while bmax + 1 in bset:
				bmax += 1
		else:
			break
	for i in range(n - len(bset)):
		if al[i] not in aset:
			aset.add(al[i])
			while amax + 1 in aset:
				amax += 1
		else:
			break
	if len(aset) + len(bset) != n:
		print(0)
		continue
	pairs = []
	if amax + bmax == n:
		pairs.append((amax, bmax))
	for i in range(len(aset), n - 1):
		if al[i] in aset:
			break
		aset.add(al[i])
		while amax + 1 in aset:
			amax += 1
		bset.remove(al[i])
		bmax = min(bmax, al[i] - 1)
		if amax + bmax == n:
			pairs.append((amax, bmax))
	print(len(pairs))
	for p in pairs:
		print('{} {}'.format(p[0], p[1]))


def checkPerm(A, l, r):
	v = A[l]
	for i in range(l, r + 1):
		if A[i] > v:
			v = A[i]
	memo = [1] * (v + 1)
	memo[0] = 0
	for i in range(l, r + 1):
		memo[A[i]] -= 1
	if any(memo):
		return False
	return True
for t in range(int(input())):
	n = int(input())
	A = [int(s) for s in input().split()]
	ans = []
	memo = [0] * n
	i = 0
	while i < n:
		if memo[A[i]]:
			if checkPerm(A, 0, i - 1) and checkPerm(A, i, n - 1):
				ans.append([i, n - i])
			break
		memo[A[i]] = 1
		i += 1
	for j in range(n):
		memo[j] = 0
	i = n - 1
	while i >= 0:
		if memo[A[i]]:
			if checkPerm(A, 0, i) and checkPerm(A, i + 1, n - 1):
				ans.append([i + 1, n - i - 1])
			break
		memo[A[i]] = 1
		i -= 1
	if len(ans) == 2 and ans[0] == ans[1]:
		ans.pop()
	print(len(ans))
	for ele in ans:
		print('{} {}'.format(ele[0], ele[1]))


def check(A):
	A.sort()
	for i in range(len(A)):
		if A[i] != i + 1:
			return 0
	return 1
for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	a = max(A)
	d = check(A[:a])
	e = check(A[a:])
	Ans = []
	if d == 1 and e == 1:
		Ans.append([a, n - a])
	if n - a != a:
		d = check(A[:n - a])
		e = check(A[n - a:])
		if d == 1 and e == 1:
			Ans.append([n - a, a])
	print(len(Ans))
	for i in Ans:
		print(*i)


def chk(s, e):
	global a
	oc = [0 for i in range(e - s + 1)]
	for i in a[s:e + 1]:
		if i > e - s + 1:
			return False
		oc[i - 1] = 1
	if 0 in oc:
		return False
	return True
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	oc = [0 for i in range(n - 1)]
	for i in a:
		oc[i - 1] += 1
	if oc[0] != 2:
		print(0)
		continue
	for i in range(len(oc)):
		if oc[i] != 2:
			break
		min_ind = i
	num = 0
	ans = []
	if chk(0, min_ind) and chk(min_ind + 1, n - 1):
		ans.append([min_ind + 1, n - min_ind - 1])
		num += 1
	if chk(0, n - min_ind - 2) and chk(n - min_ind - 1, n - 1):
		ans.append([n - min_ind - 1, min_ind + 1])
		num += 1
	if num == 0:
		print(0)
	elif num == 2 and ans[0][0] == ans[1][0]:
		print(1)
		print(*ans[0])
		continue
	else:
		print(num)
		for i in ans:
			print(*i)


from sys import *
from collections import *
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = [0] * n
	c = [0] * n
	d = defaultdict(lambda : 0)
	mx = 0
	for i in range(n):
		if d[a[i]] == 1:
			break
		else:
			d[a[i]] += 1
		mx = max(mx, a[i])
		if mx == i + 1:
			b[i] = 1
	d = defaultdict(lambda : 0)
	mx = 0
	for i in range(n - 1, -1, -1):
		if d[a[i]] == 1:
			break
		else:
			d[a[i]] += 1
		mx = max(mx, a[i])
		if mx == n - i:
			c[i] = 2
	tp = []
	cn = 0
	for i in range(n - 1):
		if b[i] == 1 and c[i + 1] == 2:
			cn += 1
			tp.append((i + 1, n - (i + 1)))
	print(cn)
	for i in range(cn):
		print(tp[i][0], tp[i][1])


import math
t = int(input())
while t > 0:
	n = int(input())
	l = [int(s) for s in input().split()]
	d = []
	mx = max(l)
	for i in range(2):
		if set(l[:mx]) == set(range(1, mx + 1)) and set(range(1, n - mx + 1)) == set(l[mx:]):
			d.append(mx)
		mx = n - mx
	d = set(d)
	print(len(d))
	for i in d:
		print(i, n - i)
	t -= 1


def verifypermutation(l):
	n = len(l)
	return sorted(l) == list(range(1, n + 1))

def process():
	n = int(input())
	l = [int(x) for x in input().split()]
	m = max(l)
	outputs = []
	if m >= n:
		print(0)
	else:
		if verifypermutation(l[:m]) and verifypermutation(l[m:]):
			outputs.append('{} {}'.format(m, n - m))
		if m != n - m and verifypermutation(l[:n - m]) and verifypermutation(l[n - m:]):
			outputs.append('{} {}'.format(n - m, m))
		print(len(outputs))
		for item in outputs:
			print(item)
numtests = int(input())
for _ in range(numtests):
	process()


from collections import Counter

def check(list1, list2):
	return set(list1) == set(list2)

def solve(n, a):
	if n == 2:
		if a.count(1) == 2:
			return '1' + '\n' + ' '.join(['1', '1'])
		else:
			return '0'
	counter_a = Counter(a)
	for i in range(1, n):
		if counter_a[i] > 1:
			i += 1
		elif i == 1:
			return '0'
		else:
			i -= 1
			break
	pm = range(1, i + 1)
	head = a[:i]
	tail = a[-i:]
	check1 = check(head, pm)
	check2 = check(tail, pm)
	if check1 and check2:
		new = a[:-i]
		pm = range(1, len(new) + 1)
		if check(new, pm):
			if i == n - i:
				return '1' + '\n' + ' '.join([str(i), str(i)])
			else:
				return '2' + '\n' + ' '.join([str(i), str(n - i)]) + '\n' + ' '.join([str(n - i), str(i)])
		else:
			return '0'
	elif check1:
		new = a[i:]
		pm = range(1, len(new) + 1)
		if check(new, pm):
			return '1' + '\n' + ' '.join([str(i), str(n - i)])
		else:
			return '0'
	elif check2:
		new = a[:-i]
		pm = range(1, len(new) + 1)
		if check(new, pm):
			return '1' + '\n' + ' '.join([str(n - i), str(i)])
		else:
			return '0'
	else:
		return '0'
t = int(input())
for _n in range(0, t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	print(solve(n, a))


a = int(input())
for i in range(0, a):
	k = int(input())
	s = list(map(int, input().split()))
	m = max(s)
	n = k - m
	l1 = set(s[0:n])
	l2 = set(s[n:])
	l3 = set(s[0:m])
	l4 = set(s[m:])
	count = 0
	an1 = ''
	an2 = ''
	if set(range(1, n + 1)) == l1 and l2 == set(range(1, m + 1)):
		count = count + 1
		an1 = str(n) + ' ' + str(m)
	if set(range(1, m + 1)) == l3 and l4 == set(range(1, n + 1)):
		count = count + 1
		an2 = str(m) + ' ' + str(n)
		if an1 == an2:
			count = 1
			an2 = ''
	print(count)
	if an1 != '':
		print(an1)
	if an2 != '':
		print(an2)


for i in range(int(input())):
	n = int(input())
	lic = list(map(int, input().split()))
	out = []
	ans = [i for i in range(1, n + 1)]
	ma = max(lic)
	(lic1, lic2, lic3, lic4) = (lic[:ma], lic[ma:], lic[-ma:], lic[:-ma])
	if sorted(lic1) == ans[:ma] and sorted(lic2) == ans[:n - ma]:
		out.append(len(lic1))
	if sorted(lic3) == ans[:ma] and sorted(lic4) == ans[:n - ma] and (len(lic4) not in out):
		out.append(len(lic4))
	print(len(out))
	for i in out:
		print(i, n - i)


def dreammoonLikesPermutations(n, array):
	d = {}
	for x in array:
		if x in d:
			d[x] += 1
			if d[x] >= 3:
				return (0, [])
		else:
			d[x] = 1
	for x in range(1, len(d)):
		if not (x in d and x + 1 in d):
			return (0, [])
		if d[x + 1] > d[x]:
			return (0, [])
	s = set()
	for x in range(1, len(d) + 1):
		if d[x] == 2:
			s.add(x)
		else:
			break
	if not s:
		return (0, [])
	v = set()
	ans = []
	for x in range(len(s)):
		v.add(array[x])
	if v == s:
		ans.append([x + 1, n - x - 1])
		if x + 1 == n - x - 1:
			return (len(ans), ans)
	v = set()
	for x in range(n - len(s), n):
		v.add(array[x])
	if v == s:
		ans.append([n - len(s), len(s)])
	return (len(ans), ans)
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	(a, ans) = dreammoonLikesPermutations(n, l)
	if a == 0:
		print(a)
	else:
		print(a)
		for x in ans:
			print(x[0], x[1])


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	l1 = max(a)
	l2 = n - l1
	c = 0
	if l1 == n:
		print('0')
	else:
		p11 = sorted(a[:l1])
		p12 = sorted(a[:l2])
		p21 = sorted(a[l1:])
		p22 = sorted(a[l2:])
		p1 = [i for i in range(1, l1 + 1)]
		p2 = [j for j in range(1, l2 + 1)]
		k = 0
		if p11 == p1 and p21 == p2:
			c += 1
			k = l1
		if p12 == p2 and p22 == p1:
			c += 1
			k = l2
		if l1 == l2 and c > 0:
			c = 1
		print(c)
		if c == 1:
			print(k, n - k)
		if c == 2:
			print(l1, l2)
			print(l2, l1)


from collections import defaultdict as dc
from heapq import *
import math
import bisect
import sys
from collections import deque as dq
mod = 10 ** 12

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

def line():
	p = list(map(int, input().split()))
	return p

def digit(n):
	s = str(n)
	p = 0
	for i in s:
		p += int(i) ** 2
	return p

def check(a, b):
	c = 0
	for i in range(len(a)):
		if a[i] != b[i]:
			c += 1
			if c > 1:
				return 0
	return 1

def check(a, b, x):
	if a == 1 and b == x:
		return 1
	return 0
for _ in range(inp()):
	n = inp()
	a = line()
	p = dc(int)
	r1 = dc(int)
	mn = float('inf')
	mx = float('-inf')
	for i in range(n):
		mn = min(mn, a[i])
		mx = max(mx, a[i])
		l = i + 1
		p[a[i]] += 1
		if p[a[i]] > 1:
			break
		elif check(mn, mx, l):
			r1[i + 1] += 1
	q = dc(int)
	r2 = dc(int)
	mn = float('inf')
	mx = float('-inf')
	for i in range(n - 1, -1, -1):
		mn = min(mn, a[i])
		mx = max(mx, a[i])
		l = n - i
		q[a[i]] += 1
		if q[a[i]] > 1:
			break
		elif check(mn, mx, l):
			r2[n - i] = 1
	ans = []
	if len(r1) > len(r2):
		for i in r2.keys():
			if r1[n - i] >= 1:
				ans.append((n - i, i))
	else:
		for i in r1.keys():
			if r2[n - i] >= 1:
				ans.append((i, n - i))
	print(len(ans))
	for i in ans:
		print(*i)


from collections import Counter, defaultdict, deque

def read_int():
	return int(input())

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

def read_float():
	return float(input())

def read_float_n():
	return list(map(float, input().split()))

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

def read_str_n():
	return list(map(str, input().split()))

def error_print(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time

	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		error_print(e - s, 'sec')
		return ret
	return wrap

def isp(a):
	n = len(a)
	a = set(a)
	for i in range(1, n + 1):
		if i not in a:
			return False
	return True

def slv(N, A):
	sa = [0]
	for a in A:
		sa.append(sa[-1] + a)
	K = []
	for i in range(N):
		n = i + 1
		m = N - n
		ls = sa[i + 1] - sa[0]
		rs = sa[N] - sa[i + 1]
		if ls == (n ** 2 + n) // 2 and rs == (m ** 2 + m) // 2:
			if isp(A[:i + 1]) and isp(A[i + 1:]):
				K.append((n, m))
	print(len(K))
	for k in K:
		print(*k)

def main():
	T = read_int()
	for _ in range(T):
		N = read_int()
		A = read_int_n()
		slv(N, A)
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	positions1 = []
	occured1 = set({})
	max1 = 0
	for i in range(n):
		if a[i] in occured1:
			break
		occured1.add(a[i])
		max1 = max(max1, a[i])
		if len(occured1) == max1:
			positions1.append(i)
	positions2 = set({})
	occured2 = set({})
	max2 = 0
	for j in range(n):
		i = n - j - 1
		if a[i] in occured2:
			break
		occured2.add(a[i])
		max2 = max(max2, a[i])
		if len(occured2) == max2:
			positions2.add(i - 1)
	count = 0
	places = []
	for i in positions1:
		if i in positions2:
			count += 1
			places.append(i)
	print(count)
	for i in places:
		print(i + 1, n - i - 1)


import sys
from collections import Counter
readLine = lambda : sys.stdin.readline()
readInt = lambda : int(sys.stdin.readline())
readInts = lambda : [int(x) for x in sys.stdin.readline().split(' ')]

def main():
	solns = []
	t = readInt()
	for _ in range(t):
		n = readInt()
		a = readInts()
		count = 0
		s = []
		largest = max(a)
		counter = Counter(a)
		if counter[largest] == 2:
			p1 = a[:largest]
			p2 = a[-largest:]
			if len(p1) + len(p2) != len(a):
				pass
			else:
				p1 = set(p1)
				if p1 == set(p2) and p1 == set(range(1, largest + 1)):
					count += 1
					s.append(f'{largest} {largest}')
		elif counter[largest] == 1:
			pivot = a.index(largest)
			p1 = a[:largest]
			p2 = a[-(n - largest):]
			if set(p1) == set(range(1, len(p1) + 1)) and set(p2) == set(range(1, len(p2) + 1)):
				count += 1
				s.append(f'{largest} {n - largest}')
			p2 = a[-largest:]
			p1 = a[:n - largest]
			if set(p1) == set(range(1, len(p1) + 1)) and set(p2) == set(range(1, len(p2) + 1)):
				count += 1
				s.append(f'{n - largest} {largest}')
		else:
			pass
		solns.append(str(count))
		if count > 0:
			solns.extend(s)
	print('\n'.join(solns))
main()


def f(l, k):
	d = set(l)
	if len(d) == k:
		if max(d) == k:
			return True
		else:
			return False
	else:
		return False
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = max(l)
	res = []
	if n - d != d:
		if f(l[:d], d) and f(l[d:], n - d):
			res.append([d, n - d])
		if f(l[n - d:], d) and f(l[:n - d], n - d):
			res.append([n - d, d])
	elif f(l[:d], d) and f(l[d:], n - d):
		res.append([d, n - d])
	print(len(res))
	for i in res:
		print(*i)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	maxx = arr[0]
	cnt = 1
	k = set()
	ans = {}
	k.add(arr[0])
	if maxx == cnt:
		ans[cnt] = 1
	for i in range(1, n):
		maxx = max(maxx, arr[i])
		k.add(arr[i])
		cnt += 1
		if maxx == len(k) and maxx == cnt:
			ans[cnt] = 1
	arr = arr[-1::-1]
	p = arr[0]
	cnt = 1
	k = set()
	k.add(arr[0])
	temp = {}
	if p == cnt:
		temp[cnt] = 1
	for i in range(1, n):
		p = max(p, arr[i])
		k.add(arr[i])
		cnt += 1
		if p == len(k) and p == cnt:
			temp[cnt] = 1
	f = []
	for i in temp:
		if n - i in ans:
			f.append([n - i, i])
	print(len(f))
	for i in f:
		print(*i)


for _ in range(int(input())):
	x = int(input())
	num = list(map(int, input().split()))
	ans = []
	corr = [i for i in range(x)]
	i = max(num)
	for k in range(2):
		if len(set(num[:i])) + len(set(num[i:x])) == x and sorted(num[:i]) == corr[1:i + 1] and (sorted(num[i:x]) == corr[1:x - i + 1]):
			ans.append(i)
		i = x - i
	ans = set(ans)
	print(len(ans))
	for j in ans:
		print(j, x - j)


def isPermutation(l):
	if len(l) == 1:
		if l[0] == 1:
			return True
		else:
			return False
	r = list(range(1, len(l) + 1))
	l1 = l[:]
	l1.sort()
	if l1 == r:
		return True
	else:
		return False
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	counter = 0
	pr = []
	maxval = max(l)
	l1 = l[:n - maxval]
	l2 = l[n - maxval:]
	if isPermutation(l1) and isPermutation(l2):
		counter += 1
		pr.append(n - maxval)
	l1 = l[:maxval]
	l2 = l[maxval:]
	if isPermutation(l1) and isPermutation(l2) and (n - maxval != maxval):
		counter += 1
		pr.append(maxval)
	print(counter)
	for i in range(len(pr)):
		print(pr[i], n - pr[i])


def is_correct(sub_array):
	s = set(sub_array)
	if min(s) != 1:
		return False
	if max(s) != len(sub_array):
		return False
	if len(s) != len(sub_array):
		return False
	return True

def permutations(n, m):
	m = [int(m[i]) for i in range(len(m))]
	if len(m) != n:
		return 'Incorrect input'
	g = []
	maxr = max(m)
	if is_correct(m[maxr:]) and is_correct(m[:maxr]):
		g.append('{0} {1}'.format(maxr, n - maxr))
	if is_correct(m[n - maxr:]) and is_correct(m[:n - maxr]) and (2 * maxr != n):
		g.append('{0} {1}'.format(n - maxr, maxr))
	return g
for i in range(int(input().strip())):
	n = int(input().strip())
	m = input().strip().split()
	arr = permutations(n, m)
	if len(arr) == 0:
		print(0)
	else:
		print(len(arr))
		for j in range(len(arr)):
			print(arr[j])


cases = int(input())
for t in range(cases):
	n = int(input())
	a = list(map(int, input().split()))
	out = 0
	outl = []
	pos = -1
	f = 0
	f1 = []
	d1 = {}
	mv = 0
	c = 0
	p = 0
	a.append(a[-1])
	for i in range(n + 1):
		if a[i] in d1:
			if c == mv:
				p += 1
				if p == 2:
					pos = i
					f = 1
					f1 = [n - mv, mv]
				d1 = {}
				d1[a[i]] = 1
				c = 1
				mv = a[i]
			else:
				p = -1
				break
		else:
			d1[a[i]] = 1
			c += 1
			mv = max(mv, a[i])
	if p == 2 and pos == n:
		out += f
		outl.append(f1)
	pos = -1
	f = 0
	f1 = []
	d1 = {}
	mv = 0
	c = 0
	p = 0
	a = a[:-1]
	a = a[::-1]
	a.append(a[-1])
	for i in range(n + 1):
		if a[i] in d1:
			if c == mv:
				p += 1
				if p == 2:
					pos = i
					f = 1
					f1 = [mv, n - mv]
				d1 = {}
				d1[a[i]] = 1
				c = 1
				mv = a[i]
			else:
				p = -1
				break
		else:
			d1[a[i]] = 1
			c += 1
			mv = max(mv, a[i])
	if p == 2 and pos == n:
		if f1 not in outl:
			outl.append(f1)
			out += 1
	print(out)
	for (i, j) in outl:
		print(i, j)


def I():
	return list(map(int, input().split()))
for __ in range(int(input())):
	n = int(input())
	arr = I()
	ans = []
	m = max(arr)
	l1 = m
	l2 = n - m
	done = [0] * l1
	for i in range(l1):
		if arr[i] > l1:
			break
		done[arr[i] - 1] = 1
	if not done.count(0) > 0:
		ans1 = l2
		done = [0] * l2
		for i in range(l2):
			if arr[i + l1] > l2:
				break
			done[arr[i + l1] - 1] = 1
		if not done.count(0) > 0:
			ans.append([l1, l2])
	done = [0] * l2
	for i in range(l2):
		if arr[i] > l2:
			break
		done[arr[i] - 1] = 1
	if not done.count(0) > 0:
		done = [0] * l1
		for i in range(l1):
			if arr[i + l2] > l1:
				break
			done[arr[i + l2] - 1] = 1
		if not done.count(0) > 0 and l1 != l2:
			ans.append([l2, l1])
	print(len(ans))
	for i in ans:
		print(*i)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	m = max(a)
	l = []
	for i in range(m + 1):
		l.append(0)
	for i in range(n):
		l[a[i]] += 1
	f = 0
	for i in range(1, m + 1):
		if l[i] != 1 and l[i] != 2:
			f = 1
			break
		if l[i] != 2:
			break
	if f == 1:
		print(0)
	else:
		for j in range(i + 1, m + 1):
			if l[j] != 1:
				f = 1
				break
		if f == 1:
			print(0)
		else:
			if i != m:
				y = i - 1
				z = n - y
			else:
				y = i
				z = n - y
			l1 = []
			for i in range(y + 1):
				l1.append(0)
			for i in range(y):
				if a[i] > y:
					break
				l1[a[i]] += 1
			l2 = []
			for i in range(z + 1):
				l2.append(0)
			for i in range(1, z + 1):
				if a[i * -1] > z:
					break
				l2[a[i * -1]] += 1
			ans = 0
			if l1.count(1) == y and l2.count(1) == z:
				ans += 1
			w = z
			x = y
			l1 = []
			for i in range(w + 1):
				l1.append(0)
			for i in range(w):
				if a[i] > w:
					break
				l1[a[i]] += 1
			l2 = []
			for i in range(x + 1):
				l2.append(0)
			for i in range(1, x + 1):
				if a[i * -1] > x:
					break
				l2[a[i * -1]] += 1
			if l1.count(1) == w and l2.count(1) == x:
				if ans == 1:
					if w != y:
						print(2)
						print(w, x)
						print(y, z)
					else:
						print(1)
						print(w, x)
				else:
					print(1)
					print(w, x)
			elif ans == 1:
				print(1)
				print(y, z)
			else:
				print(0)


import sys
inp = sys.stdin.readline
read = lambda : list(map(int, inp().split()))
ans = ''
for _ in range(int(inp())):
	n = int(inp())
	arr = read()
	total = sum(arr)
	s1 = 0
	ans_lis = []
	for i in range(n):
		s1 += arr[i]
		total -= arr[i]
		(p1, p2) = (i + 1, n - i - 1)
		if s1 == p1 * (p1 + 1) // 2 and total == p2 * (p2 + 1) // 2 and (len(set(arr[:p1])) == p1) and (len(set(arr[p1:])) == p2):
			ans_lis.append(str(p1) + ' ' + str(p2))
	ans += str(len(ans_lis)) + '\n'
	for i in ans_lis:
		ans += str(i) + '\n'
print(ans)


import sys
input = sys.stdin.readline
from sys import stdin, stdout

def main():
	for _ in range(int(input())):
		n = int(input())
		l = [int(s) for s in input().split()]
		k = 0
		ans = []
		c1 = [0] * n
		c2 = [0] * n
		fr = 0
		tw1 = 0
		rev = 0
		tw2 = 0
		ii = 10 ** 9 + 7
		jj = 0
		c1[l[0] - 1] += 1
		for i in range(1, n):
			c2[l[i] - 1] += 1
			if c2[l[i] - 1] > 1:
				tw2 += 1
		for i in range(n - 1, -1, -1):
			if c2[i] > 0:
				jj = i
				break
		for i in range(n):
			if c2[i] == 0 and i < jj:
				rev += 1
		for i in range(n):
			if c1[i] == 1:
				if i > 0:
					fr += 1
				if ii == 10 ** 9 + 7:
					ii = i + 1
				break
			else:
				ii = min(ii, i)
		if fr == 0 and tw2 == 0 and (rev == 0):
			ans.append([1, n - 1])
			k += 1
		for w in range(1, n - 1):
			if l[w] - 1 >= ii:
				fr += 1
			c1[l[w] - 1] += 1
			c2[l[w] - 1] -= 1
			if c1[l[w] - 1] > 1:
				break
			if c2[l[w] - 1] == 1:
				tw2 -= 1
			else:
				rev += 1
			if l[w] - 1 == jj:
				while jj >= 0 and c2[jj] == 0:
					rev -= 1
					jj -= 1
			if l[w] - 1 == ii:
				while ii < n and c1[ii] == 1:
					fr -= 1
					ii += 1
			if fr == 0 and tw2 == 0 and (rev == 0):
				k += 1
				ans.append([w + 1, n - w - 1])
		print(k)
		for i in ans:
			print(*i)
main()


def read_int():
	n = int(input())
	return n

def read_ints():
	ints = [int(x) for x in input().split(' ')]
	return ints

def check_perm(p):
	cntr = [0] * len(p)
	lmt = len(p)
	for i in p:
		if not 1 <= i <= lmt:
			return 0
		elif cntr[i - 1] != 0:
			return 0
		else:
			cntr[i - 1] = 1
	return 1
t = read_int()
for case in range(t):
	n = read_int()
	a = read_ints()
	perms = []
	amx = max(a)
	p1 = (a[:amx], a[amx:])
	p2 = (a[-amx:], a[:-amx])
	if check_perm(p1[0]) and check_perm(p1[1]):
		perms.append((max(p1[0]), max(p1[1])))
	if check_perm(p2[0]) and check_perm(p2[1]):
		if (max(p2[1]), max(p2[0])) not in perms:
			perms.append((max(p2[1]), max(p2[0])))
	print(len(perms))
	for i in perms:
		print('{} {}'.format(i[0], i[1]))


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	ans = set()
	mx = max(a)
	for x in range(2):
		if set(a[:mx]) == set(range(1, mx + 1)) and set(a[mx:]) == set(range(1, n - mx + 1)):
			ans.add(mx)
		mx = n - mx
	print(len(ans))
	for x in ans:
		print(x, n - x)


I = input
for _ in range(int(I())):
	n = int(I())
	a = list(map(int, I().split(' ')))
	dd = [0 for i in range(n)]
	lm = [a[0]]
	ld = [1]
	t = a[0]
	dd[t - 1] = 1
	c = 1
	for i in range(1, n - 1):
		if a[i] > t:
			t = a[i]
		lm.append(t)
		if dd[a[i] - 1] == 0:
			c += 1
			dd[a[i] - 1] = 1
		ld.append(c)
	dd = [0 for i in range(n)]
	t = a[n - 1]
	rm = [t]
	rd = [1]
	c = 1
	dd[t - 1] = 1
	for i in range(n - 2, 0, -1):
		if a[i] > t:
			t = a[i]
		rm.append(t)
		if dd[a[i] - 1] == 0:
			c += 1
			dd[a[i] - 1] = 1
		rd.append(c)
	rm = rm[::-1]
	rd = rd[::-1]
	ans = []
	for i in range(n - 1):
		if ld[i] == i + 1 and rd[i] == n - i - 1:
			if lm[i] == i + 1 and rm[i] == n - i - 1:
				ans.append([lm[i], rm[i]])
	print(len(ans))
	for i in ans:
		print(i[0], i[1])


import sys

def update(d, req):
	while req in d:
		req += 1
	return req

def solve(a, n, pre2):
	req = 1
	maxi = 0
	d = {}
	for x in range(n):
		if a[x] in d:
			return [0, 0]
		else:
			d[a[x]] = 1
		maxi = max(maxi, a[x])
		if a[x] == req:
			req = update(d, req)
			if maxi != req - 1:
				continue
			elif x + 1 < n and pre2[x + 1]:
				return [x, 1]
			else:
				continue
	return [0, 0]

def solve_back(a, n, pre1):
	d2 = {}
	mx = 0
	rq = 1
	for y in range(n - 1, -1, -1):
		if a[y] in d2:
			return -1
		else:
			d2[a[y]] = 1
		mx = max(mx, a[y])
		if a[y] == rq:
			rq = update(d2, rq)
			if mx != rq - 1:
				continue
			elif y - 1 >= 0 and pre1[y - 1]:
				return y
			else:
				continue
	return -1

def make_pre(a, n):
	pre1 = [False] * n
	d = {}
	maxi = 0
	req = 1
	for x in range(n):
		if a[x] in d:
			break
		else:
			d[a[x]] = 1
		maxi = max(maxi, a[x])
		if a[x] == req:
			req = update(d, req)
			if maxi == req - 1:
				pre1[x] = True
	pre2 = [False] * n
	d2 = {}
	mx = 0
	rq = 1
	for y in range(n - 1, -1, -1):
		if a[y] in d2:
			break
		else:
			d2[a[y]] = 1
		mx = max(mx, a[y])
		if a[y] == rq:
			rq = update(d2, rq)
			if mx == rq - 1:
				pre2[y] = True
	return [pre1, pre2]
t = int(sys.stdin.readline())
for i in range(t):
	n = int(sys.stdin.readline())
	a = [int(x) for x in sys.stdin.readline().split()]
	[pre1, pre2] = make_pre(a, n)
	arr = solve(a, n, pre2)
	if arr[1] == 0:
		print(0)
	if arr[1] == 1:
		sec = solve_back(a, n, pre1)
		if sec == -1 or sec == arr[0] + 1:
			print(1)
			print(arr[0] + 1, n - arr[0] - 1)
		else:
			print(2)
			print(arr[0] + 1, n - arr[0] - 1)
			print(sec, n - sec)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	l = [False for _ in range(n)]
	r = [False for _ in range(n)]
	cur_max = 0
	s = set()
	for i in range(n):
		el = a[i]
		if el in s:
			break
		s.add(el)
		cur_max = max(cur_max, el)
		if cur_max == len(s):
			l[i] = True
	cur_max = 0
	s = set()
	for i in range(n - 1, -1, -1):
		el = a[i]
		if el in s:
			break
		s.add(el)
		cur_max = max(cur_max, el)
		if cur_max == len(s):
			r[i] = True
	ans = 0
	for i in range(n - 1):
		if l[i] and r[i + 1]:
			ans += 1
	print(ans)
	for i in range(n - 1):
		if l[i] and r[i + 1]:
			print('{} {}'.format(str(i + 1), str(n - i - 1)))


def per(X):
	S = set(X)
	if not len(X) == len(S):
		return False
	for i in range(1, len(X) + 1):
		if i not in S:
			return False
	return True
for _ in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	m = max(p)
	(l1, l11) = (m, n - m)
	(l2, l22) = (n - m, m)
	ans = 0
	res = []
	if per(p[l1:]) and per(p[:l1]):
		ans += 1
		res.append([l1, l11])
	if per(p[l2:]) and per(p[:l2]):
		ans += 1
		res.append([l2, l22])
	if ans == 0:
		print(0)
	elif ans == 1:
		print(1)
		print(*res[0])
	elif res[0] == res[1]:
		print(1)
		print(*res[0])
	else:
		print(2)
		print(*res[0])
		print(*res[1])


def is_permutation(xs):
	xs.sort()
	for (i, x) in enumerate(xs):
		if i != x:
			return False
	return True

def ways_to_split(xs):
	x_counts = {}
	x_double_max = -1
	for x in xs:
		x_count = x_counts[x] = 1 + x_counts.get(x, 0)
		if x_count == 2:
			if x > x_double_max:
				x_double_max = x
		elif x_count == 3:
			return []
	if x_double_max == -1:
		raise ValueError('Такого быть не может по условию!')
	l_smaller_perm = x_double_max + 1
	ways = set()
	if is_permutation(xs[:l_smaller_perm]) and is_permutation(xs[l_smaller_perm:]):
		ways.add((l_smaller_perm, len(xs) - l_smaller_perm))
	if is_permutation(xs[-l_smaller_perm:]) and is_permutation(xs[:-l_smaller_perm]):
		ways.add((len(xs) - l_smaller_perm, l_smaller_perm))
	return ways
for _ in range(int(input())):
	input()
	ways = ways_to_split([int(x) - 1 for x in input().split(' ')])
	print(len(ways))
	for (a, b) in ways:
		print(a, b)


def ipr(s):
	for n in range(len(s)):
		if s[n] != n + 1:
			return 0
	return 1

def chek(s):
	mp1 = {}
	mp2 = {}
	pos = 0
	a = []
	b = []
	for n in range(len(s)):
		if s[n] not in mp1 and pos == 0:
			mp1[s[n]] = 1
			a.append(s[n])
		elif s[n] not in mp2:
			pos = 1
			b.append(s[n])
			mp2[s[n]] = 1
		else:
			return [0, (0, 0)]
	if ipr(sorted(a)) and ipr(sorted(b)):
		return [1, (len(a), len(b))]
	return [0, (0, 0)]

def solv():
	x = int(input())
	s = list(map(int, input().split()))
	res = set()
	(v, b) = chek(s)
	if v:
		res.add(b)
	s.reverse()
	(v, b) = chek(s)
	j = (b[1], b[0])
	if v:
		res.add(j)
	res = list(res)
	print(len(res))
	for n in res:
		print(*n)
for _ in range(int(input())):
	solv()


def solve(n):
	n = int(input())
	arr = list(map(int, input().split()))
	Max = max(arr)
	(np, ans) = (0, [])
	l1 = sorted(arr[:Max])
	l2 = sorted(arr[Max:])
	if l1 == list(range(1, Max + 1)) and l2 == list(range(1, n - Max + 1)):
		np += 1
		ans.append((Max, n - Max))
	l1 = sorted(arr[:n - Max])
	l2 = sorted(arr[n - Max:])
	if l1 == list(range(1, n - Max + 1)) and l2 == list(range(1, Max + 1)):
		np += 1
		ans.append((n - Max, Max))
	print(len(set(ans)))
	for (i, j) in list(set(ans)):
		print(i, j)
t = int(input())
for i in range(t):
	solve(i)


for _ in range(int(input())):
	n = int(input())
	s = map(int, input().split())
	s = list(s)
	a = set()
	se = set()
	m = 0
	for i in range(n - 1):
		if s[i] in se:
			break
		se.add(s[i])
		m = max(m, s[i])
		if m == i + 1:
			a.add(m)
	b = set()
	se = set()
	m = 0
	for i in range(n - 1, 0, -1):
		if s[i] in se:
			break
		se.add(s[i])
		m = max(m, s[i])
		if m == n - i:
			b.add(m)
	ans = []
	for i in a:
		if n - i in b:
			ans.append([i, n - i])
	print(len(ans))
	for (a, b) in ans:
		print(a, b)


import math
from collections import Counter
L = lambda : list(map(int, input().split()))
M = lambda : map(int, input().split())
I = lambda : int(input())
IN = lambda : input()

def s(a):
	print(''.join(list(map(str, a))))
t = I()
for i in range(t):
	n = I()
	a = L()
	x = 0
	k = 0
	l1 = max(a)
	l2 = n - l1
	if l1 == n:
		print(0)
	else:
		p = sorted(a[:l1])
		q = sorted(a[l1:])
		r = sorted(a[:l2])
		s = sorted(a[l2:])
		A = [i for i in range(1, l1 + 1)]
		B = [i for i in range(1, l2 + 1)]
		if p == A and q == B:
			x += 1
			k = l1
		if r == B and s == A:
			x += 1
			k = l2
		if l1 == l2 and x > 0:
			x = 1
		print(x)
		if x == 1:
			print(k, n - k)
		elif x == 2:
			print(l1, l2)
			print(l2, l1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	set1 = set()
	set2 = set()
	_max1 = 0
	_max2 = 0
	possible1 = [False] * n
	possible2 = [False] * n
	cancelled1 = False
	cancelled2 = False
	for i in range(n):
		j = n - i - 1
		_max1 = max(_max1, a[i])
		_max2 = max(_max2, a[j])
		if not cancelled1 and a[i] not in set1:
			set1.add(a[i])
		else:
			cancelled1 = True
		if not cancelled2 and a[j] not in set2:
			set2.add(a[j])
		else:
			cancelled2 = True
		if not cancelled1:
			possible1[i] = _max1 == len(set1)
		if not cancelled2:
			possible2[j] = _max2 == len(set2)
	indices = []
	for i in range(n - 1):
		if possible1[i] and possible2[i + 1]:
			indices.append([i, i + 1])
	print(len(indices))
	for i in range(len(indices)):
		print(indices[i][0] + 1, n - indices[i][1])


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	mx = max(a)
	sols = []
	if mx < n:
		l1 = list(sorted(a[:mx]))
		l2 = list(sorted(a[mx:]))
		rl1 = list(range(1, mx + 1))
		rl2 = list(range(1, n - mx + 1))
		if l1 == rl1 and l2 == rl2:
			sols.append((mx, n - mx))
		l1 = list(sorted(a[:n - mx]))
		l2 = list(sorted(a[n - mx:]))
		if mx * 2 != n and l1 == rl2 and (l2 == rl1):
			sols.append((n - mx, mx))
	print(len(sols))
	for p in sols:
		print(*p)


t = int(input())
for _ in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	i = 0
	s1 = set()
	s2 = set()
	x = []
	ans = 0
	total = set()
	total1 = set()
	while i < n - 1:
		if l[i] in s1:
			break
		else:
			s1.add(l[i])
		i += 1
	while i < n:
		if l[i] in s2:
			break
		else:
			s2.add(l[i])
		i += 1
	for i in range(1, len(s1) + 1):
		total.add(i)
	if total - s1 == set() and len(s1) + len(s2) == n:
		for i in range(1, n - len(s1) + 1):
			total1.add(i)
		if total1 - s2 == set():
			ans += 1
			x = [len(s1), len(s2)]
	s1.clear()
	s2.clear()
	i = n - 1
	while i > 0:
		if l[i] in s1:
			break
		else:
			s1.add(l[i])
		i -= 1
	while i > -1:
		if l[i] in s2:
			break
		else:
			s2.add(l[i])
		i -= 1
	total.clear()
	total1.clear()
	y = []
	for i in range(1, len(s1) + 1):
		total.add(i)
	if total - s1 == set() and len(s1) + len(s2) == n:
		total1 = set()
		for i in range(1, n - len(s1) + 1):
			total1.add(i)
		if total1 - s2 == set():
			ans += 1
			y = [len(s2), len(s1)]
	if x == y and x:
		ans -= 1
		y = []
	print(ans)
	if x:
		print(*x)
	if y:
		print(*y)


t = int(input())
while t > 0:
	n = int(input())
	arr = [int(x) for x in input().split()]
	x = max(arr)
	A = arr[:x]
	B = arr[x:]
	C = arr[-x:]
	D = arr[:-x]
	A.sort()
	B.sort()
	C.sort()
	D.sort()
	ans = []
	if x == n - x:
		if A == list(range(1, x + 1)) and B == list(range(1, n - x + 1)):
			ans += [[x, n - x]]
	else:
		if A == list(range(1, x + 1)) and B == list(range(1, n - x + 1)):
			ans += [[x, n - x]]
		if C == list(range(1, x + 1)) and D == list(range(1, n - x + 1)):
			ans += [[n - x, x]]
	print(len(ans))
	for i in range(len(ans)):
		print(' '.join([str(x) for x in ans[i]]))
	t = t - 1


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from bisect import *

def main():
	for t in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		b = Counter(a)
		ans = -1
		for i in b:
			if b[i] > 2:
				ans = 0
				break
		if ans == 0:
			print(0)
		else:
			c = []
			b = len(set(a))
			d = set()
			for i in range(n - b):
				d.add(a[i])
			e = set()
			for i in range(n - b, n, 1):
				e.add(a[i])
			f = 0
			for i in range(n - b):
				if i + 1 not in d:
					f = 1
					break
			f1 = 0
			for i in range(b):
				if i + 1 not in e:
					f1 = 1
					break
			if f == 0 and f1 == 0:
				c.append([n - b, b])
			d = set()
			for i in range(b):
				d.add(a[i])
			e = set()
			for i in range(b, n, 1):
				e.add(a[i])
			f = 0
			for i in range(b):
				if i + 1 not in d:
					f = 1
					break
			f1 = 0
			for i in range(n - b):
				if i + 1 not in e:
					f1 = 1
					break
			if f == 0 and f1 == 0:
				c.append([b, n - b])
				if len(c) == 2:
					if c[1][0] == c[0][0] and c[1][1] == c[0][1]:
						c.pop()
			print(len(c))
			for i in c:
				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')
main()


def comp(n, s):
	x = n * (n + 1) // 2
	if x == s:
		return True
	else:
		return False

def comp2(n, s):
	x = n * (n + 1) // 2
	x = x ** 2
	if x == s:
		return True
	else:
		return False

def comp1(n, s):
	x = n * (n + 1) * (2 * n + 1) // 6
	if x == s:
		return True
	else:
		return False

def computeXOR(n):
	if n % 4 == 0:
		return n
	if n % 4 == 1:
		return 1
	if n % 4 == 2:
		return n + 1
	return 0
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ans = [0] * n
	ans1 = [0] * n
	ans2 = [0] * n
	ans[0] = l[0]
	ans1[0] = l[0] * l[0]
	ans2[0] = l[0] * l[0] * l[0]
	for i in range(1, n):
		ans[i] = l[i] + ans[i - 1]
		ans1[i] = l[i] * l[i] + ans1[i - 1]
		ans2[i] = l[i] * l[i] * l[i] + ans2[i - 1]
	final = []
	for i in range(n):
		if comp(i + 1, ans[i]) and comp(n - i - 1, ans[n - 1] - ans[i]) and comp1(i + 1, ans1[i]) and comp1(n - i - 1, ans1[n - 1] - ans1[i]) and comp2(i + 1, ans2[i]) and comp2(n - i - 1, ans2[n - 1] - ans2[i]):
			final.append(i + 1)
			final.append(n - i - 1)
	if len(final):
		print(len(final) // 2)
		for i in range(0, len(final), 2):
			print(final[i], end=' ')
			print(final[i + 1])
	else:
		print(0)


t = int(input())

def check(l):
	b = list(range(1, len(l) + 1))
	l.sort()
	if l == b:
		return True
	else:
		return False
for i in range(t):
	count = 0
	c = []
	k = int(input())
	x = [int(x) for x in input().split()]
	for j in [max(x), k - max(x)]:
		a1 = x[:j]
		a2 = x[j:]
		if check(a1) and check(a2):
			c.append(j)
	c = list(set(c))
	print(len(c))
	for m in range(len(c)):
		print(c[m], k - c[m])


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	c = Counter(a)
	m = max(c)
	possible = True
	for i in range(1, m + 1):
		if c[i] not in [1, 2]:
			possible = False
	l1 = m
	for i in range(1, m + 1):
		if c[i] != 2:
			l1 = i - 1
			break
	if c[1] == 0:
		possible = False
	for i in range(l1 + 1, m + 1):
		if c[i] != 1:
			possible = False
	if possible:
		total = 0
		firstP = False
		if set(a[:l1]) == set((i for i in range(1, l1 + 1))):
			if set(a[l1:]) == set((i for i in range(1, m + 1))):
				total += 1
				firstP = True
		if m != l1 and set(a[:m]) == set((i for i in range(1, m + 1))):
			if set(a[m:]) == set((i for i in range(1, l1 + 1))):
				total += 1
		print(total)
		if firstP:
			print(l1, m)
		if not firstP and total or (total == 2 and m != l1):
			print(m, l1)
	else:
		print(0)


t = int(input())
for i in range(t):
	n = int(input())
	pos = [int(k) for k in input().split()]
	dic1 = {}
	dic2 = {}
	i = 0
	(a, b, c, d) = (0, n - 1, 0, n - 1)
	while i < n:
		try:
			(a, b) = (dic1[pos[i]], i)
			break
		except:
			dic1[pos[i]] = i
			i += 1
	i = n - 1
	while i >= 0:
		try:
			(c, d) = (i, dic2[pos[i]])
			break
		except:
			dic2[pos[i]] = i
			i -= 1
	if b <= c:
		print(0)
		continue
	sm1 = 0
	sm2 = sum(pos)
	i = 0
	ans = []
	while i < c:
		sm1 += pos[i]
		sm2 -= pos[i]
		i += 1
	while i < b:
		sm1 += pos[i]
		sm2 -= pos[i]
		if sm1 == (i + 1) * (i + 2) // 2 and sm2 == (n - i) * (n - i - 1) // 2:
			ans.append(i + 1)
		i += 1
	print(len(ans))
	for k in ans:
		print(k, n - k)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = []
	fin = [0 for j in range(n)]
	ind = -1
	for j in range(n):
		if fin[arr[j] - 1] == 0:
			fin[arr[j] - 1] = 1
		else:
			if sum(fin[0:j]) == j:
				ind = j
			break
	fin2 = [0 for j in range(n)]
	if ind != -1:
		for j in range(ind, n):
			if fin2[arr[j] - 1] == 0:
				fin2[arr[j] - 1] = 1
			else:
				break
		else:
			if sum(fin2[0:n - ind]) == n - ind:
				ans.append(ind)
	arr.reverse()
	fin = [0 for j in range(n)]
	ind = -1
	for j in range(n):
		if fin[arr[j] - 1] == 0:
			fin[arr[j] - 1] = 1
		else:
			if sum(fin[0:j]) == j:
				ind = j
			break
	fin2 = [0 for j in range(n)]
	if ind != -1:
		for j in range(ind, n):
			if fin2[arr[j] - 1] == 0:
				fin2[arr[j] - 1] = 1
			else:
				break
		else:
			if sum(fin2[0:n - ind]) == n - ind:
				if len(ans) > 0:
					if ans[0] != n - ind:
						ans.append(n - ind)
				else:
					ans.append(n - ind)
	print(len(ans))
	for x in ans:
		print(str(x) + ' ' + str(n - x))


def search(p1, p2, lp1, lp2):
	used_1 = [True] + [False] * lp1
	for ele in p1:
		if ele > lp1:
			return False
		elif used_1[ele] == False:
			used_1[ele] = True
		else:
			return False
	used_2 = [True] + [False] * lp2
	for ele in p2:
		if ele > lp2:
			return False
		elif used_2[ele] == False:
			used_2[ele] = True
		else:
			return False
	return True

def solve(ans1, ans2):
	n = int(input())
	a = [int(x) for x in input().split()]
	ma = max(a)
	count = 0
	p1 = a[0:ma:1]
	p2 = a[ma:]
	stm1 = search(p1, p2, ma, n - ma)
	if stm1:
		count += 1
		ans2.append([ma, n - ma])
	if ma == n - ma:
		ans1.append(count)
		return
	p1 = a[0:n - ma:1]
	p2 = a[n - ma:]
	stm2 = search(p1, p2, n - ma, ma)
	if stm2:
		count += 1
		ans2.append([n - ma, ma])
	ans1.append(count)
	return
n = int(input())
ans1 = []
ans2 = []
for i in range(n):
	solve(ans1, ans2)
for ele in ans1:
	print(ele)
	for i in range(ele):
		print(*ans2[0])
		ans2.pop(0)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	c = 0
	d = 0
	for i in range(n):
		if arr[i] == 1 and c == 0:
			first = i
			c += 1
		elif arr[i] == 1 and c == 1:
			second = i
			c += 1
		elif arr[i] == 1:
			c += 1
	if c == 2:
		var = 1
		temp = [False] * n
		s = set()
		for i in range(n):
			if arr[i] in s:
				break
			s.add(arr[i])
			while var in s:
				s.remove(var)
				var += 1
			if len(s) == 0:
				temp[i] = True
			else:
				temp[i] = False
		var = 1
		newTemp = [False] * n
		arr.reverse()
		s = set()
		for i in range(n):
			if arr[i] in s:
				break
			s.add(arr[i])
			while var in s:
				s.remove(var)
				var += 1
			if len(s) == 0:
				newTemp[i] = True
			else:
				newTemp[i] = False
		newTemp.reverse()
		ans = []
		for i in range(n - 1):
			if temp[i] == newTemp[i + 1] == 1:
				ans.append((i + 1, n - i - 1))
		print(len(ans))
		if len(ans):
			for (l, r) in ans:
				print(l, r)
	else:
		print(0)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	maxi = max(arr)
	li = []
	for k in range(2):
		if set(arr[:maxi]) == set(range(1, maxi + 1)) and set(arr[maxi:]) == set(range(1, n - maxi + 1)):
			li.append(maxi)
		maxi = n - maxi
	li = set(li)
	print(len(li))
	for i in li:
		print(i, n - i)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = set()
	(ans, mx, mn) = (set(), 0, float('inf'))
	(pre, suf) = ([False] * n, [False] * n)
	for i in range(n):
		mn = min(mn, a[i])
		mx = max(mx, a[i])
		s.add(a[i])
		pre[i] = mx == len(s) == i + 1 and mn == 1
	mx = 0
	s = set()
	mn = float('inf')
	for i in range(n - 1, -1, -1):
		mn = min(mn, a[i])
		mx = max(mx, a[i])
		s.add(a[i])
		suf[i] = mx == len(s) == n - i and mn == 1
	for i in range(n):
		if pre[i] and suf[i + 1]:
			ans.add((i + 1, n - i - 1))
	if ans == []:
		print(0)
	else:
		print(len(ans))
		for i in ans:
			print(i[0], i[1])


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')
for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = max(l)
	s1 = n - s
	if s1 <= 0:
		print(0)
		continue
	p1 = set()
	p2 = set()
	d = set()
	d1 = set()
	lw = []
	ans = 0
	for j in range(s1):
		d.add(j + 1)
	for j in range(s):
		d1.add(j + 1)
	for j in range(s1):
		p1.add(l[j])
	for j in range(s1, n):
		p2.add(l[j])
	if p1 == d and p2 == d1:
		ans += 1
		lw.append([s1, s])
		if s == s1:
			print(1)
			print(s1, s)
			continue
	p1 = set()
	p2 = set()
	for j in range(s):
		p2.add(l[j])
	for j in range(s, n):
		p1.add(l[j])
	if p1 == d and p2 == d1:
		ans += 1
		lw.append([s, s1])
	print(ans)
	for j in range(len(lw)):
		print(lw[j][0], lw[j][1])


t = int(input())
while t > 0:
	n = int(input())
	a = [int(x) for x in input().split()]
	b = []
	for i in range(n + 1):
		b.append(-1)
	k1 = -1
	for i in range(n):
		if b[a[i]] == -1:
			b[a[i]] = i
		else:
			k1 = i
			break
	for i in range(n + 1):
		b[i] = -1
	k2 = -1
	for i in range(n - 1, -1, -1):
		if b[a[i]] == -1:
			b[a[i]] = i
		else:
			k2 = i
			break
	if k1 > k2:
		temp = k1
		k1 = k2
		k2 = temp
	if k1 == -1 or k2 == -1:
		print(0)
		t -= 1
		continue
	a1 = []
	a2 = []
	b1 = []
	b2 = []
	for i in range(n):
		if i <= k1:
			a1.append(a[i])
		else:
			a2.append(a[i])
	for i in range(n):
		if i < k2:
			b1.append(a[i])
		else:
			b2.append(a[i])
	a1.sort()
	a2.sort()
	b1.sort()
	b2.sort()
	flaga = 0
	flagb = 0
	for i in range(1, len(a1)):
		if a1[i] - 1 != a1[i - 1]:
			flaga = 1
	for i in range(1, len(a2)):
		if a2[i] - 1 != a2[i - 1]:
			flaga = 1
	for i in range(1, len(b1)):
		if b1[i] - 1 != b1[i - 1]:
			flagb = 1
	for i in range(1, len(b2)):
		if b2[i] - 1 != b2[i - 1]:
			flagb = 1
	if a1[0] != 1 and a1[-1] != k1 + 1:
		flaga = 1
	if a2[0] != 1 and a2[-1] != n - (k1 + 1):
		flaga = 1
	if b1[0] != 1 and b1[-1] != k2:
		flagb = 1
	if b2[0] != 1 and b2[-1] != n - k2:
		flagb = 1
	if a1 == b1 and a2 == b2:
		flagb = 1
	print(2 - (flagb + flaga))
	if flaga == 0:
		print(k1 + 1, n - (k1 + 1))
	if flagb == 0:
		print(k2, n - k2)
	t -= 1


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	aa = list(map(int, input().split()))
	ss = set()
	st = 0
	ind = 1
	pre = [0 for i in range(n)]
	for i in range(n):
		if aa[i] in ss:
			break
		ss.add(aa[i])
		while ind <= len(ss):
			if ind in ss:
				ind += 1
			else:
				break
		if len(ss) != ind - 1:
			pre[i] = 0
		else:
			pre[i] = ind
	ind = 1
	ss = set()
	suff = [0 for i in range(n)]
	for i in range(n - 1, -1, -1):
		if aa[i] in ss:
			break
		ss.add(aa[i])
		while ind <= len(ss):
			if ind in ss:
				ind += 1
			else:
				break
		if len(ss) != ind - 1:
			suff[i] = 0
		else:
			suff[i] = ind
	tot = 0
	ans = []
	for i in range(n - 1):
		if pre[i] > 0 and suff[i + 1] > 0:
			tot += 1
			ans.append([i + 1, n - i - 1])
	print(tot)
	for i in ans:
		print(i[0], i[1])


def solve(nums, n):
	used = [False] * n * 2
	used[0] = True
	pos = 0
	ans_left = []
	for (i, num) in enumerate(nums):
		used[num] = True
		while used[pos + 1] and pos <= i + 1:
			pos += 1
		if pos == i + 1:
			ans_left.append((pos, n - pos))
	nums = list(reversed(nums))
	used = [False] * n * 2
	used[0] = True
	pos = 0
	ans_right = []
	for (i, num) in enumerate(nums):
		used[num] = True
		while used[pos + 1] and pos <= i + 1:
			pos += 1
		if pos == i + 1:
			ans_right.append((n - pos, pos))
	ans_left = set(ans_left)
	ans_right = set(ans_right)
	return list(ans_left.intersection(ans_right))
t = int(input())
for _ in range(t):
	n = int(input())
	nums = list(map(int, input().split()))
	ans = solve(nums, n)
	print(len(ans))
	for a in ans:
		print(a[0], a[1])


for T in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	p1 = max(arr)
	v1 = [False] * (p1 + 1)
	v1[0] = True
	p2 = n - p1
	v2 = [False] * (p2 + 1)
	v2[0] = True
	lis = []
	if p2 > p1:
		print(0)
	else:
		res1 = 1
		for i in range(p1):
			if v1[arr[i]] == False:
				v1[arr[i]] = True
		for i in range(p1 + 1):
			if v1[i] == False:
				res1 = -1
				break
		if res1 == 1:
			res2 = 1
			for i in range(p1, n):
				if arr[i] < p2 + 1 and v2[arr[i]] == False:
					v2[arr[i]] = True
				else:
					break
			for i in range(p2 + 1):
				if v2[i] == False:
					res2 = -1
					break
			if res2 == 1:
				lis.append((p1, p2))
		if p1 != p2:
			v1 = [False] * (p2 + 1)
			v1[0] = True
			v2 = [False] * (p1 + 1)
			v2[0] = True
			res4 = 1
			for i in range(p2, n):
				if v2[arr[i]] == False:
					v2[arr[i]] = True
			for i in range(p1 + 1):
				if v2[i] == False:
					res4 = -1
					break
			if res4 == 1:
				res3 = 1
				for i in range(p2):
					if arr[i] < p2 + 1 and v1[arr[i]] == False:
						v1[arr[i]] = True
					else:
						break
				for i in range(p2 + 1):
					if v1[i] == False:
						res3 = -1
						break
				if res3 == 1:
					lis.append((p2, p1))
		if len(lis) == 0:
			print(0)
		else:
			print(len(lis))
			for (a, b) in lis:
				print(a, b)


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	x = list(map(int, input().split()))
	mx = max(x)
	m = n - mx
	if n == 1 or m <= 0 or m > mx:
		print(0)
	else:
		d1 = Counter(x[:m])
		d2 = Counter(x[m:])
		f1 = 1
		f2 = 1
		for i in range(1, m + 1):
			if i not in d1:
				f1 = 0
				break
			elif d1[i] > 1:
				f1 = 0
				break
		for i in range(1, mx + 1):
			if i not in d2:
				f1 = 0
				break
			elif d2[i] > 1:
				f1 = 0
				break
		d1 = Counter(x[:mx])
		d2 = Counter(x[mx:])
		for i in range(1, m + 1):
			if i not in d2:
				f2 = 0
				break
			elif d2[i] > 1:
				f2 = 0
				break
		for i in range(1, mx + 1):
			if i not in d1:
				f2 = 0
				break
			elif d1[i] > 1:
				f2 = 0
				break
		if f1 == 1 and f2 == 1:
			if m != mx:
				print(2)
				print(m, mx)
				print(mx, m)
			else:
				print(1)
				print(m, mx)
		elif f1 == 1 and f2 == 0:
			print(1)
			print(m, mx)
		elif f1 == 0 and f2 == 1:
			print(1)
			print(mx, m)
		else:
			print(0)


import sys
input = sys.stdin.readline

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

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

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return res

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

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

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

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

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	n = int(input())
	a = int_array()
	left = []
	xset = set()
	length = 0
	mini = INF
	maxi = NINF
	for i in a:
		if i in xset:
			break
		xset.add(i)
		length += 1
		mini = min(i, mini)
		maxi = max(maxi, i)
		if mini == 1 and maxi == length:
			left.append(length)
	a = a[::-1]
	first = left.copy()
	left = []
	xset = set()
	length = 0
	mini = INF
	maxi = NINF
	for i in a:
		if i in xset:
			break
		xset.add(i)
		length += 1
		mini = min(i, mini)
		maxi = max(maxi, i)
		if mini == 1 and maxi == length:
			left.append(length)
	first = set(first)
	second = set(left)
	ans = 0
	this = []
	for i in first:
		if n - i in second:
			ans += 1
			this.append((i, n - i))
	print(ans)
	for i in this:
		print(*i)


t = int(input())
for you in range(t):
	n = int(input())
	l = input().split()
	li = [int(i) for i in l]
	z = max(li)
	y = n - z
	if y <= 0:
		print(0)
		continue
	hashi1 = dict()
	hashi2 = dict()
	for i in range(1, z + 1):
		hashi1[i] = 1
	for i in range(1, y + 1):
		hashi2[i] = 1
	hashi1c = hashi1.copy()
	hashi2c = hashi2.copy()
	l = []
	poss = 1
	for i in range(z):
		if li[i] not in hashi1 or hashi1[li[i]] == 0:
			poss = 0
			break
		hashi1[li[i]] -= 1
	for i in range(z, n):
		if li[i] not in hashi2 or hashi2[li[i]] == 0:
			poss = 0
			break
		hashi2[li[i]] -= 1
	if poss:
		l.append((z, y))
	poss = 1
	for i in range(y):
		if li[i] not in hashi2c or hashi2c[li[i]] == 0:
			poss = 0
			break
		hashi2c[li[i]] -= 1
	for i in range(y, n):
		if li[i] not in hashi1c or hashi1c[li[i]] == 0:
			poss = 0
			break
		hashi1c[li[i]] -= 1
	if poss and (y, z) != (z, y):
		l.append((y, z))
	print(len(l))
	for i in l:
		print(i[0], i[1])


def perm(A):
	max_a = 0
	S = set()
	ret = set()
	for (i, a) in enumerate(A):
		if max_a < a:
			max_a = a
		S.add(a)
		if max_a == i + 1 and len(S) == i + 1:
			ret.add(max_a)
	return ret

def main():
	for _ in [0] * int(input()):
		n = int(input())
		A = list(map(int, input().split()))
		left = perm(A)
		right = perm(A[::-1])
		ans = []
		for l in left:
			if n - l in right:
				ans.append(l)
		print(len(ans))
		[print(l, n - l) for l in ans]
main()


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	m = 0
	s = 0
	d = {}
	ans1 = {}
	for i in range(n):
		if l[i] > m:
			m = l[i]
		try:
			d[l[i]] += 5
			break
		except:
			d[l[i]] = 1
			s += 1
		if s == m:
			ans1[i + 1, n - i - 1] = 2
	ans = []
	l = l[::-1]
	m = 0
	s = 0
	d = {}
	for i in range(n):
		if l[i] > m:
			m = l[i]
		try:
			d[l[i]] += 5
			break
		except:
			d[l[i]] = 1
			s += 1
		if s == m:
			try:
				ans1[n - i - 1, i + 1] += 5
				ans.append([n - i - 1, i + 1])
			except:
				kk = 5
	print(len(ans))
	for i in range(len(ans)):
		print(ans[i][0], ans[i][1])


cycles = int(input())

def find_first(vals, high, high2):
	s1 = set(range(1, high + 1))
	s2 = set(range(1, high2 + 1))
	for i in range(high):
		val = vals[i]
		if val not in s1:
			return []
		else:
			s1.remove(val)
	if len(s1) != 0:
		return []
	for i in range(high, high + high2):
		val = vals[i]
		if val not in s2:
			return []
		else:
			s2.remove(val)
	if len(s2) != 0:
		return []
	return [[high, high2]]

def find_second(vals, high, high2):
	s1 = set(range(1, high + 1))
	s2 = set(range(1, high2 + 1))
	for i in range(high2):
		val = vals[i]
		if val not in s2:
			return []
		else:
			s2.remove(val)
	if len(s2) != 0:
		return []
	for i in range(high2, high + high2):
		val = vals[i]
		if val not in s1:
			return []
		else:
			s1.remove(val)
	if len(s1) != 0:
		return []
	return [[high2, high]]

def find(vals):
	if len(vals) < 2:
		return []
	elif len(vals) == [1, 1]:
		return [[1, 1]]
	else:
		high = max(vals)
		high2 = len(vals) - high
		if high == high2:
			return find_first(vals, high, high2)
		return find_second(vals, high, high2) + find_first(vals, high, high2)
results = []
for cycle in range(cycles):
	n = int(input())
	vals = map(int, input().split())
	results.append(find(list(vals)))
for r in results:
	print(len(r))
	for s in r:
		print('%d %d' % (s[0], s[1]))


from sys import stdin, stdout
t = int(stdin.readline())
for query in range(t):
	n = int(stdin.readline())
	a = stdin.readline().split()
	for num in range(n):
		a[num] = int(a[num])
	b = sorted(a[:])
	counter1 = 1
	counter2 = 0
	while b[counter2] == counter1 and b[counter2 + 1] == counter1:
		counter2 += 2
		counter1 += 1
		if counter2 + 1 >= n:
			break
	counter1 -= 1
	solutions = 0
	counter2 = counter1
	counter3 = 0
	mysolutions = []
	while counter2:
		if a[counter3] <= counter1:
			counter2 = counter2 - 1
		counter3 += 1
	list1 = sorted(a[:counter3])
	list2 = sorted(a[counter3:])
	list1bool = True
	list2bool = True
	for x in range(counter3):
		if list1[x] != x + 1:
			list1bool = False
	for x in range(n - counter3):
		if list2[x] != x + 1:
			list2bool = False
	if list1bool and list2bool:
		solutions += 1
		mysolutions.append([counter3, n - counter3])
	counter2 = counter1
	counter3 = n - 1
	while counter2:
		if a[counter3] <= counter1:
			counter2 = counter2 - 1
		counter3 -= 1
	list1 = sorted(a[:counter3 + 1])
	list2 = sorted(a[counter3 + 1:])
	list1bool = True
	list2bool = True
	for x in range(counter3 + 1):
		if list1[x] != x + 1:
			list1bool = False
	for x in range(n - counter3 - 1):
		if list2[x] != x + 1:
			list2bool = False
	if list1bool and list2bool:
		solutions += 1
		mysolutions.append([counter3 + 1, n - counter3 - 1])
	if solutions == 2:
		if mysolutions[0] == mysolutions[1]:
			mysolutions.remove(mysolutions[0])
			solutions -= 1
	stdout.write('\n' + str(solutions) + '\n')
	for solution in range(solutions):
		stdout.write(str(mysolutions[solution][0]) + ' ' + str(mysolutions[solution][1]) + '\n')


import heapq
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	q = []
	s = set()
	memo = [0] * n
	ret = []
	for i in range(n):
		heapq.heappush(q, -a[i])
		cmax = heapq.heappop(q)
		heapq.heappush(q, cmax)
		s.add(a[i])
		if len(s) == i + 1 and -cmax == i + 1:
			memo[i] = 1
	q = []
	s = set()
	for i in range(n - 1, 0, -1):
		heapq.heappush(q, -a[i])
		cmax = heapq.heappop(q)
		heapq.heappush(q, cmax)
		s.add(a[i])
		if len(s) == n - i and -cmax == n - i and (memo[i - 1] == 1):
			ret.append(i)
	print(len(ret))
	for r in ret:
		print('{} {}'.format(r, n - r))


def permutationChecker(a):
	temp_dict = {}
	for f1 in a:
		if f1 not in temp_dict.keys():
			temp_dict[f1] = 1
		else:
			temp_dict[f1] += 1
	for f1 in range(1, max(temp_dict.keys()) + 1, 1):
		if f1 not in temp_dict.keys():
			return False
		elif temp_dict[f1] > 1:
			return False
	return True
testCases = int(input())
for i1 in range(testCases):
	length = int(input())
	numbers = list(map(int, input().split()))
	index = max(numbers)
	max_count = numbers.count(index)
	if max_count == 2:
		if length % 2 == 1:
			print(0)
		else:
			left = permutationChecker(numbers[0:length // 2])
			right = permutationChecker(numbers[length // 2:length])
			if left and right:
				print(1)
				print(length // 2, length // 2)
			else:
				print(0)
		continue
	left_included = permutationChecker(numbers[0:index])
	left_excluded = permutationChecker(numbers[0:length - index])
	right_excluded = permutationChecker(numbers[index:length])
	right_included = permutationChecker(numbers[length - index:length])
	result = 0
	solution = []
	if left_excluded and right_included:
		result += 1
		solution.append([length - index, index])
	if left_included and right_excluded:
		result += 1
		solution.append([index, length - index])
	if result == 0:
		print(0)
	else:
		print(result)
		for i2 in solution:
			print(i2[0], i2[1])


def give(n):
	return n * (n + 1) // 2
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = [0] * n
	sum = 0
	i = 0
	one = [0] * n
	while i <= n - 2:
		if b[a[i]]:
			break
		sum += a[i]
		b[a[i]] = 1
		if sum == give(i + 1):
			one[i] += i + 1
		i += 1
	k = 0
	this = []
	b = [0] * n
	sum = 0
	i = n - 1
	while i >= 1:
		if b[a[i]]:
			break
		sum += a[i]
		b[a[i]] = 1
		if sum == give(n - i):
			one[i - 1] += n - i
		i -= 1
	for i in range(n):
		if one[i] == n:
			k += 1
			this.append([i + 1, n - i - 1])
	print(k)
	for x in this:
		print(*x)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	pref = dict()
	suff = dict()
	mx = 0
	curr = set()
	for i in range(n):
		if a[i] > mx:
			mx = a[i]
		curr.add(a[i])
		if mx == i + 1 and len(curr) == i + 1:
			pref[i + 1] = True
		else:
			pref[i + 1] = False
	mx = 0
	curr = set()
	for i in range(n):
		j = n - i - 1
		if a[j] > mx:
			mx = a[j]
		curr.add(a[j])
		if mx == i + 1 and len(curr) == i + 1:
			suff[i + 1] = True
		else:
			suff[i + 1] = False
	k = 0
	ans = []
	for i in range(1, n + 1):
		if pref[i] and suff[n - i]:
			ans.append(str(i) + ' ' + str(n - i))
			k += 1
	print(k)
	for i in range(k):
		print(ans[i])


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ml = [0 for _ in range(n)]
	mr = [0 for _ in range(n)]
	mr[-1] = a[-1]
	ml[0] = a[0]
	for i in range(1, len(a)):
		ml[i] = max(ml[i - 1], a[i])
	for i in range(len(a) - 2, -1, -1):
		mr[i] = max(mr[i + 1], a[i])
	llegnth = [0 for _ in range(n)]
	rlength = [0 for _ in range(n)]
	temp = set()
	temp.add(a[0])
	llegnth[0] = 1
	for i in range(1, n):
		temp.add(a[i])
		llegnth[i] = len(temp)
	temp = set()
	temp.add(a[-1])
	rlength[-1] = 1
	for i in range(n - 2, -1, -1):
		temp.add(a[i])
		rlength[i] = len(temp)
	total = 0
	ans = []
	for i in range(0, n):
		if ml[i] == i + 1 and llegnth[i] == i + 1 and (mr[i + 1] == n - i - 1) and (rlength[i + 1] == n - i - 1):
			total += 1
			ans.append((i + 1, n - i - 1))
	print(total)
	for i in ans:
		print(i[0], i[1])


for _ in range(int(input())):
	n = int(input())
	a = input().split(' ')
	for i in range(n):
		a[i] = int(a[i])
	l1 = max(a)
	d = []
	for j in range(2):
		if set(a[:l1]) == set(range(1, l1 + 1)) and set(a[l1:]) == set(range(1, n - l1 + 1)):
			d.append(l1)
		l1 = n - l1
	d = set(d)
	print(len(d))
	if len(d) > 0:
		for i in d:
			print(i, n - i)


import sys
input = sys.stdin.buffer.readline
for _ in range(int(input())):
	n = int(input())
	(*a,) = map(int, input().split())
	ok = [0] * n
	okrev = [0] * n
	ma = le = 0
	se = set()
	for (i, x) in enumerate(a):
		if x not in se:
			se.add(x)
			le += 1
		if x > ma:
			ma = x
		if ma == le == i + 1:
			ok[i] = 1
	ma = le = 0
	se = set()
	for (i, x) in enumerate(a[::-1]):
		if x not in se:
			se.add(x)
			le += 1
		if x > ma:
			ma = x
		if ma == le == i + 1:
			okrev[i] = 1
	c = 0
	ans = []
	for i in range(n - 1):
		if ok[i] and okrev[n - i - 2]:
			c += 1
			ans.append('{} {}'.format(i + 1, n - i - 1))
	print(c)
	if c:
		print('\n'.join(ans))


def scanleft(ls, N, offset=0):
	n = offset
	occurences = [0 for i in range(N)]
	mxm = 0
	(l1, l2) = (-1, -1)
	while n < N:
		a = ls[n]
		if occurences[a] == 1:
			if sum(occurences) < mxm:
				break
			l1 = n
			l2 = scanright(ls, N, n)
			break
		mxm = max(mxm, a)
		occurences[a] += 1
		n += 1
	return (l1, l2)

def scanright(ls, N, offset=0):
	n = offset
	occurences = [0 for i in range(N)]
	while n < N:
		a = ls[n]
		if occurences[a] == 1 or a > N - offset:
			return -1
		occurences[a] += 1
		n += 1
	return N - offset
T = int(input())
for test in range(T):
	N = int(input())
	alist = list(map(int, input().split()))
	(l1f, l2f) = scanleft(alist, N)
	alist.reverse()
	(l2r, l1r) = scanleft(alist, N)
	soln = [0, 0]
	if l1f >= 0 and l2f >= 0:
		soln[0] = 1
	if l1r >= 0 and l2r >= 0 and (l1f != l1r):
		soln[1] = 1
	print(sum(soln))
	if soln[0] == 1:
		print(l1f, l2f)
	if soln[1] == 1:
		print(l1r, l2r)


def solve(n, arr):
	left = [0 for _ in range(n)]
	right = [0 for _ in range(n)]
	mySet = set()
	maxInSet = float('-inf')
	for i in range(n):
		num = arr[i]
		if num in mySet:
			break
		mySet.add(num)
		maxInSet = max(maxInSet, num)
		if maxInSet == len(mySet):
			left[i] = 1
	mySet = set()
	maxInSet = float('-inf')
	for i in range(n - 1, -1, -1):
		num = arr[i]
		if num in mySet:
			break
		mySet.add(num)
		maxInSet = max(maxInSet, num)
		if maxInSet == len(mySet):
			right[i] = 1
	ans = set()
	for i in range(n - 1):
		if left[i] == 1 and right[i + 1] == 1:
			ans.add((i + 1, n - (i + 1)))
	return ans
t = int(input().strip())
for _ in range(t):
	n = int(input().strip())
	arr = list(map(int, input().strip().split()))
	ans = solve(n, arr)
	print(len(ans))
	for a in ans:
		print(a[0], a[1])


import sys
import math
import collections

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

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

def get_string():
	return sys.stdin.readline().strip()
for t in range(int(input())):
	n = int(input())
	A = get_list()
	count = 0
	ans = []
	m = max(A)
	if m >= n:
		print(0)
	else:
		p1a = A[:m]
		p2a = A[m:]
		p1b = A[:n - m]
		p2b = A[n - m:]
		if len(set(p1a)) == m == max(p1a) and len(set(p2a)) == n - m == max(p2a):
			ans.append(m)
			count += 1
		if len(set(p1b)) == n - m == max(p1b) and len(set(p2b)) == m == max(p2b) and (m != n - m):
			ans.append(n - m)
			count += 1
		print(count)
		for i in ans:
			print(i, n - i)


def check(l):
	l.sort()
	return len(l) > 0 and all((i + 1 == l[i] for i in range(len(l))))
for _ in range(int(input())):
	a = [list(map(int, input().split())) for i in '..'][1]
	(mx, n) = (max(a), len(a))
	res = set()
	if check(a[:mx]) and check(a[mx:]):
		res.add((mx, n - mx))
	if check(a[:n - mx]) and check(a[n - mx:]):
		res.add((n - mx, mx))
	print(len(res))
	for r in res:
		print(*r)


import sys

class BDreamoonLikesPermutations:

	def solve(self):
		for _ in range(int(input())):

			def is_perm(a):
				return len(set(a)) == len(a) and min(a) == 1 and (max(a) == len(a))
			n = int(input())
			a = [int(_) for _ in input().split()]
			done = set()
			ans = set()
			i = 0
			for i in range(n):
				if a[i] in done:
					break
				done.add(a[i])
			if is_perm(a[:i]) and is_perm(a[i:]):
				ans.add((i, n - i))
			done = set()
			for i in range(n - 1, -1, -1):
				if a[i] in done:
					break
				done.add(a[i])
			if is_perm(a[:i + 1]) and is_perm(a[i + 1:]):
				ans.add((i + 1, n - i - 1))
			print(len(ans))
			for sol in ans:
				print(*sol)
solver = BDreamoonLikesPermutations()
input = sys.stdin.readline
solver.solve()


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	maxx = max(l)
	a = n - maxx
	d1 = {}
	d2 = {}
	for j in range(1, a + 1):
		d1[j] = 0
	for j in range(1, maxx + 1):
		d2[j] = 0
	for j in range(n):
		if j < a:
			if d1.get(l[j]) != None:
				d1[l[j]] += 1
		elif d2.get(l[j]) != None:
			d2[l[j]] += 1
	check1 = 0
	for j in d1:
		if d1[j] == 0 or d1[j] > 1:
			check1 = 1
			break
	for j in d2:
		if d2[j] == 0 or d2[j] > 1:
			check1 = 1
			break
	d1 = {}
	d2 = {}
	for j in range(1, maxx + 1):
		d1[j] = 0
	for j in range(1, a + 1):
		d2[j] = 0
	for j in range(n):
		if j < maxx:
			if d1.get(l[j]) != None:
				d1[l[j]] += 1
		elif d2.get(l[j]) != None:
			d2[l[j]] += 1
	check2 = 0
	if a == maxx:
		check2 = 1
	for j in d1:
		if d1[j] == 0 or d1[j] > 1:
			check2 = 1
			break
	for j in d2:
		if d2[j] == 0 or d2[j] > 1:
			check2 = 1
			break
	if check1 == 0 and check2 == 0:
		print(2)
	elif check1 == 0 or check2 == 0:
		print(1)
	else:
		print(0)
	if check1 == 0:
		print(a, end=' ')
		print(maxx)
	if check2 == 0:
		print(maxx, end=' ')
		print(a)


import sys
import math

def fn(n, a):
	l2 = max(a)
	l1 = n - l2
	m2 = []
	if l2 >= n:
		print(0)
		return 0
	for i in range(1, l2 + 1):
		m2.append(i)
	m1 = []
	for i in range(1, l1 + 1):
		m1.append(i)
	a1 = a[:l2]
	a2 = a[l2:]
	b1 = a[:l1]
	b2 = a[l1:]
	a1.sort()
	a2.sort()
	b1.sort()
	b2.sort()
	flag = 0
	c = 0
	if m2 == a1 and m1 == a2:
		flag = 1
		c = c + 1
	if m1 == b1 and m2 == b2:
		flag = 2
		c = c + 1
	if l1 == l2 and c == 2:
		print(1)
		print(l1, l2)
		return 0
	if c == 0:
		print(0)
	elif c == 2:
		print(2)
		print(l1, l2)
		print(l2, l1)
		return 0
	elif c == 1:
		print(1)
		if flag == 1:
			print(l2, l1)
		else:
			print(l1, l2)
		return 0
input = sys.stdin.read()
data = list(map(int, input.split()))
t = data[0]
l = 0
for i in range(t):
	n = data[l + 1]
	a = data[l + 2:l + 2 + n]
	l = l + 1 + n
	fn(n, a)


t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	c = 0
	cs = 0
	ca = [0] * n
	csa = [0] * n
	for i in range(n):
		c += a[i]
		cs += a[i] * a[i] * a[i]
		ca[i] = c
		csa[i] = cs
	count = 0
	ans = []
	for i in range(n - 1):
		N = i + 1
		k = n - N
		if ca[i] == N * (N + 1) // 2 and ca[-1] - ca[i] == k * (k + 1) // 2 and (csa[i] == N * (N + 1) // 2 * (N * (N + 1) // 2)) and (csa[-1] - csa[i] == k * (k + 1) // 2 * (k * (k + 1) // 2)):
			count += 1
			ans.append([N, k])
	print(count)
	for i in ans:
		print(*i)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	li1 = [0] * n
	lc1 = [0] * n
	s = 0
	for i in range(n - 1):
		s += l[i]
		li1[l[i]] += 1
		if li1[l[i]] > 1:
			break
		if s == (i + 1) * (i + 2) // 2:
			lc1[i] = 1
	li1 = [0] * n
	k = 1
	l1 = []
	l2 = []
	ans = 0
	s = 0
	for i in range(n - 1, 0, -1):
		s += l[i]
		li1[l[i]] += 1
		if li1[l[i]] > 1:
			break
		if s == k * (k + 1) // 2 and lc1[i - 1] == 1:
			ans += 1
			l1.append(i)
			l2.append(n - i)
		k += 1
	print(ans)
	if ans != 0:
		for i in range(len(l1)):
			print(l1[i], l2[i])


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	mas = [0 for i in range(n)]
	for i in range(n):
		mas[a[i] - 1] += 1
	boo = 1
	n1 = n
	ind = 0
	while n1 != 0:
		if mas[ind] == 0:
			boo = 0
		n1 -= mas[ind]
		ind += 1
	if boo == 0:
		print(0)
		continue
	maxx = -1
	xex = max(a)
	if max(mas) > 2:
		print(0)
		continue
	while mas[maxx + 1] == 2:
		maxx += 1
	if mas.count(2) != maxx + 1:
		print(0)
		continue
	ans = []
	lol = [0 for i in range(n)]
	for i in range(maxx + 1):
		lol[a[i] - 1] += 1
	boo = 1
	for i in range(maxx + 1):
		if lol[i] != 1:
			boo = 0
	if boo == 1 and maxx != -1:
		ans.append([maxx + 1, xex])
	for i in range(maxx + 1, xex):
		lol[a[i] - 1] += 1
	boo = 1
	for i in range(xex):
		if lol[i] != 1:
			boo = 0
	if boo == 1 and maxx != -1:
		ans.append([xex, maxx + 1])
	if len(ans) == 2:
		if ans[1] == ans[0]:
			ans.pop()
	print(len(ans))
	for i in ans:
		print(*i)


from sys import stdin, stdout

def check(a, m, n):
	b = []
	for i in range(1, n - m + 1):
		b.append(i)
	c = []
	for i in range(m, n):
		c.append(a[i])
	if sorted(c) == b:
		return True
	return False

def f(a, n):
	answ = []
	ans = 0
	ma = max(a)
	b = []
	c = []
	if ma < n:
		for i in range(ma):
			b.append(a[i])
			c.append(i + 1)
		if sorted(b) == c and check(a, ma, n):
			ans += 1
			answ.append([ma, n - ma])
		a = a[::-1]
		b = []
		for i in range(ma):
			b.append(a[i])
		if sorted(b) == c and check(a, ma, n):
			if n - ma != ma:
				ans += 1
				answ.append([n - ma, ma])
		print(ans)
		if answ:
			for i in answ:
				print(i[0], i[1], sep=' ')
	else:
		print(0)
t = int(input())
for i in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	f(a, n)


from math import *
from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(n, a) = (int(input()), list(map(int, input().split())))
	(m, li) = (max(a), [])
	for i in {m, n - m}:
		if sorted(a[:i]) + sorted(a[i:]) == [*range(1, i + 1), *range(1, n - i + 1)]:
			li.append(i)
	print(len(li))
	for i in li:
		print(i, n - i)


def chqperm(t, n):
	s = set()
	for i in range(1, n + 1):
		s.add(i)
	return t == s
for _ in range(int(input())):
	a = int(input())
	b = list(map(int, input().split()))
	v = []
	mx = 0
	for i in range(a):
		mx = max(mx, b[i])
	if mx >= a:
		print(0)
	else:
		if chqperm(set(b[:mx]), mx) and chqperm(set(b[mx:]), a - mx):
			v.append([mx, a - mx])
		if mx != a / 2:
			if chqperm(set(b[:a - mx]), a - mx) and chqperm(set(b[a - mx:]), mx):
				v.append([a - mx, mx])
	print(len(v))
	for j in v:
		print(*j)


T = int(input())
for case in range(T):
	m = int(input())
	ls = [int(x) for x in input().split()]
	ma = 0
	p = set()
	pn = set()
	negn = set()
	neg = set()
	for (n, e) in enumerate(ls):
		ma = max(ma, e)
		pn.add(e)
		if ma == n + 1 and len(pn) == ma:
			p.add(n + 1)
	ls = ls[::-1]
	ma = 0
	for (n, e) in enumerate(ls):
		ma = max(ma, e)
		negn.add(e)
		if ma == n + 1 and len(negn) == ma:
			neg.add(n + 1)
	ret = []
	for i in range(1, m):
		if i in p and m - i in neg:
			ret.append(i)
	print(len(ret))
	for r in ret:
		print(r, m - r)


from collections import Counter

def solve():
	n = int(input())
	l1 = list(map(int, input().split()))
	d = Counter(l1)
	v1 = list(d.keys())
	c = 0
	sum1 = sum(l1)
	kk = []
	xx = 0
	for i in range(len(v1)):
		if d[v1[i]] == 2:
			c = c + 1
	s2 = len(d)
	f1 = (c + 1) * c // 2
	f2 = (s2 + 1) * s2 // 2
	a = sum(l1[0:c])
	b = sum1 - a
	if f1 == a and f2 == b and (a + b == sum1) and (c + s2 == n):
		xx += 1
		kk.append(c)
		kk.append(s2)
	a1 = sum(l1[0:s2])
	b1 = sum1 - a1
	if a1 == f2 and b1 == f1 and (a + b == sum1) and (c + s2 == n):
		xx = xx + 1
		kk.append(s2)
		kk.append(c)
	if s2 == c:
		if xx > 0:
			xx = xx - 1
			kk.pop()
			kk.pop()
	print(xx)
	for i in range(0, len(kk), 2):
		print(kk[i], kk[i + 1])
for _ in range(int(input())):
	solve()


def findRepeating(arr):
	s = set()
	for i in range(len(arr)):
		if arr[i] in s:
			return arr[i]
		s.add(arr[i])
	return -1

def check_elements(arr, n, A, B):
	rangeV = B - A
	for i in range(0, n):
		if abs(arr[i]) >= A and abs(arr[i]) <= B:
			z = abs(arr[i]) - A
			if arr[z] > 0:
				arr[z] = arr[z] * -1
	count = 0
	for i in range(0, rangeV + 1):
		if i >= n:
			break
		if arr[i] > 0:
			return False
		else:
			count = count + 1
	if count != rangeV + 1:
		return False
	return True
for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	A = 1
	B = max(arr)
	a = 0
	if B * 2 != n and check_elements(arr[0:B], B, A, B) and check_elements(arr[B:n], n - B, A, n - B):
		if findRepeating(arr[0:B]) == -1 and findRepeating(arr[B:n]) == -1:
			a = a + 1
	if check_elements(arr[0:n - B], n - B, A, n - B) and check_elements(arr[n - B:n], B, A, B):
		if findRepeating(arr[0:n - B]) == -1 and findRepeating(arr[n - B:n]) == -1:
			a = a + 1
	print(a)
	if check_elements(arr[0:n - B], n - B, A, n - B) and check_elements(arr[n - B:n], B, A, B):
		if findRepeating(arr[0:n - B]) == -1 and findRepeating(arr[n - B:n]) == -1:
			print(n - B, B)
	if B * 2 != n and check_elements(arr[0:B], B, A, B) and check_elements(arr[B:n], n - B, A, n - B):
		if findRepeating(arr[0:B]) == -1 and findRepeating(arr[B:n]) == -1:
			print(B, n - B)


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	pre_arr = [0] * n
	for i in range(n):
		if i == 0:
			pre_arr[i] = arr[i]
		else:
			pre_arr[i] = pre_arr[i - 1] + arr[i]
	Dict = defaultdict(int)
	Dict1 = defaultdict(int)
	dist = [0] * n
	for i in range(n):
		if Dict[arr[i]] == 0:
			dist[i] = dist[i - 1] + 1
			Dict[arr[i]] = 1
		else:
			dist[i] = dist[i - 1]
	dist1 = [0] * n
	for i in range(n - 1, -1, -1):
		if Dict1[arr[i]] == 0:
			if i == n - 1:
				dist1[i] = 1
			else:
				dist1[i] = dist1[i + 1] + 1
			Dict1[arr[i]] = 1
		else:
			dist1[i] = dist1[i + 1]
	ans = 0
	lis = []
	for i in range(1, n):
		temp1 = pre_arr[i - 1]
		temp2 = pre_arr[n - 1] - pre_arr[i - 1]
		che1 = i * (i + 1) // 2
		che2 = (n - i) * (n - i + 1) // 2
		if (temp1 == che1 and dist[i - 1] == i) and (temp2 == che2 and dist1[i] == n - i):
			lis.append((i, n - i))
			ans += 1
	print(ans)
	if len(lis) > 0:
		for i in lis:
			print(i[0], i[1])


import math
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	m = max(l)
	s1 = list(set(l))
	if l.count(1) != 2:
		print(0)
	elif m == n:
		print(0)
	else:
		count = 0
		max1 = max(l)
		max2 = n - max1
		l1 = l[0:max1]
		l1.sort()
		l2 = l[max1:]
		l2.sort()
		l3 = l[0:max2]
		l3.sort()
		l4 = l[max2:]
		l4.sort()
		p1 = list((i for i in range(1, max1 + 1)))
		p2 = list((j for j in range(1, max2 + 1)))
		if l1 == p1 and l2 == p2:
			count += 1
			k = max1
		if l3 == p2 and l4 == p1:
			count += 1
			k = max2
		if p1 == p2 and count > 0:
			count = 1
		print(count)
		if count == 1:
			print(k, n - k)
		if count == 2:
			print(max1, max2)
			print(max2, max1)
			l


def check(temp):
	vis = [-1] * temp
	for i in range(temp):
		if l[i] - 1 < len(vis) and l[i] - 1 >= 0:
			vis[l[i] - 1] = 1
	vis2 = [-1] * (len(l) - temp)
	for i in range(temp, len(l)):
		if l[i] - 1 < len(vis2) and l[i] - 1 >= 0:
			vis2[l[i] - 1] = 1
	if -1 in vis or -1 in vis2:
		return False
	return True
for nt in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	v = [-1] * n
	ans = []
	s = sum(l)
	s1 = l[0]
	s2 = s - s1
	for i in range(1, n):
		if s1 == i * (i + 1) // 2 and s2 == (n - i) * (n - i + 1) // 2:
			if check(i):
				ans.append(i)
		s1 += l[i]
		s2 -= l[i]
	print(len(ans))
	for i in ans:
		print(i, n - i)


import sys
input = sys.stdin.readline
t = int(input())
for r in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in l:
		try:
			d[i] += 1
		except:
			d[i] = 1
	flag = True
	length = len(d)
	for i in range(1, length + 1):
		try:
			if d[i] > 2:
				flag = False
				break
		except:
			flag = False
	if flag == False:
		print(0)
	else:
		summ = 0
		for i in l:
			summ += i
		sum_d = {}
		sum_d[1] = 1
		length += 1
		for i in range(2, length):
			sum_d[i] = i + sum_d[i - 1]
		current = 0
		ans = []
		for i in range(n - 1):
			current += l[i]
			try:
				if sum_d[i + 1] == current and sum_d[n - i - 1] == summ - current:
					ans.append([i + 1, n - i - 1])
			except:
				pass
		print(len(ans))
		for i in ans:
			print(str(i[0]) + ' ' + str(i[1]))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().strip().split()))
	r1 = max(a)
	ans = 0
	r2 = n - r1
	if r1 == n:
		print(0)
	else:
		g = 0
		k = 0
		x = sorted(a[:r1])
		y = sorted(a[r1:])
		z = sorted(a[:r2])
		w = sorted(a[r2:])
		p1 = [i + 1 for i in range(r1)]
		p2 = [j + 1 for j in range(r2)]
		if x == p1 and y == p2:
			ans += 1
			k = r1
		if z == p2 and w == p1:
			ans += 1
			k = r2
		if r1 == r2 and ans > 0:
			g = 1
			ans = 1
		print(ans)
		if ans == 1:
			print(k, n - k)
		if ans == 2:
			print(r1, r2)
			print(r2, r1)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	count = {}
	for j in a:
		if j not in count:
			count[j] = 1
		else:
			count[j] += 1
	failed = False
	two = 0
	for j in count.keys():
		if count[j] > 2:
			failed = True
			break
		if count[j] == 2:
			two += 1
	missing = max(a)
	if failed == True or two == 0 or len(count) < max(a):
		print(0)
	else:
		answer1 = 0
		count1 = [0] * missing
		for j in a[:missing]:
			if j <= len(count1):
				count1[j - 1] += 1
		count2 = [0] * (n - missing)
		for j in a[missing:]:
			if j <= len(count2):
				count2[j - 1] += 1
		if min(count1) == 1 and max(count1) == 1 and (min(count2) == 1) and (max(count2) == 1):
			answer1 = 1
		del count1, count2
		answer2 = 0
		count1 = [0] * (n - missing)
		for j in a[:n - missing]:
			if j <= len(count1):
				count1[j - 1] += 1
		count2 = [0] * missing
		for j in a[n - missing:]:
			if j <= len(count2):
				count2[j - 1] += 1
		if min(count1) == 1 and max(count1) == 1 and (min(count2) == 1) and (max(count2) == 1):
			answer2 = 1
		del count1, count2
		if answer1 == 1 and answer2 == 1 and (missing != n - missing):
			print(2)
			print(missing, n - missing)
			print(n - missing, missing)
		elif answer1 == 1:
			print(1)
			print(missing, n - missing)
		elif answer2 == 1:
			print(1)
			print(n - missing, missing)
		else:
			print(0)


def check(a, l1):
	p1 = set(a[:l1])
	p2 = set(a[l1:])
	return p1 == set(range(1, l1 + 1)) and p2 == set(range(1, len(a) - l1 + 1))
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	m = max(a)
	if check(a, m):
		ans.append((m, n - m))
	if check(a, n - m):
		ans.append((n - m, m))
	if len(ans) == 2 and ans[0] == ans[1]:
		ans.pop()
	print(len(ans))
	for x in ans:
		print(*x)


import sys, math, cmath, time
start_time = time.time()

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

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

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

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

def solve():
	n = inp()
	a = inlt()
	(j, k) = (0, 0)
	q = [0] * (n + 1)
	w = [0] * (n + 2)
	qw = []
	for i in range(n):
		if w[a[i]] == 1:
			break
		k = max(k, a[i])
		w[a[i]] = 1
		if k == j + 1:
			q[i + 1] = 1
		j = j + 1
	(j, k) = (0, 0)
	w = [0] * (n + 2)
	for i in range(n, 1, -1):
		if w[a[i - 1]] == 1:
			break
		k = max(k, a[i - 1])
		w[a[i - 1]] = 1
		if k == j + 1 and q[i - 1] == 1:
			qw.append([i - 1, n - i + 1])
		j = j + 1
	print(len(qw))
	for i in range(len(qw)):
		print(*qw[i])
ONLINE_JUDGE = __debug__
if not ONLINE_JUDGE:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = sys.stdin.readline
t = 1
t = inp()
for tt in range(t):
	solve()
if not ONLINE_JUDGE:
	print('Time Elapsed:', time.time() - start_time, 'seconds')
sys.stdout.close()


from sys import stdin
input = stdin.readline
t = int(input())
for i in range(t):
	n = int(input())
	A = [int(j) for j in input().strip().split()]
	maxi = max(A)
	x = n - maxi
	a = maxi * (maxi + 1) // 2
	b = x * (x + 1) // 2
	if sum(A) != a + b or maxi >= n:
		print(0)
		continue
	pk = []
	if sum(set(A[:x])) == b and sum(set(A[x:])) == a:
		pk.append((x, maxi))
	if x != maxi and sum(set(A[:maxi])) == a and (sum(set(A[maxi:])) == b):
		pk.append((maxi, x))
	print(len(pk))
	for j in pk:
		print(j[0], j[1])


import sys
for _ in range(int(sys.stdin.readline())):
	n = int(sys.stdin.readline())
	a = list(map(int, sys.stdin.readline().split()))
	count = [0] * n
	for i in range(n):
		count[a[i] - 1] += 1
	if 2 not in count:
		print(0)
		continue
	l1 = max([i + 1 for i in range(n) if count[i] == 2])
	l2 = n - l1
	num = 0
	tup = []
	if sorted(a[:l1]) == list(range(1, l1 + 1)) and sorted(a[l1:l1 + l2]) == list(range(1, l2 + 1)):
		num += 1
		tup.append([l1, l2])
	if l1 == l2:
		print(num)
		for x in tup:
			print(*x)
		continue
	(l1, l2) = (l2, l1)
	if sorted(a[:l1]) == list(range(1, l1 + 1)) and sorted(a[l1:l1 + l2]) == list(range(1, l2 + 1)):
		num += 1
		tup.append([l1, l2])
	print(num)
	for x in tup:
		print(*x)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	dpF = [0 for i in range(n)]
	dpB = [0 for i in range(n)]
	noRep = 1
	r = {}
	m = 0
	for i in range(n):
		if r.get(a[i]) == None:
			r[a[i]] = 1
			m = max(m, a[i])
			if m == i + 1:
				dpF[i] = 1
		else:
			break
	r = {}
	m = 0
	for i in range(n - 1, -1, -1):
		if r.get(a[i]) == None:
			r[a[i]] = 1
			m = max(m, a[i])
			if m == n - i:
				dpB[i] = 1
		else:
			break
	ans = 0
	ansList = []
	for i in range(n - 1):
		if dpF[i] == 1 and dpB[i + 1] == 1:
			ans += 1
			ansList.append([i + 1, n - i - 1])
	print(ans)
	for i in ansList:
		print(i[0], i[1])


for ii in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	mv = max(arr)
	total = sum(arr)
	s = 0
	ans = []
	for i in range(n):
		s += arr[i]
		total -= arr[i]
		(p1, p2) = (i + 1, n - i - 1)
		if s == p1 * (p1 + 1) // 2 and total == p2 * (p2 + 1) // 2 and (len(set(arr[:p1])) == p1) and (len(set(arr[p1:])) == p2):
			ans.append([p1, p2])
	print(len(ans))
	for i in ans:
		print(i[0], i[1])


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	pre = [0]
	suf = [0]
	d5 = {}
	d6 = {}
	for t in l:
		if d5.get(t, 0) == 1:
			break
		d5[t] = 1
		x = pre[-1] + t
		pre.append(x)
	for t in l[::-1]:
		if d6.get(t, 0) == 1:
			break
		d6[t] = 1
		x = suf[-1] + t
		suf.append(x)
	p1 = []
	p2 = []
	for t in range(1, len(pre)):
		if pre[t] == t * (t + 1) // 2:
			p1.append(t)
	for t in range(1, len(suf)):
		if suf[t] == t * (t + 1) // 2:
			p2.append(n - t + 1)
	if len(p1) == 0 or len(p2) == 0:
		print(0)
	else:
		d = {}
		ans = []
		for t in p2:
			d[t] = 1
		for t in p1:
			if d.get(t + 1, 0) == 1:
				ans.append([t, n - t])
		print(len(ans))
		for t in ans:
			print(*t)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	x = max(l)
	k = n - x
	c = 0
	a = []
	p = [0] * (n - x)
	q = [0] * x
	for i in range(n):
		try:
			if i < n - x:
				p[l[i] - 1] = 1
			else:
				q[l[i] - 1] = 1
		except:
			break
	if sum(p) == n - x and sum(q) == x:
		c += 1
		a += [n - x, x]
	p = [0] * x
	q = [0] * (n - x)
	for i in range(n):
		try:
			if i < x:
				p[l[i] - 1] = 1
			else:
				q[l[i] - 1] = 1
		except:
			break
	if sum(p) == x and sum(q) == n - x:
		c += 1
		a += [x, n - x]
	print(c if c < 2 else c - int(a[0] == a[2]))
	if a != []:
		print(a[0], a[1])
		if len(a) == 4 and a[0] != a[2]:
			print(a[2], a[3])


ttt = int(input())
for tttt in range(ttt):
	n = int(input())
	a = list(map(int, input().split(' ')))

	def isperm(p):
		sp = set(p)
		if len(p) == len(sp):
			if max(p) == len(sp):
				return True
			else:
				return False
		else:
			return False
	m = max(a)
	k = 0
	ansl1 = []
	if a.count(m) == 1:
		if isperm(a[0:m]) and isperm(a[m:len(a)]):
			k += 1
			ansl1.append(m)
		if isperm(a[0:len(a) - m]) and isperm(a[len(a) - m:len(a)]):
			k += 1
			ansl1.append(len(a) - m)
		if k == 0:
			print(0)
		if k == 1:
			print(1)
			print(str(ansl1[0]) + ' ' + str(len(a) - ansl1[0]))
		if k == 2:
			print(2)
			print(str(ansl1[0]) + ' ' + str(len(a) - ansl1[0]))
			print(str(ansl1[1]) + ' ' + str(len(a) - ansl1[1]))
	elif a.count(m) == 2:
		if len(a) == m + m:
			if isperm(a[0:m]) and isperm(a[m:len(a)]):
				print(1)
				print(str(m) + ' ' + str(m))
			else:
				print(0)
		else:
			print(0)
	else:
		print(0)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	maxNum = max(a)
	counts = [0] * (maxNum + 1)
	for x in a:
		counts[x] += 1
	possible = True
	if counts[1] != 2:
		possible = False
	l1 = 1
	if possible:
		while l1 < len(counts) and counts[l1] == 2:
			l1 += 1
	for i in range(l1, maxNum + 1):
		if counts[i] != 1:
			possible = False
	l1 -= 1
	answers = []
	repeatCheck = set()
	if possible:
		maxTill = 0
		for (idx, i) in enumerate(a):
			if i in repeatCheck:
				break
			repeatCheck.add(i)
			maxTill = max(maxTill, i)
			if maxTill == idx + 1:
				if maxTill in [l1, maxNum]:
					answers.append((maxTill, n - maxTill))
	print(len(answers))
	for x in answers:
		print(x[0], x[1])


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	array = list(map(int, input().split()))
	ma = max(array)
	x = 0
	res = []
	if set(array[:ma]) == set(range(1, ma + 1)) and set(array[ma:]) == set(range(1, n - ma + 1)):
		x += 1
		res.append((ma, n - ma))
	if ma * 2 != n:
		if set(array[:n - ma]) == set(range(1, n - ma + 1)) and set(array[-ma:]) == set(range(1, ma + 1)):
			x += 1
			res.append((n - ma, ma))
	if x == 0:
		print(0)
	else:
		print(x)
		for r in res:
			print(*r)


a = int(input())
for i in range(a):
	n = int(input())
	l = list(map(int, input().split()))
	k = max(l)
	c = []
	for i2 in {k, n - k}:
		if set(l[:i2]) == set((j + 1 for j in range(i2))) and set(l[i2:]) == set((j + 1 for j in range(n - i2))):
			c.append(i2)
	print(len(c))
	for ans in c:
		print(ans, n - ans)


for _ in range(int(input())):
	n = int(input())
	b = [int(i) for i in input().split()]
	a = [0]
	c = [0]
	ans = []
	for i in range(1, n + 1):
		a += [a[-1] + i]
		c += [c[-1] + b[i - 1]]
	used = [0 for i in range(max(b) + 1)]
	for i in range(1, n):
		if used[b[i - 1]] == 0:
			if c[i] == a[i] and c[n] - c[i] == a[n - i] and (n - i == len(set(b[i:]))):
				ans += [[i, n - i]]
			used[b[i - 1]] = 1
		else:
			break
	print(len(ans))
	for (x, y) in ans:
		print(x, y)


t = int(input())

def check_permute(a, n):
	num = set()
	for i in range(n):
		if a[i] not in num:
			num.add(a[i])
		else:
			return False
	return True
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	pref_a = [a[0]] * n
	suff_a = [a[-1]] * n
	for i in range(1, n):
		pref_a[i] = pref_a[i - 1] + a[i]
	for i in range(n - 2, -1, -1):
		suff_a[i] = suff_a[i + 1] + a[i]
	ans = []
	for i in range(n - 1):
		l1 = i + 1
		l2 = n - l1
		if pref_a[i] == l1 * (l1 + 1) // 2 and suff_a[i + 1] == l2 * (l2 + 1) // 2:
			res1 = check_permute(a[:l1], l1)
			res2 = check_permute(a[l1:], l2)
			if res1 and res2:
				ans.append([l1, l2])
	print(len(ans))
	for res in ans:
		print(res[0], res[1])


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	d = dict()
	demand = 1
	pre = [0] * n
	post = [0] * n
	for i in range(n):
		d[arr[i]] = 1
		if demand in d:
			while demand in d:
				demand += 1
			pre[i] = demand - 1
	d2 = dict()
	demand = 1
	for i in range(n - 1, -1, -1):
		d2[arr[i]] = 1
		if demand in d2:
			while demand in d2:
				demand += 1
			post[i] = demand - 1
	l = []
	for i in range(1, n):
		if post[i] + pre[i - 1] == n:
			l += [[pre[i - 1], post[i]]]
	print(len(l))
	for i in l:
		print(*i)


input = __import__('sys').stdin.readline
for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	pre = [0] * (n + 1)
	has = [0] * (n + 2)
	j = 0
	k = 0
	for i in range(1, n + 1):
		if has[lis[i - 1]] == 1:
			break
		has[lis[i - 1]] = 1
		j += 1
		k = max(k, lis[i - 1])
		if k == j:
			pre[i] = 1
	j = 0
	k = 0
	has = [0] * (n + 2)
	ans = []
	for i in range(n - 1, 0, -1):
		if has[lis[i]] == 1:
			break
		has[lis[i]] = 1
		k = max(k, lis[i])
		j += 1
		if k == j and pre[i] == 1:
			ans.append([i, n - i])
	print(len(ans))
	for i in ans:
		print(*i)


t = int(input())

def is_perm(s):
	st = set(s)
	for i in range(1, len(s) + 1):
		if i not in st:
			return False
	return True
for _ in range(t):
	input()
	arr = list(map(int, input().split()))
	sm = sum(arr)
	ans = list()
	left = 0
	for idx in range(len(arr) - 1):
		v = arr[idx]
		left += v
		must_left = (idx + 2) * (idx + 1) // 2
		right = sm - left
		must_right = (len(arr) - idx) * (len(arr) - idx - 1) // 2
		if must_left == left and right == must_right:
			if is_perm(arr[:idx + 1]) and is_perm(arr[idx + 1:]):
				ans.append((idx + 1, len(arr) - idx - 1))
	print(len(ans))
	for a in ans:
		print(*a)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	used = [0] * n
	k = 0
	v = []
	t = 2
	while t:
		for i in range(n):
			if used[a[i] - 1]:
				l = a[i:]
				if sum(used[:i]) == i and len(set(l)) == n - i and (max(l) == n - i):
					k += 1
					if t == 1:
						v.append([i, n - i][::-1])
						if len(v) == 2 and v[0] == v[1]:
							k -= 1
							del v[1]
					else:
						v.append([i, n - i])
				break
			else:
				used[a[i] - 1] = 1
		t -= 1
		a = a[::-1]
		used = [0] * n
	if k:
		print(k)
		for num in v:
			print(*num)
	else:
		print(0)


import math
for ii in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	a = max(l)
	if a >= len(l):
		print(0)
	else:
		x = l[0:a]
		y = l[a:]
		ans = []
		count = 0
		if sorted(x) == [int(i + 1) for i in range(len(x))] and sorted(y) == [int(i + 1) for i in range(len(y))]:
			count += 1
			ans.append([a, n - a])
		x = l[0:n - a]
		y = l[n - a:n]
		if sorted(x) == [int(i + 1) for i in range(len(x))] and sorted(y) == [int(i + 1) for i in range(len(y))]:
			count += 1
			ans.append([n - a, a])
		if a == n // 2 + n % 2 / 2 and count == 2:
			print(1)
			print(*ans[0])
		else:
			print(count)
			for i in ans:
				print(*i)


from collections import defaultdict
from sys import stdin, stdout

def write(_s):
	stdout.write(_s)

def write_int(_s):
	stdout.write(str(_s))

def write_list(_l):
	stdout.write(' '.join(map(str, _l)))

def read():
	return stdin.readline().split(' ')

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

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

def check_numbers(array):
	sort = sorted(array)
	for i in range(len(array)):
		if sort[i] != i + 1:
			return False
	return True
t = readint()
while t:
	n = readint()
	a = list(read_int_l())
	max_val = max(a)
	first = False
	if check_numbers(a[:max_val]) and check_numbers(a[max_val:]):
		first = True
	second = False
	if max_val != n - max_val and check_numbers(a[:n - max_val]) and check_numbers(a[n - max_val:]):
		second = True
	write_int(first + second)
	write('\n')
	if first:
		write_list([max_val, n - max_val])
		write('\n')
	if second:
		write_list([n - max_val, max_val])
		write('\n')
	t -= 1


from collections import defaultdict

def soln(arr):
	uniqueFromFront = [False for _ in arr]
	uniqueFromBack = [False for _ in arr]
	prefixSums = [0]
	going = True
	forwardTable = defaultdict(int)
	for (i, elem) in enumerate(arr):
		if elem in forwardTable:
			going = False
		elif going:
			uniqueFromFront[i] = True
		if going:
			forwardTable[elem] += 1
		prefixSums.append(prefixSums[-1] + elem)
	backwardTable = defaultdict(int)
	for i in range(len(arr) - 1, -1, -1):
		elem = arr[i]
		if elem in backwardTable:
			break
		else:
			uniqueFromBack[i] = True
		backwardTable[elem] += 1

	def rangedSum(l, r):
		return prefixSums[r + 1] - prefixSums[l]

	def ascSum(n):
		return n * (n + 1) // 2
	result = []
	for i in range(1, len(arr)):
		if uniqueFromFront[i - 1] and uniqueFromBack[i] and (rangedSum(0, i - 1) == ascSum(i)) and (rangedSum(i, len(arr) - 1) == ascSum(len(arr) - i)):
			result.append([len(arr[:i]), len(arr[i:])])
	return result

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = [int(i) for i in input().split(' ')]
		result = soln(a)
		print(len(result))
		for res in result:
			(l1, l2) = res
			print('{} {}'.format(l1, l2))

def test():
	a = [1, 4, 3, 2, 1]
	print(soln(a))
main()


def _check_permutation(array):
	return set(range(1, len(array) + 1)) == set(array)

def _split_perm(array):
	viewed_numbers = set()
	for (index, number) in enumerate(array):
		if number in viewed_numbers:
			if _check_permutation(array[:index]) and _check_permutation(array[index:]):
				return index
			else:
				return -1
		viewed_numbers.add(number)
	return -1
task_number = int(input())
for _ in range(task_number):
	n = int(input())
	array = [int(i) for i in input().split()]
	forward = _split_perm(array)
	array.reverse()
	backward = _split_perm(array)
	ans = []
	if forward > 0:
		ans.append((forward, n - forward))
	if backward > 0:
		ans.append((n - backward, backward))
	ans = set(ans)
	print(len(ans))
	for (l1, l2) in ans:
		print(l1, l2)


import sys
input = iter(sys.stdin.readlines()).__next__
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))

	def output():
		output = []
		c1 = {}
		c2 = {}
		for (i, x) in enumerate(a):
			if x not in c1:
				c1[x] = i
			elif x not in c2:
				c2[x] = i
			else:
				return []
		(l, r) = (0, n + 1)
		for x in range(1, n + 1):
			if x in c2:
				(xl, xr) = sorted([c1[x], c2[x]])
				l = max(l, xl + 1)
				r = min(r, xr)
				if l > r:
					return []
			else:
				break
		longer = 0
		for x in range(x, n - (x - 1) + 1):
			if x not in c1:
				return []
			if x in c2:
				return []
			i = c1[x]
			if i < l:
				if longer == +1:
					return []
				longer = -1
				l = r
			elif i >= r:
				if longer == -1:
					return []
				longer = +1
				r = l
		output.append([l, n - l])
		if r > l:
			output.append([r, n - r])
		return output
	out = output()
	print(len(out))
	for r in out:
		print(*r)


t = int(input())
for jj in range(t):
	n = int(input())
	a = list(map(int, input().strip().split(' ')))
	pp = max(a)
	x1 = [0 for _ in range(pp + 1)]
	kk = 0
	for i in range(n):
		x1[a[i]] += 1
		if x1[a[i]] == 2 and kk == 0:
			ppp = i
			kk = 1
	x1 = x1[1:]
	mn1 = 0
	mn2 = 0
	ff = True
	pppp = -1
	for i in range(len(x1)):
		if x1[i] == 2:
			pppp = i
	for i in range(len(x1)):
		if x1[i] == 0 and i <= pp - 1 or pppp == -1:
			ff = False
			break
		elif x1[i] == 1 and i <= pppp:
			ff = False
			break
	if not ff:
		print(0)
	else:
		xkkk = 0
		fgh = []
		sum1 = sum(a[0:pppp + 1])
		sum2 = sum(a) - sum1
		sum3 = sum(a[n - pppp - 1:])
		sum4 = sum(a) - sum3
		if sum1 == (pppp + 1) * (pppp + 2) // 2 and sum2 == pp * (pp + 1) // 2:
			xkkk += 1
			fgh.append([pppp + 1, n - pppp - 1])
		if sum3 == (pppp + 1) * (pppp + 2) // 2 and sum4 == pp * (pp + 1) // 2:
			if n != 2 * (pppp + 1):
				fgh.append([n - pppp - 1, pppp + 1])
				xkkk += 1
		if xkkk == 0:
			print(0)
		else:
			print(xkkk)
			for jjj in fgh:
				print(jjj[0], jjj[1])


import os, sys, atexit
from io import BytesIO, StringIO
input = BytesIO(os.read(0, os.fstat(0).st_size)).readline
_OUTPUT_BUFFER = StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
t = int(input())
while t:
	t += -1
	n = int(input())
	l = list(map(int, input().split()))
	count = [0] * (n + 1)
	for i in l:
		count[i] -= -1
	l1 = 0
	l2 = 0
	ch = 0
	for i in range(1, n + 1):
		if count[i] == 2:
			l1 = i
		else:
			break
	l2 = n - l1
	p1 = [0] * (l1 + 1)
	p2 = [0] * (l2 + 1)
	for i in range(l1):
		if l[i] > l1:
			ch = 1
			break
		p1[l[i]] = 1
	for i in range(l1, n):
		if l[i] > l2:
			ch = 1
			break
		p2[l[i]] = 1
	ch1 = 1
	ch2 = 1
	if 0 in p1[1:l1 + 1] or 0 in p2[1:l2 + 1] or ch:
		ch1 = 0
	(l1, l2) = (l2, l1)
	p1 = [0] * (l1 + 1)
	p2 = [0] * (l2 + 1)
	ch = 0
	for i in range(l1):
		if l[i] > l1:
			ch = 1
			break
		p1[l[i]] = 1
	for i in range(l1, n):
		if l[i] > l2:
			ch = 1
			break
		p2[l[i]] = 1
	if 0 in p1[1:l1 + 1] or 0 in p2[1:l2 + 1] or ch:
		ch2 = 0
	if ch1:
		if ch2:
			if l1 != l2:
				print(2)
				print(l1, l2)
				print(l2, l1)
			else:
				print(1)
				print(l1, l2)
		else:
			print(1)
			print(l2, l1)
	elif ch2:
		print(1)
		print(l1, l2)
	else:
		print(0)


import os
import heapq
import sys, threading
import math as mt
import operator
from copy import copy
from collections import defaultdict, deque
from io import BytesIO, IOBase
sys.setrecursionlimit(10 ** 5)

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

def inpt():
	return [int(k) for k in input().split()]

def main():
	for _ in range(int(input())):
		n = int(input())
		ar = inpt()
		ma = max(ar)
		(tp1, tp2) = ([], [])
		if ma >= n:
			print(0)
			continue
		for i in range(ma):
			tp1.append(ar[i])
		for i in range(ma, n):
			tp2.append(ar[i])
		tp1.sort()
		tp2.sort()
		ok1 = True
		for i in range(len(tp1)):
			if tp1[i] != i + 1:
				ok1 = False
				break
		for i in range(len(tp2)):
			if tp2[i] != i + 1:
				ok1 = False
				break
		ok2 = True
		ar = ar[::-1]
		(tp1, tp2) = ([], [])
		for i in range(ma):
			tp1.append(ar[i])
		for i in range(ma, n):
			tp2.append(ar[i])
		tp1.sort()
		tp2.sort()
		for i in range(len(tp1)):
			if tp1[i] != i + 1:
				ok2 = False
				break
		for i in range(len(tp2)):
			if tp2[i] != i + 1:
				ok2 = False
				break
		if ok1 == ok2 == False:
			print(0)
			continue
		if ok1 == ok2 == True and ma != n - ma:
			print(2)
			print(n - ma, ma)
			print(ma, n - ma)
			continue
		if ok1 == True:
			print(1)
			print(ma, n - ma)
			continue
		if ok2 == True:
			print(1)
			print(n - ma, ma)
			continue
		print(0)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	mx = max(a)
	sz = n - mx
	s1 = {num for num in range(1, sz + 1)}
	s2 = {num for num in range(1, mx + 1)}
	ans = 0
	l = []
	for i in range(n):
		if i < sz:
			if a[i] in s1:
				s1.remove(a[i])
		elif a[i] in s2:
			s2.remove(a[i])
	if len(s1) == 0 and len(s2) == 0:
		ans += 1
		l.append(sz)
		l.append(mx)
	s2 = {num for num in range(1, sz + 1)}
	s1 = {num for num in range(1, mx + 1)}
	for i in range(n):
		if i < mx:
			if a[i] in s1:
				s1.remove(a[i])
		elif a[i] in s2:
			s2.remove(a[i])
	if len(s1) == 0 and len(s2) == 0 and (sz != mx):
		ans += 1
		l.append(mx)
		l.append(sz)
	if ans == 0:
		print(ans)
	else:
		print(ans)
		for i in range(0, ans * 2, 2):
			print(f'{l[i]} {l[i + 1]}')


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
for _ in range(get_int()):
	n = get_int()
	lst = get_int_list()
	n1 = len(set(lst))
	n2 = n - n1
	ref1 = list(range(1, n1 + 1))
	ref2 = list(range(1, n2 + 1))
	result = []
	flag = True
	if sorted(lst[:n1]) == ref1 and sorted(lst[n1:]) == ref2:
		result.append([n1, n2])
		if n1 == n2:
			flag = False
	if flag and sorted(lst[:n2]) == ref2 and (sorted(lst[n2:]) == ref1):
		result.append([n2, n1])
	print(len(result))
	for row in result:
		print(row[0], row[1])


import time
import os, sys
from io import BytesIO, IOBase
from types import GeneratorType
from bisect import bisect_left, bisect_right
from collections import defaultdict as dd, deque as dq, Counter as dc
import math, string, heapq as h
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def getInt():
	return int(input())

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

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

def getStr():
	return input()

def listStr():
	return list(input())

def getMat(n):
	return [getInts() for _ in range(n)]

def getBin():
	return list(map(int, list(input())))

def isInt(s):
	return '0' <= s[0] <= '9'

def ceil_(a, b):
	return a // b + (a % b > 0)
MOD = 10 ** 9 + 7

def solve():
	N = getInt()
	A = getInts()
	used = [0] * N
	ops = set()
	for (i, a) in enumerate(A):
		if used[a]:
			L1 = i
			L2 = N - i
			break
		used[a] = 1
	if sorted(A[L1:]) == list(range(1, L2 + 1)) and sorted(A[:L1]) == list(range(1, L1 + 1)):
		ops.add((L1, L2))
	used = [0] * N
	for (i, a) in enumerate(reversed(A)):
		if used[a]:
			L1 = i
			L2 = N - i
			break
		used[a] = 1
	if sorted(A[:L2]) == list(range(1, L2 + 1)) and sorted(A[L2:]) == list(range(1, L1 + 1)):
		ops.add((L2, L1))
	print(len(ops))
	for (a, b) in ops:
		print(a, b)
	return
for _ in range(getInt()):
	solve()


a = int(input())
for i in range(a):
	s = int(input())
	z = list(map(int, input().split()))
	t = max(z)
	ans1 = z[0:t]
	ans2 = z[t:]
	ans1.sort()
	ans2.sort()
	flag = 0
	glag = []
	for i in range(len(ans1)):
		if ans1[i] != i + 1:
			flag = 1
	for i in range(len(ans2)):
		if ans2[i] != i + 1:
			flag = 1
	if flag == 0:
		glag.append([t, len(z) - t])
	ans1 = z[0:len(z) - t]
	ans2 = z[len(z) - t:]
	ans1.sort()
	ans2.sort()
	flag = 0
	for i in range(len(ans1)):
		if ans1[i] != i + 1:
			flag = 1
	for i in range(len(ans2)):
		if ans2[i] != i + 1:
			flag = 1
	if flag == 0:
		glag.append([len(z) - t, t])
	if len(glag) == 2 and glag[0] == glag[1]:
		print(1)
		print(glag[0][0], glag[0][1])
		continue
	print(len(glag))
	for i in range(len(glag)):
		print(glag[i][0], glag[i][1])


from collections import defaultdict

def check(arr):
	arr.sort()
	value = [i + 1 for i in range(len(arr))]
	if arr == value:
		return True
	return False
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	high = max(l)
	low = len(l) - high
	ans = []
	if check(l[:low]) == True and check(l[low:]) == True:
		ans.append([low, high])
	if low != high and check(l[:high]) == True and (check(l[high:]) == True):
		ans.append([high, low])
	print(len(ans))
	for i in ans:
		print(*i)


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	conc = list(map(int, input().split()))
	minp = [n] * n
	mins = [n] * (n + 1)
	maxp = [0] * n
	maxs = [0] * (n + 1)
	for i in range(n):
		minp[i] = min(minp[i - 1], conc[i])
		maxp[i] = max(maxp[i - 1], conc[i])
	for i in range(n - 1, -1, -1):
		mins[i] = min(mins[i + 1], conc[i])
		maxs[i] = max(maxs[i + 1], conc[i])
	s1 = {conc[0]}
	s2 = defaultdict(int)
	for i in range(1, n):
		s2[conc[i]] += 1
	possibles = []
	for i in range(1, n):
		pred = minp[i - 1] == 1 and mins[i] == 1 and (maxp[i - 1] == i) and (maxs[i] == n - i)
		if pred and len(s1) == i and (len(s2) == n - i):
			possibles.append(i)
		s1.add(conc[i])
		s2[conc[i]] -= 1
		if s2[conc[i]] == 0:
			s2.pop(conc[i])
	print(len(possibles))
	for pos in possibles:
		print(pos, n - pos)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

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

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

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

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

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator
from collections import deque, defaultdict, OrderedDict
import collections

def answer(a, n, v):
	d = {}
	c = 0
	z = []
	mx1 = 0
	for i in a:
		mx1 = max(i, mx1)
		c += 1
		if i in d:
			if d[i] + 1 == 2:
				break
			else:
				d[i] += 1
		else:
			d[i] = 1
	ans = -1
	for i in range(c - 1):
		if i + 1 not in d:
			ans = 0
	mx2 = 0
	d2 = {}
	for j in range(c - 1, n):
		mx2 = max(mx2, a[j])
		if a[j] not in d:
			ans = 0
			break
		else:
			d[a[j]] += 1
			if d[a[j]] == 3:
				ans = 0
				break
		if a[j] not in d2:
			d2[a[j]] = 1
	for i in range(n - c + 1):
		if i + 1 not in d2:
			ans = 0
		elif d[i + 1] == 3:
			ans = 0
			break
	if ans == 0:
		return [0, 0, v]
	else:
		return [1, c - 1, n - c + 1, v]

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	ans = []
	k = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
	for _ in range(ri()):
		n = ri()
		a = ria()
		kk = answer(a, n, 0)
		zz = answer(a[::-1], n, 1)
		if kk[0] == 0 and zz[0] == 0:
			print(0)
		elif kk[0] != 0 and zz[0] == 0:
			print(kk[0])
			print(kk[1], kk[2])
		elif kk[0] == 0 and zz[0] != 0:
			print(zz[0])
			print(n - zz[1], n - zz[2])
		elif kk[1] != n - zz[1]:
			print(2)
			print(kk[1], kk[2])
			print(n - zz[1], n - zz[2])
		else:
			print(1)
			print(kk[1], kk[2])
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			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, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			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()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	maxa = max(a)
	l1 = maxa
	l2 = n - l1
	v1 = [False] * l1
	v2 = [False] * l2
	a1 = 0
	a2 = 0
	cnt = 0
	for i in range(l1):
		if a[i] > l1:
			break
		v1[a[i] - 1] = True
	for i in range(l1, n):
		if a[i] > l2:
			break
		v2[a[i] - 1] = True
	if sum((1 for i in range(l1) if not v1[i])) == 0 and sum((1 for i in range(l2) if not v2[i])) == 0:
		a1 = 1
		cnt += 1
	v1 = [False] * l2
	v2 = [False] * l1
	for i in range(l2):
		if a[i] > l2:
			break
		v1[a[i] - 1] = True
	for i in range(l2, n):
		if a[i] > l1:
			break
		v2[a[i] - 1] = True
	if sum((1 for i in range(l2) if not v1[i])) == 0 and sum((1 for i in range(l1) if not v2[i])) == 0:
		a2 = 1
		cnt += 1
	if l1 == l2:
		if a1 == 1:
			print('1')
			print(l1, l1)
		else:
			print('0')
	else:
		print(cnt)
		if a1 == 1:
			print(l1, n - l1)
		if a2 == 1:
			print(n - l1, l1)


from sys import stdin
for _ in range(int(input())):
	n = int(stdin.readline().rstrip())
	l = list(map(int, stdin.readline().rstrip().split(' ')))
	s = 0
	d = {}
	le = 0
	res1 = []
	res2 = []
	for i in range(n):
		x = d.get(l[i], 0)
		if x:
			if s == le * (le + 1) // 2:
				res1.append(le)
			s = 0
			le = 0
			d = {}
			d[l[i]] = 1
		else:
			d[l[i]] = 1
		le += 1
		s += l[i]
	if s == le * (le + 1) // 2:
		res1.append(le)
	s = 0
	le = 0
	d = {}
	for i in range(n - 1, -1, -1):
		x = d.get(l[i], 0)
		if x:
			if s == le * (le + 1) // 2:
				res2.append(le)
			s = 0
			le = 0
			d = {}
			d[l[i]] = 1
		else:
			d[l[i]] = 1
		le += 1
		s += l[i]
	if s == le * (le + 1) // 2:
		res2.append(le)
	if sum(res2) != n or len(res2) > 2:
		res2 = []
	if sum(res1) != n or len(res1) > 2:
		res1 = []
	if res1 == list(reversed(res2)):
		res2 = []
	print(len(res2) // 2 + len(res1) // 2)
	if len(res1) // 2:
		print(*res1)
	if len(res2) // 2:
		print(*list(reversed(res2)))


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	max1 = max(l)
	l2 = []
	g1 = 1
	for i in range(1, max1 + 1):
		l2.append(i)
	g2 = set(l)
	if len(g2) == 1 and n != 2:
		g1 = 0
	l3 = l[0:max1]
	l3.sort()
	l4 = l[max1:]
	l4.sort()
	g3 = 0
	g4 = 0
	if max1 == n:
		g1 == 0
	if g1 == 1:
		if l2 != l3:
			g3 = 0
		else:
			g3 = 1
		if g3 == 1:
			l5 = []
			for i in range(1, max(l4) + 1):
				l5.append(i)
			if l5 != l4:
				g3 = 0
			else:
				g3 = 1
		l3 = l[-1:-max1 - 1:-1]
		l3.sort()
		l4 = l[-max1 - 1::-1]
		l4.sort()
		if l2 != l3:
			g4 = 0
		else:
			g4 = 1
		if g4 == 1:
			l5 = []
			for i in range(1, max(l4) + 1):
				l5.append(i)
			if l5 != l4:
				g4 = 0
			else:
				g4 = 1
	if g1 == 0:
		print(0)
	elif (g3 == 1 and g4 == 1) and max1 != n / 2:
		print(2)
		print(max1, n - max1)
		print(n - max1, max1)
	elif g3 == 1:
		print(1)
		print(max1, n - max1)
	elif g4 == 1:
		print(1)
		print(n - max1, max1)
	else:
		print(0)


T = int(input())
for _ in range(T):
	n = int(input())
	nums = list(map(int, input().split()))
	m_num = max(nums)
	count = [0] * (n + 1)
	gg = False
	for i in range(m_num):
		count[nums[i]] += 1
		if count[nums[i]] > 1:
			gg = True
	count = [0] * (n + 1)
	for i in range(m_num, n):
		count[nums[i]] += 1
		if count[nums[i]] > 1 or nums[i] > n - m_num:
			gg = True
	count = [0] * (n + 1)
	gg1 = False
	for i in range(n - m_num):
		count[nums[i]] += 1
		if count[nums[i]] > 1 or nums[i] > n - m_num:
			gg1 = True
	count = [0] * (n + 1)
	for i in range(n - m_num, n):
		count[nums[i]] += 1
		if count[nums[i]] > 1:
			gg1 = True
	if m_num == n - m_num and (not gg):
		print(1)
		print(m_num, m_num)
		continue
	print(2 - gg - gg1)
	if not gg:
		print(m_num, n - m_num)
	if not gg1:
		print(n - m_num, m_num)


from collections import Counter

def check(arr, mx, mx2):
	st = set(range(1, mx + 1))
	for i in range(len(arr)):
		if len(st) == 0:
			st2 = set(range(1, mx2 + 1))
			for j in range(i, len(arr)):
				if arr[j] in st2:
					st2.remove(arr[j])
				else:
					return False
			return True if len(st2) == 0 else False
		if arr[i] in st:
			st.remove(arr[i])
		else:
			return False
	return False
t = int(input())
for i in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	cnt = Counter(arr)
	mx = max(arr)
	mx2 = -1
	for i in cnt:
		if cnt[i] == 2:
			mx2 = max(i, mx2)
		if cnt[i] >= 3:
			print(0)
			break
	else:
		ans = 0
		ansarr = []
		if check(arr, mx, mx2):
			ans += 1
			ansarr.append([mx, mx2])
		if check(arr, mx2, mx):
			ans += 1
			ansarr.append([mx2, mx])
		if ans and mx2 > 0:
			if mx2 == mx:
				print(1)
				print(mx, mx2)
			else:
				print(ans)
				for i in range(len(ansarr)):
					print(ansarr[i][0], ansarr[i][1])
		else:
			print(0)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
from collections import Counter

def solve():
	n = inp()
	lst = inlt()
	ma = max(lst)
	if ma >= len(lst):
		print(0)
		return
	res = []
	if is_perm(lst, 0, ma) and is_perm(lst, ma, len(lst)):
		res.append([str(ma), str(n - ma)])
	if ma != n - ma and is_perm(lst, 0, n - ma) and is_perm(lst, n - ma, len(lst)):
		res.append([str(n - ma), str(ma)])
	print(len(res))
	for r in res:
		print(' '.join(r))

def is_perm(lst, l, r):
	els = r - l
	seen = [False] * els
	for i in range(l, r):
		el = lst[i] - 1
		if el >= len(seen) or seen[el]:
			return False
		seen[el] = True
	return True

def main():
	t = inp()
	for i in range(t):
		solve()
BUFSIZE = 8192

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

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

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

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

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


from collections import *
from bisect import *
from math import ceil, factorial, gcd
from heapq import *

def perm(a, l1):
	v = defaultdict(int)
	for i in range(l1):
		v[a[i]] = 1
	for i in range(1, l1 + 1):
		if v[i] == 0:
			return False
	return True
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	mx = max(a)
	(l1, l2) = (mx, n - mx)
	res = []
	if perm(a, l1) and perm(a[l1:], l2):
		res.append([l1, l2])
	if l1 != l2 and perm(a, l2) and perm(a[l2:], l1):
		res.append([l2, l1])
	print(len(res))
	for r in res:
		print(*r)


import sys
import math
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	d = [0] * n
	for i in range(n):
		d[a[i]] += 1
	(l1, l2) = (0, 0)
	for i in range(1, n):
		if d[i] == 2:
			l1 += 1
			l2 += 1
		elif d[i] == 1:
			l1 += 1
		else:
			break
	if l1 + l2 == n:
		cnt = 0
		left = {}
		right = {}
		fa = 0
		fa1 = 0
		for i in range(l1):
			left[a[i]] = 1
		j = n - 1
		for i in range(l2):
			right[a[j]] = 1
			j -= 1
		for i in range(1, l1 + 1):
			if left.get(i, -1) == -1:
				fa = 1
				break
		for i in range(1, l2 + 1):
			if right.get(i, -1) == -1:
				fa = 1
				break
		left = {}
		right = {}
		for i in range(l2):
			left[a[i]] = 1
		j = n - 1
		for i in range(l1):
			right[a[j]] = 1
			j -= 1
		for i in range(1, l2 + 1):
			if left.get(i, -1) == -1:
				fa1 = 1
				break
		for i in range(1, l1 + 1):
			if right.get(i, -1) == -1:
				fa1 = 1
				break
		if fa * fa1 == 1:
			print(0)
		elif l1 == l2:
			print(1)
			print(l1, l2)
		elif fa == 0:
			if fa1 == 0:
				print(2)
				print(l1, l2)
				print(l2, l1)
			else:
				print(1)
				print(l1, l2)
		elif fa == 0:
			print(2)
			print(l1, l2)
			print(l2, l1)
		else:
			print(1)
			print(l2, l1)
	else:
		print(0)


import collections, math
local = False
if local:
	file = open('inputt.txt', 'r')

def inp():
	if local:
		return file.readline().rstrip()
	else:
		return input().rstrip()

def ints():
	return [int(_) for _ in inp().split()]
t = int(inp())
for _ in range(t):
	n = int(inp())
	arr = ints()
	ans = []
	right = 0
	visited = set()
	validPermu = [False] * len(arr)
	for i in range(len(arr)):
		right = max(right, arr[-i - 1])
		if arr[-i - 1] not in visited:
			visited.add(arr[-i - 1])
		else:
			break
		if i + 1 == right:
			validPermu[-i - 1] = True
	right = 0
	visited.clear()
	for i in range(len(arr)):
		right = max(right, arr[i])
		if arr[i] not in visited:
			visited.add(arr[i])
		else:
			break
		if i + 1 == right and validPermu[i + 1]:
			(first, sec) = (i + 1, len(arr) - i - 1)
			ans.append([first, sec])
	if len(ans) == 0:
		print(0)
	else:
		print(len(ans))
		for (first, sec) in ans:
			print('{0} {1}'.format(first, sec))


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	arr = list(map(int, stdin.readline().split()))
	a = len(set(arr))
	if a == n:
		print(2)
		print(n, 0)
		print(0, n)
	else:
		ans = []
		c = 0
		for t in range(2):
			if set(arr[:a]) == set(range(1, a + 1)) and set(arr[a:]) == set(range(1, n - a + 1)):
				c += 1
				ans.extend([a, n - a])
			if a == n - a:
				break
			a = n - a
		print(c)
		for t in range(0, len(ans), 2):
			print(ans[t], ans[t + 1])


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	am2 = 0
	summ2 = 0
	am1 = 0
	summ1 = 0
	ch1 = set()
	ans1 = set()
	ch2 = set()
	ch1.add(0)
	chh = set()
	for i in a:
		chh.add(i)
		am1 += 1
		summ1 += i
		if len(chh) == am1 and am1 * (am1 + 1) // 2 == summ1:
			ch1.add(am1)
	ans = 0
	anss = []
	num = len(a)
	chh = set()
	if num in ch1:
		ans += 1
		anss.append(len(a))
		anss.append(0)
	for i in range(len(a) - 1, -1, -1):
		chh.add(a[i])
		am2 += 1
		summ2 += a[i]
		if len(chh) == am2 and am2 * (am2 + 1) // 2 == summ2:
			num = len(a) - am2
			if num in ch1:
				ans += 1
				anss.append(len(a) - am2)
				anss.append(am2)
	print(ans)
	for i in range(ans):
		print(anss[2 * i], anss[2 * i + 1])


for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	ans = []
	s1 = 0
	c = 0
	s = set([])
	s2 = sum(l)
	for i in range(n):
		s1 += l[i]
		s.add(l[i])
		t = i + 1
		p = n - t
		if t * (t + 1) // 2 == s1 and len(s) == t and (s2 - s1 == p * (p + 1) // 2):
			c += 1
			ans.append((t, p))
	ans2 = set([])
	s1 = 0
	s = set([])
	s2 = sum(l)
	k = 0
	for i in range(n - 1, -1, -1):
		s1 += l[i]
		s.add(l[i])
		t = k + 1
		p = n - t
		if t * (t + 1) // 2 == s1 and len(s) == t and (s2 - s1 == p * (p + 1) // 2):
			ans2.add((t, p))
		k += 1
	c = 0
	newans = []
	for i in ans:
		if (i[1], i[0]) in ans2:
			newans.append((i[0], i[1]))
			c += 1
	print(c)
	for i in newans:
		print(i[0], i[1])


t = int(input())
for i in range(t):
	l = int(input())
	data = list(map(int, input().split()))
	m = max(data)
	a = sorted(data[:m])
	b = sorted(data[m:])
	c = sorted(data[:l - m])
	d = sorted(data[l - m:])
	e = [i for i in range(1, m + 1)]
	f = [i for i in range(1, l - m + 1)]
	if m != l / 2:
		if (a == e and b == f) and (c == f and d == e):
			print(2)
			print(m, l - m)
			print(l - m, m)
		elif (a == e and b == f) and (c != f or d != e):
			print(1)
			print(m, l - m)
		elif (a != e or b != f) and (c == f and d == e):
			print(1)
			print(l - m, m)
		else:
			print(0)
	elif a == e and b == f or (c == f and d == e):
		print(1)
		print(m, m)
	else:
		print(0)


t = int(input())
for f in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	x = [0] * (n + 1)
	k = 0
	m = 0
	t = 0
	s = [0]
	for i in range(n):
		x[a[i]] += 1
		if x[a[i]] == 1:
			t += 1
		m = max(m, a[i])
		if m == t and m == i + 1:
			k += 1
			s += [i + 1]
	possible = 1
	p1 = 0
	if x[1] != 2:
		possible = 0
	for i in range(n - 1):
		if x[i + 2] > x[i + 1]:
			possible = 0
		if x[i + 2] < x[i + 1] and x[i + 1] == 2:
			p1 = i + 1
	if possible == 1:
		rk = 0
		rs = [0]
		for i in range(k):
			if s[i + 1] == p1 or s[i + 1] == n - p1:
				rk += 1
				rs += [s[i + 1]]
		print(rk)
		for i in range(rk):
			print(rs[i + 1], n - rs[i + 1])
	else:
		print(0)


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

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
testcases = int(input())
for case in range(testcases):
	n = int(input())
	l = [int(zax) for zax in input().split()]
	total = sum(l)
	first = 0
	answers = []
	prev = 0
	for i in range(n - 1):
		prev += l[i]
		other_sum = total - prev
		count = n - i - 1
		if (i + 1) * (i + 2) // 2 == prev and count * (count + 1) // 2 == other_sum:
			p1 = l[0:i + 1]
			p2 = l[i + 1:]
			if sorted(p1) == [i for i in range(1, i + 2)] and sorted(p2) == [i for i in range(1, count + 1)]:
				first += 1
				answers.append([i + 1, count])
	print(first)
	for i in range(first):
		print(answers[i][0], answers[i][1])


import sys
import math
input = sys.stdin.readline

def solve(N, A):
	items = set()
	ans = set()
	max_item = -1
	for i in range(N):
		items.add(A[i])
		if A[i] > max_item:
			max_item = A[i]
		if len(items) == max_item and len(items) == i + 1:
			ans.add(i + 1)
	return ans
T = int(input())
for t in range(T):
	N = int(input())
	A = list(map(int, input().split(' ')))
	ans1 = solve(N, A)
	ans2 = {N - x for x in solve(N, list(reversed(A)))}
	ans = ans1 & ans2
	print(len(ans))
	for x in ans:
		print(x, N - x)


for _ in range(int(input())):
	n = int(input())
	v = list(map(int, input().split()))
	sup = max(v)
	num = 0
	res = []
	if set(v[:sup]) == set(range(1, sup + 1)) and set(v[sup:]) == set(range(1, n - sup + 1)):
		num += 1
		res.append((sup, n - sup))
	if 2 * sup != n:
		if set(v[:n - sup]) == set(range(1, n - sup + 1)) and set(v[-sup:]) == set(range(1, sup + 1)):
			num += 1
			res.append((n - sup, sup))
	if num == 0:
		print(0)
	else:
		print(num)
		for i in res:
			print(*i)


import sys
from math import sqrt, floor
from collections import deque, Counter
inp = sys.stdin.readline
read = lambda : list(map(int, inp().split()))

def a():
	ans = ''
	for _ in range(int(inp())):
		(n, x) = read()
		arr = sorted(list(set(read())))
		n = len(arr)
		i = 0
		while i < n and arr[i] <= x + 1:
			x += 1
			i += 1
		ans += str(x) + '\n'
	print(ans)

def b():
	ans = ''
	for _ in range(int(inp())):
		n = int(inp())
		arr = read()
		total = sum(arr)
		s1 = 0
		ans_lis = []
		for i in range(n):
			s1 += arr[i]
			total -= arr[i]
			(p1, p2) = (i + 1, n - i - 1)
			if s1 == p1 * (p1 + 1) // 2 and total == p2 * (p2 + 1) // 2 and (len(set(arr[:p1])) == p1) and (len(set(arr[p1:])) == p2):
				ans_lis.append(str(p1) + ' ' + str(p2))
		ans += str(len(ans_lis)) + '\n'
		for i in ans_lis:
			ans += str(i) + '\n'
	print(ans)
b()


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	l1 = max(ar)
	l2 = n - l1
	se1 = set({})
	se2 = set({})
	for i in range(1, l1 + 1):
		se1.add(i)
	for j in range(1, n - l1 + 1):
		se2.add(j)
	k = 0
	li = []
	if se1 == set(ar[:l1]) and se2 == set(ar[l1:]):
		k += 1
		li.append([l1, l2])
	if se1 == set(ar[-l1:]) and se2 == set(ar[:-l1]):
		if l1 != l2:
			k += 1
			li.append([l2, l1])
	print(k)
	for z in range(k):
		print(*li[z])


from functools import reduce
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

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

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

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))
mo = 1000000007
d = defaultdict(int)
for i in range(1, 200001):
	res = i * (i + 1) // 2
	d[res] = i
for _ in range(inn()):
	n = inn()
	a = arr()
	sm = 0
	count = defaultdict(int)
	pre = defaultdict(int)
	flag = 0
	for i in range(n):
		sm += a[i]
		if a[i] in count:
			flag = 1
		else:
			count[a[i]] += 1
		if sm in d and i + 1 == d[sm] and (flag == 0):
			pre[i] = sm
	sm = 0
	flag = 0
	count = defaultdict(int)
	suf = defaultdict(int)
	for i in range(n - 1, -1, -1):
		sm += a[i]
		if a[i] in count:
			flag = 1
		else:
			count[a[i]] += 1
		if sm in d and n - i == d[sm] and (flag == 0):
			suf[i] = sm
	ans = []
	for i in pre:
		if i + 1 in suf:
			ans += [(d[pre[i]], d[suf[i + 1]])]
	print(len(ans))
	for i in range(len(ans)):
		print(ans[i][0], ans[i][1])


def check(sublist, length):
	if len(set(sublist)) != length:
		return False
	if max(sublist) > length:
		return False
	return True
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	count = 0
	result = ''
	for i in {max(a), n - max(a)}:
		if check(a[:i], i):
			if check(a[i:], n - i):
				count += 1
				result += f'{i} {n - i}\n'
	print(count)
	if result:
		result = result[:-1]
		print(result)


def check(arr):
	arr.sort()
	for i in range(0, len(arr)):
		if arr[i] != i + 1:
			return False
	return True
for _ in range(int(input())):
	w = int(input())
	data = list(map(int, input().split()))
	indexOfMax = max(data)
	flag1 = 0
	flag2 = 0
	if check(data[:indexOfMax]) and check(data[indexOfMax:]):
		flag1 = 1
	if check(data[:w - indexOfMax]) and check(data[w - indexOfMax:]):
		if indexOfMax != w - indexOfMax:
			flag2 = 1
	print(flag2 + flag1)
	if flag1 == 1:
		print(indexOfMax, w - indexOfMax)
	if flag2 == 1:
		print(w - indexOfMax, indexOfMax)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(p) for p in input().split()]
	m = max(arr)
	count = 0
	if sorted(arr[:m]) == list(range(1, m + 1)) and sorted(arr[m:]) == list(range(1, n - m + 1)):
		count += 1
		t = 1
	if sorted(arr[:n - m]) == list(range(1, n - m + 1)) and sorted(arr[n - m:]) == list(range(1, m + 1)):
		count += 1
		t = 2
	if count == 2:
		if n - m == m:
			print(1)
			print(n - m, m)
			continue
		print(count)
		print(n - m, m)
		print(m, n - m)
	elif count == 1:
		print(1)
		if t == 1:
			print(m, n - m)
		else:
			print(n - m, m)
	else:
		print(0)


kl = int(input())
for l in range(kl):
	n = int(input())
	mx = 0
	k = 0
	a = [0 for j in range(n)]
	for i in input().split():
		i = int(i)
		a[k] = i
		k += 1
		mx = max(mx, i)
	if mx >= n:
		print(0)
		continue
	kn1 = n - mx
	kn2 = mx
	A1 = {int(i) for i in range(1, kn1 + 1)}
	B1 = {int(i) for i in range(1, kn2 + 1)}
	A2 = {int(i) for i in range(1, kn2 + 1)}
	B2 = {int(i) for i in range(1, kn1 + 1)}
	ra1 = set()
	ra2 = set()
	rb1 = set()
	rb2 = set()
	for i in range(kn1):
		ra1.add(a[i])
	for i in range(kn1, n):
		rb1.add(a[i])
	for i in range(kn2):
		ra2.add(a[i])
	for i in range(kn2, n):
		rb2.add(a[i])
	if A1 == ra1 and rb1 == B1:
		if A2 == ra2 and B2 == rb2:
			if kn1 == kn2:
				print(1)
				print(kn1, kn2)
			else:
				print(2)
				print(kn1, kn2)
				print(kn2, kn1)
		else:
			print(1)
			print(kn1, kn2)
	elif A2 == ra2 and B2 == rb2:
		print(1)
		print(kn2, kn1)
	else:
		print(0)


def NO():
	return print('NO')

def YES():
	return print('YES')

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

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

def STR():
	return input()

def MAP():
	return map(int, input().split())
for _ in range(INT()):
	n = INT()
	a = LIST()
	d = [0] * n
	for i in range(n):
		d[a[i]] += 1
	l1 = 0
	l2 = 0
	for i in range(1, n):
		if d[i] == 2:
			l1 += 1
			l2 += 1
		elif d[i] == 1:
			l1 += 1
		else:
			break
	if l1 + l2 == n:
		cnt = 0
		left = {}
		right = {}
		f = 0
		f1 = 0
		for i in range(l1):
			left[a[i]] = 1
		j = n - 1
		for i in range(l2):
			right[a[j]] = 1
			j -= 1
		for i in range(1, l1 + 1):
			if left.get(i, -1) == -1:
				f = 1
				break
		for i in range(1, l2 + 1):
			if right.get(i, -1) == -1:
				f = 1
				break
		left = {}
		right = {}
		for i in range(l2):
			left[a[i]] = 1
		j = n - 1
		for i in range(l1):
			right[a[j]] = 1
			j -= 1
		for i in range(1, l2 + 1):
			if left.get(i, -1) == -1:
				f1 = 1
				break
		for i in range(1, l1 + 1):
			if right.get(i, -1) == -1:
				f1 = 1
				break
		if f * f1 == 1:
			print(0)
		elif f == 0:
			if l1 == l2:
				print(1)
				print(l1, l2)
			elif f1 == 0:
				print(2)
				print(l1, l2)
				print(l2, l1)
			else:
				print(1)
				print(l1, l2)
		elif f == 0:
			print(2)
			print(l1, l2)
			print(l2, l1)
		else:
			print(1)
			print(l2, l1)
	else:
		print('0')


ans = []
for _ in range(int(input())):
	n = int(input())
	u = list(map(lambda x: int(x) - 1, input().split()))
	mm = max(u) + 1
	d = []
	for i in range(mm):
		d.append([])
	for i in range(n):
		d[u[i]].append(i)
	ok = False
	okk = False
	for i in range(mm):
		if len(d[i]) == 0 or len(d[i]) > 2:
			ans.append('0')
			okk = True
			break
		if not ok:
			if len(d[i]) == 1:
				ok = True
		elif len(d[i]) == 2:
			ans.append('0')
			okk = True
			break
	if okk:
		continue
	w = []
	w.append((-1, 1))
	w.append((n, -1))
	for i in range(mm):
		if len(d[i]) == 1:
			break
		w.append((d[i][0], 1))
		w.append((d[i][1], -1))
	w.sort()
	st = 0
	a = -1
	b = -1
	for i in range(len(w)):
		st += w[i][1]
		if st == len(w) // 2:
			a = w[i][0]
		if st == len(w) // 2 - 1 and a != -1:
			b = w[i][0]
			break
	mn = n
	mx = -1
	for i in range(len(w) // 2 - 1, mm):
		mn = min(mn, d[i][0])
		mx = max(mx, d[i][0])
	if mx == -1:
		mn = -1
	p1 = (-1, mn)
	p2 = (mx, n)
	ansi = []
	if a < mn:
		for i in range(a, min(b, mn)):
			ansi.append((i + 1, n - i - 1))
	if mx < b:
		for i in range(max(mx, a), b):
			ansi.append((i + 1, n - i - 1))
	ans.append(str(len(ansi)))
	for i in range(len(ansi)):
		ans.append(str(ansi[i][0]) + ' ' + str(ansi[i][1]))
print('\n'.join(ans))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	for i in a:
		if i not in d:
			d[i] = 1
		else:
			d[i] = 2
	x = 0
	y = 0
	for i in d.keys():
		if i > x:
			x = i
		if i > y and d[i] == 2:
			y = i
	if x + y != n or y == 0:
		print(0)
		continue
	(flag1, flag2, flag3, flag4) = (1, 1, 1, 1)
	d1 = {}
	d2 = {}
	d3 = {}
	d4 = {}
	for i in range(y):
		d1[i + 1] = 0
		d4[i + 1] = 0
	for i in range(x):
		d2[i + 1] = 0
		d3[i + 1] = 0
	for i in range(0, y):
		d1[a[i]] = 1
	for i in range(y, n):
		d2[a[i]] = 1
	for i in range(0, x):
		d3[a[i]] = 1
	for i in range(x, n):
		d4[a[i]] = 1
	for i in range(y):
		if d1[i + 1] == 0:
			flag1 = 0
		if d4[i + 1] == 0:
			flag3 = 0
	for i in range(x):
		if d2[i + 1] == 0:
			flag2 = 0
		if d3[i + 1] == 0:
			flag4 = 0
	flag5 = flag1 and flag2
	flag6 = flag3 and flag4
	if flag5 and flag6 == 1:
		if x != y:
			print(2)
			print(x, y)
			print(y, x)
		else:
			print(1)
			print(x, y)
		continue
	if flag5 == 0 and flag6 == 0:
		print(0)
		continue
	print(1)
	if flag5 == 1:
		print(y, x)
	else:
		print(x, y)


import sys
input = sys.stdin.buffer.readline
T = int(input())
for t in range(1, T + 1):
	L = int(input())
	W = [int(x) for x in input().split()]
	m = max(W)
	answer = []
	if set(W[:m]) == set(range(1, m + 1)) and set(W[m:]) == set(range(1, L - m + 1)):
		answer.append(m)
	m = L - m
	if set(W[:m]) == set(range(1, m + 1)) and set(W[m:]) == set(range(1, L - m + 1)):
		answer.append(m)
	answer = set(answer)
	print(len(answer))
	for a in answer:
		print('{} {}'.format(a, L - a))


def check(array, index):
	new_array = array[:index]
	new_array.sort()
	for i in range(index):
		if i + 1 != new_array[i]:
			return False
	new_array = array[index:]
	new_array.sort()
	for i in range(len(array) - index):
		if i + 1 != new_array[i]:
			return False
	return True
t = int(input())
while t:
	n = int(input())
	perm = list(map(int, input().split()))
	maxPerm = -1
	for x in perm:
		if x > maxPerm:
			maxPerm = x
	forward = check(perm, maxPerm)
	reverse = check(perm[::-1], maxPerm)
	if maxPerm == n - maxPerm:
		reverse = False
	if forward and reverse:
		print('2')
		print(maxPerm, n - maxPerm)
		print(n - maxPerm, maxPerm)
	elif forward:
		print('1')
		print(maxPerm, n - maxPerm)
	elif reverse:
		print('1')
		print(n - maxPerm, maxPerm)
	else:
		print('0')
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	a = max(l)
	b = n - a
	l1 = l[:b]
	flag1 = 1
	flag2 = 0
	l1.sort()
	for i in range(b):
		if l1[i] != i + 1:
			flag1 = 0
			break
	if flag1 != 0:
		l2 = l[b:]
		l2.sort()
		for i in range(n - b):
			if l2[i] != i + 1:
				flag1 = 0
				break
	if 2 * b != n:
		flag2 = 1
		b = n - b
		l1 = l[:b]
		l1.sort()
		for i in range(b):
			if l1[i] != i + 1:
				flag2 = 0
				break
		if flag2 != 0:
			l2 = l[b:]
			l2.sort()
			for i in range(n - b):
				if l2[i] != i + 1:
					flag2 = 0
					break
	if flag1 == 1 and flag2 == 1 and (b != 0) and (n - b != 0):
		print(2)
		print(*[b, n - b])
		print(*[n - b, b])
	elif flag1 == 1 and flag2 == 0 and (b != 0) and (n - b != 0):
		print(1)
		print(*[n - b, b])
	elif flag2 == 1 and flag1 == 0 and (b != 0) and (n - b != 0):
		print(1)
		print(*[b, n - b])
	else:
		print(0)


t = int(input())
for T in range(t):
	n = int(input())
	v = [int(i) for i in input().split(' ')]
	s = sorted(v)
	l1 = 0
	for i in range(1, n):
		if s[i] == s[i - 1]:
			l1 = s[i]
	l2 = s[-1]
	if l1 + l2 != n:
		print(0)
		continue
	ans = []
	f1 = set(v[:l1])
	f2 = set(v[l1:])
	if len(f1) == l1 and len(f2) == l2:
		ans.append((l1, l2))
	s1 = set(v[:l2])
	s2 = set(v[l2:])
	if l1 != l2 and len(s2) == l1 and (len(s1) == l2):
		ans.append((l2, l1))
	print(len(ans))
	for i in ans:
		print(i[0], i[1])


t = int(input())
for i in range(t):
	x = int(input())
	num = list((0 for j in range(x)))
	arr = list(map(int, input().split()))
	ma = max(arr)
	ans = list()
	if len(set(arr[:ma])) == ma and len(set(arr[ma:])) == x - ma and (max(arr[:ma]) == ma) and (max(arr[ma:]) == x - ma):
		ans.append([ma, x - ma])
	ma = x - ma
	if len(set(arr[:ma])) == ma and len(set(arr[ma:])) == x - ma and (max(arr[:ma]) == ma) and (max(arr[ma:]) == x - ma):
		ans.append([ma, x - ma])
	if ma == x - ma:
		if len(ans) == 2:
			print(1)
			print(*ans[0])
			continue
	print(len(ans))
	for j in ans:
		print(*j)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	ans = []
	ls = [0] * (max(a) + 1)
	ls2 = [0] * (max(a) + 1)
	ind = 0
	check = True
	psm = 0
	for i in range(n):
		if ls[a[i]] == 1:
			ind = i - 1
			break
		else:
			ls[a[i]] = 1
			psm += a[i]
	if psm != (ind + 2) * (ind + 1) / 2:
		check = False
	cnt = n - ind - 1
	r = cnt
	sm = 0
	for i in range(ind + 1, n):
		if ls2[a[i]] == 1:
			check = False
			break
		else:
			ls2[a[i]] = 1
			cnt -= 1
			sm += a[i]
	if check and cnt == 0 and (sm == (r + 1) * r / 2):
		ans.append((ind + 1, n - ind - 1))
	ls3 = [0] * (max(a) + 1)
	ls4 = [0] * (max(a) + 1)
	ind2 = 0
	check2 = True
	psm2 = 0
	for i in range(n - 1, -1, -1):
		if ls3[a[i]] == 1:
			ind2 = i + 1
			break
		else:
			ls3[a[i]] = 1
			psm2 += a[i]
	if psm2 != (n - ind2 + 1) * (n - ind2) / 2:
		check2 = False
	cnt2 = ind2
	r2 = cnt2
	sm2 = 0
	for i in range(ind2 - 1, -1, -1):
		if ls4[a[i]] == 1:
			check2 = False
			break
		else:
			ls4[a[i]] = 1
			cnt2 -= 1
			sm2 += a[i]
	if check2 and cnt2 == 0 and (sm2 == (r2 + 1) * r2 / 2):
		ans.append((ind2, n - ind2))
	ans = list(dict.fromkeys(ans))
	if len(ans) == 0:
		print(0)
	else:
		print(len(ans))
		for i in ans:
			print(i[0], i[1])


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	have = [False] * n
	combos = 0
	cArr = []
	for i in range(n):
		if have[arr[i]] == False:
			have[arr[i]] = True
		else:
			if len(set(arr[i:])) == n - i and min(arr[i:]) == 1 and (max(arr[i:]) == n - i) and (max(arr[:i]) == i) and (min(arr[:i]) == 1):
				combos += 1
				cArr.append([i, n - i])
			break
	have = [False] * n
	for i in range(n - 1, -1, -1):
		if have[arr[i]] == False:
			have[arr[i]] = True
		else:
			if len(set(arr[:i + 1])) == i + 1 and min(arr[:i + 1]) == 1 and (max(arr[:i + 1]) == i + 1) and (max(arr[i + 1:]) == n - i - 1) and (min(arr[i + 1:]) == 1):
				combos += 1
				cArr.append([i + 1, n - i - 1])
			break
	if combos == 2:
		if cArr[0] == cArr[1]:
			print(1)
			print(*cArr[1])
		else:
			print(combos)
			for i in range(len(cArr)):
				print(*cArr[i])
	else:
		print(combos)
		for i in range(len(cArr)):
			print(*cArr[i])


import itertools
t = int(input())
for i in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	s = []
	m = max(p)
	r1 = set(range(1, m + 1))
	r2 = set(range(1, n - m + 1))
	l1 = set(p[:m])
	l2 = set(p[m:])
	if len(r1.difference(l1)) == 0 and len(r2.difference(l2)) == 0:
		s.append((m, n - m))
	l1 = set(p[n - m:])
	l2 = set(p[:n - m])
	if len(r1.difference(l1)) == 0 and len(r2.difference(l2)) == 0:
		s.append((n - m, m))
	if len(s) > 0:
		print(len(set(s)))
		for e in set(s):
			print(*e)
	else:
		print(0)


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 998244353

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	n = val()
	l = li()
	a = set()
	s = Counter(l)
	b = set(l)
	le1 = 0
	le2 = sum(s.values())
	m = 0
	ind = n
	lmax = [0]
	for i in l[::-1]:
		lmax.append(max(lmax[-1], i))
	lmax = lmax[1:]
	lmax = lmax[::-1]
	lmax = lmax[1:]
	lsmall = [0]
	for i in l:
		lsmall.append(max(lsmall[-1], i))
	lsmall = lsmall[1:]
	ans = []
	for j in range(n):
		if l[j] in a:
			break
		a.add(l[j])
		le1 += 1
		s[l[j]] -= 1
		if not s[l[j]]:
			b.remove(l[j])
		le2 -= 1
		if le1 == lsmall[j] and le2 == len(b) == lmax[j]:
			ans.append([le1, len(b)])
	print(len(ans))
	for i in ans:
		print(*i)


t = int(input())
for u in range(t):
	n = int(input())
	z = [int(x) for x in input().split(' ')]
	(a, b) = (0, 0)
	m = max(z)
	a = z.index(m)
	ans = []
	if len(set(z[:m])) == m and len(set(z[m:])) == n - m:
		(a, b) = (max(z[:m]), max(z[m:]))
		if len(set(z[:m])) == a and len(set(z[m:])) == b:
			ans.append(m)
	if len(set(z[:n - m])) == n - m and len(set(z[n - m:])) == m:
		(a, b) = (max(z[:n - m]), max(z[n - m:]))
		if len(set(z[:n - m])) == a and len(set(z[n - m:])) == b:
			if n - m not in ans:
				ans.append(n - m)
	if len(ans):
		print(len(ans))
		for x in ans:
			print(x, n - x)
	else:
		print(0)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	flag = 1
	first = 0
	out = 0
	mem = [0] * n
	for i in a:
		mem[i - 1] += 1
		if mem[i - 1] > 2:
			flag = 0
			break
	for i in mem:
		if i == 2:
			first += 1
		else:
			break
	if flag and first and (first <= n):
		sec = n - first
		f = a[:first]
		s = a[first:]
		res = []
		check1 = list(range(1, first + 1))
		check2 = list(range(1, sec + 1))
		if check1 == list(set(f)) and check2 == list(set(s)):
			out = 1
			res.append([first, sec])
		f = a[:sec]
		s = a[sec:]
		if check2 == list(set(f)) and check1 == list(set(s)) and (first != sec):
			out += 1
			res.append([sec, first])
		print(out)
		for i in res:
			print(*i)
	else:
		print(out)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	M = max(a)
	ans = set()
	cnt1 = [0] * n
	cnt2 = [0] * n
	for i in range(M):
		cnt1[a[i]] += 1
	for i in range(M, n):
		cnt2[a[i]] += 1
	flag = True
	for i in range(1, M + 1):
		if cnt1[i] != 1:
			flag = False
	for i in range(1, n - M + 1):
		if cnt2[i] != 1:
			flag = False
	if flag:
		ans.add((M, n - M))
	cnt1 = [0] * n
	cnt2 = [0] * n
	for i in range(n - M):
		cnt1[a[i]] += 1
	for i in range(n - M, n):
		cnt2[a[i]] += 1
	flag = True
	for i in range(1, n - M + 1):
		if cnt1[i] != 1:
			flag = False
	for i in range(1, M + 1):
		if cnt2[i] != 1:
			flag = False
	if flag:
		ans.add((n - M, M))
	print(len(ans))
	for (l1, l2) in ans:
		print(l1, l2)


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')
t = int(input())
for ti in range(t):
	n = (int(i) for i in input().split(' '))
	li = [int(i) for i in input().split(' ')]
	d = {}
	d2 = {}
	p1 = []
	p2 = []
	a1 = 0
	a2 = []
	tg = False
	for (idx, i) in enumerate(li):
		if i not in d and tg == False:
			p1.append(i)
			d[i] = idx
		else:
			tg = True
			p2.append(i)
			d2[i] = idx
	beg = 0
	dn = False
	for i in sorted(p1):
		if i == beg + 1:
			beg += 1
		else:
			dn = True
	beg = 0
	for i in sorted(p2):
		if i == beg + 1:
			beg += 1
		else:
			dn = True
	if not dn and 0 not in (len(p1), len(p2)):
		a1 = 1
		a2.append((len(p1), len(p2)))
	p1 = []
	p2 = []
	d = {}
	d2 = {}
	tg = False
	for (idx, i) in enumerate(li[::-1]):
		if i not in d and tg == False:
			p1.append(i)
			d[i] = idx
		else:
			tg = True
			p2.append(i)
			d2[i] = idx
	beg = 0
	dn = False
	for i in sorted(p1):
		if i == beg + 1:
			beg += 1
		else:
			dn = True
	beg = 0
	for i in sorted(p2):
		if i == beg + 1:
			beg += 1
		else:
			dn = True
	if not dn and 0 not in (len(p1), len(p2)):
		a1 += 1
		if a1 == 2:
			if a2[0] == (len(p2), len(p1)):
				a1 = 1
				pass
			else:
				a2.append((len(p2), len(p1)))
		else:
			a2.append((len(p2), len(p1)))
	print(a1)
	for i in a2:
		print(*i)


import os
import sys
from io import BytesIO, IOBase
from collections import Counter, defaultdict
from collections import deque
from functools import cmp_to_key
import math

def sin():
	return input()

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

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

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	s = set()
	for p in range(2, n + 1):
		if prime[p]:
			s.add(p)
	return s

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def solve(c1, c2, maxi1, maxi2):
	for i in range(1, maxi1 + 1):
		if i not in c1:
			return False
	for i in range(1, maxi2 + 1):
		if i not in c2:
			return False
	return True

def main():
	for _ in range(iin()):
		n = iin()
		l = ain()
		maxi = max(l)
		ans = []
		c1 = Counter(l[0:maxi])
		c2 = Counter(l[maxi:])
		if solve(c1, c2, maxi, n - maxi):
			ans.append(maxi)
		c1 = Counter(l[n - maxi:])
		c2 = Counter(l[:n - maxi])
		if solve(c1, c2, maxi, n - maxi):
			ans.append(n - maxi)
		ans = set(ans)
		print(len(ans))
		for i in ans:
			print(i, n - 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')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def main_function():
	t = int(input())
	for i in range(t):
		n = int(input())
		A = list(map(int, input().split(' ')))
		l1 = max(A)
		l2 = n - l1
		k = 0
		ans = []
		if l1 == l2:
			if l1 == len(set(A[:n // 2])) == len(set(A[n // 2:])) and sum(list(range(l1 + 1))) == sum(set(A[:n // 2])) == sum(set(A[n // 2:])):
				print(1)
				print(l1, l1)
			else:
				print(0)
		else:
			if l1 == len(set(A[:l1])) and l2 == len(set(A[l1:])) and (sum(list(range(l1 + 1))) == sum(set(A[:l1]))) and (sum(list(range(l2 + 1))) == sum(set(A[l1:]))):
				k += 1
				ans.append(l1)
				ans.append(l2)
			if l2 == len(set(A[:l2])) and l1 == len(set(A[l2:])) and (sum(list(range(l2 + 1))) == sum(set(A[:l2]))) and (sum(list(range(l1 + 1))) == sum(set(A[l2:]))):
				k += 1
				ans.append(l2)
				ans.append(l1)
			print(k)
			for j in range(0, len(ans), 2):
				print(ans[j], ans[j + 1])
main_function()


from sys import stdin
from collections import Counter
t = int(input())
for _ in range(t):
	(n,) = map(int, stdin.readline().split())
	S = list(map(int, stdin.readline().split()))
	M = 1
	rtbs = 1
	c = Counter()
	forward = [False] * n
	for i in range(n):
		if c[S[i]] > 0:
			break
		else:
			c[S[i]] += 1
		if S[i] > M:
			M = S[i]
			rtbs = M - i - 1
		else:
			rtbs -= 1
		if rtbs == 0:
			forward[i] = True
	M = 1
	rtbs = 1
	c = Counter()
	backward = [False] * n
	S = S[::-1]
	for i in range(n):
		if c[S[i]] > 0:
			break
		else:
			c[S[i]] += 1
		if S[i] > M:
			M = S[i]
			rtbs = M - i - 1
		else:
			rtbs -= 1
		if rtbs == 0:
			backward[i] = True
	backward = backward[::-1]
	count = 0
	ans = []
	for i in range(n - 1):
		if forward[i] and backward[i + 1]:
			count += 1
			ans.append(str(i + 1) + ' ' + str(n - i - 1))
	print(count)
	for i in ans:
		print(i)


t = int(input(''))
for _ in range(t):
	n = int(input(''))
	a = list(map(int, input('').split(' ')))
	mx = max(a)
	ans = 0
	fin = []
	d = {}
	for i in range(mx):
		d[a[i]] = True
	chk = True
	for i in range(1, mx + 1, 1):
		if i not in d:
			chk = False
			break
	if chk:
		f = {}
		chk = True
		for i in range(mx, n, 1):
			f[a[i]] = True
		for i in range(1, n - mx + 1, 1):
			if i not in f:
				chk = False
				break
		if chk:
			ans += 1
			fin.append(str(mx) + ' ' + str(n - mx))
	d = {}
	for i in range(n - 1, n - mx - 1, -1):
		d[a[i]] = True
	chk = True
	for i in range(1, mx + 1, 1):
		if i not in d:
			chk = False
			break
	if chk:
		f = {}
		chk = True
		for i in range(n - mx):
			f[a[i]] = True
		for i in range(1, n - mx + 1, 1):
			if i not in f:
				chk = False
				break
		if chk:
			if mx != n / 2:
				ans += 1
				fin.append(str(n - mx) + ' ' + str(mx))
	print(ans)
	for k in range(ans):
		print(fin[k])


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	c = 0
	ans = ''
	a = [s[0]] + [0] * n
	b = [0] + s[1:]
	mxa = max(a)
	mxb = max(b)
	sa = {}
	sb = {}
	sa[mxa] = 1
	for i in range(1, n):
		if sb.get(b[i]):
			sb[b[i]] += 1
		else:
			sb[b[i]] = 1
	mxsbind = -1
	for i in range(1, n):
		if len(sa) == mxa == i and len(sb) == mxb == n - i:
			c += 1
			ans += str(i) + ' ' + str(n - i) + '\n'
		t = b[i]
		b[i] = 0
		sb[t] -= 1
		if sb[t] == 0:
			sb.pop(t)
			if t == mxb:
				for j in range(mxb - 1, -1, -1):
					if sb.get(j):
						mxb = j
						break
		if sa.get(t):
			sa[t] += 1
		else:
			sa[t] = 1
		a[i] = t
		mxa = max(mxa, t)
	print(c)
	if c:
		print(ans[:-1])


MAX_N = 200010
T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	c = {}
	ans = []
	maxl = 1
	for i in range(n):
		x = a[i]
		maxl = max(x, maxl)
		if x in c:
			c[x] += 1
		else:
			c[x] = 1
	perm = True
	for i in range(1, maxl + 1):
		if i not in c or c[i] == 0 or c[i] > 2:
			perm = False
			break
	if perm:
		for i in range(1, maxl + 1):
			if c[i] == 2:
				if i == maxl:
					minl = i
				elif c[i + 1] == 1:
					minl = i
					break
	if perm:
		for i in range(minl + 1, maxl + 1):
			if c[i] != 1:
				perm = False
				break
	if perm:
		for p in set([minl - 1, maxl - 1]):
			valid = True
			v1 = set()
			v2 = set()
			for j in range(p + 1):
				v1.add(a[j])
			for j in range(p + 1, n):
				v2.add(a[j])
			for j in range(1, p + 1 + 1):
				if j not in v1:
					valid = False
					break
			if valid:
				for j in range(1, n - (p + 1) + 1):
					if j not in v2:
						valid = False
						break
			if valid:
				ans.append((p + 1, n - (p + 1)))
	print(len(ans))
	for i in range(len(ans)):
		(l1, l2) = ans[i]
		print(l1, l2)


t = int(input())
for i in range(t):
	n = int(input())
	(s, m, k, a, b, r) = (input().split(), set(), 0, [], [], [])
	for i in range(n):
		if int(s[i]) in m:
			m.remove(int(s[i]))
			if m == set():
				a.append(i + 1)
		elif int(s[i]) > k:
			for j in range(k + 1, int(s[i])):
				m.add(j)
			k = int(s[i])
			if m == set():
				a.append(i + 1)
		else:
			break
	(k, m) = (0, set())
	for i in range(n - 1, -1, -1):
		if int(s[i]) in m:
			m.remove(int(s[i]))
			if m == set():
				b.append(i + 1)
		elif int(s[i]) > k:
			for j in range(k + 1, int(s[i])):
				m.add(j)
			k = int(s[i])
			if m == set():
				b.append(i + 1)
		else:
			break
	b = sorted(b)
	k = 0
	while a != [] and b != []:
		if a[-1] - b[-1] < -1:
			b.pop()
		elif a[-1] - b[-1] > -1:
			a.pop()
		else:
			k = k + 1
			r.append(str(a[-1]) + ' ' + str(n - b[-1] + 1))
			a.pop()
			b.pop()
	print(k)
	if len(r) != 0:
		for i in r:
			print(i)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	temp = [0 for i in range(n + 1)]
	count = 0
	flag = ''
	for i in range(n):
		temp[a[i]] += 1
		if temp[a[i]] == 2:
			count += 1
		if temp[a[i]] == 3:
			flag = 'not possible'
	for i in range(1, n - count + 1):
		if temp[i] == 0:
			flag = 'not possible'
		if i > count and temp[i] == 2:
			flag = 'not possible'
		if i <= count and temp[i] != 2:
			flag = 'not possible'
	if flag == '':
		target = count * (count + 1) // 2
		temp1 = 0
		for i in range(count):
			temp1 += a[i]
		temp2 = 0
		for i in range(n - 1, n - count - 1, -1):
			temp2 += a[i]
		if temp1 == temp2 and temp1 == target:
			if count == n - count:
				print(1)
				print(count, count)
			else:
				print(2)
				print(count, n - count)
				print(n - count, count)
		elif temp1 == target and temp2 != target:
			print(1)
			print(count, n - count)
		elif temp2 == target and temp1 != target:
			print(1)
			print(n - count, count)
		else:
			print(0)
	else:
		print(0)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import ceil, floor
from copy import *
from collections import deque, defaultdict
from collections import Counter as counter
from itertools import combinations
from itertools import permutations as permutate
from bisect import bisect_left as bl
from operator import *
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192
from sys import stderr

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))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

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

def stringlis():
	return list(map(str, inp().split()))

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

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

def fsep():
	return map(float, inp().split())

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def pow(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

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

def prefix_sum(ar):
	return list(accumulate(ar))

def suffix_sum(ar):
	return list(accumulate(ar[::-1]))[::-1]

def N():
	return int(inp())
dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]

def YES():
	print('YES')

def NO():
	print('NO')

def Yes():
	print('Yes')

def No():
	print('No')
from collections import defaultdict

def numberOfSetBits(i):
	i = i - (i >> 1 & 1431655765)
	i = (i & 858993459) + (i >> 2 & 858993459)
	return ((i + (i >> 4) & 252645135) * 16843009 & 4294967295) >> 24

def solve():
	n = N()
	ar = lis()
	m = max(ar)
	s1 = set(ar[:m])
	s2 = set(ar[m:])
	ans = []
	if len(s1) == m and len(s2) == n - m and (max(s1) == m) and (max(s2) == n - m):
		ans.append((m, n - m))
	s1 = set(ar[:n - m])
	s2 = set(ar[n - m:])
	if len(s1) == n - m and len(s2) == m and (max(s1) == n - m) and (max(s2) == m):
		ans.append((n - m, m))
	if len(ans) == 2:
		if ans[0] == ans[1]:
			ans.pop()
	print(len(ans))
	for i in ans:
		print(*i)
testcase(int(inp()))


from collections import defaultdict
t = int(input())
for k in range(t):
	n = int(input())
	a = [int(el) for el in input().split()]
	pref_sum = [0 for i in range(n)]
	pref_sum[0] = a[0]
	numbers = defaultdict(int)
	numbers[a[0]] = 1
	for i in range(1, n):
		pref_sum[i] = pref_sum[i - 1] + a[i]
		numbers[a[i]] += 1
	max_r = [0 for i in range(n)]
	max_r[n - 1] = a[n - 1]
	for i in range(n - 2, -1, -1):
		max_r[i] = max(max_r[i + 1], a[i])
	result = []
	max_l = 0
	num_l = defaultdict(int)
	for i in range(n - 1):
		num_l[a[i]] += 1
		if num_l[a[i]] > 1:
			break
		numbers[a[i]] -= 1
		if numbers[a[i]] == 0:
			numbers.pop(a[i])
		max_l = max(max_l, a[i])
		len_r = n - i - 1
		if i + 1 != len(num_l) or len_r != len(numbers):
			continue
		if max_l != i + 1 or max_r[i + 1] != len_r:
			continue
		if pref_sum[i] == (1 + i + 1) * (i + 1) // 2 and pref_sum[n - 1] - pref_sum[i] == (1 + len_r) * len_r // 2:
			result.append((i + 1, len_r))
	print(len(result))
	for (l, r) in result:
		print(l, r)


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, A):

	def makeForward(A):
		seen = set()
		mn = float('inf')
		mx = float('-inf')
		bad = False
		forward = []
		for (i, x) in enumerate(A):
			mx = max(mx, x)
			mn = min(mn, x)
			if x in seen:
				bad = True
			seen.add(x)
			if bad:
				forward.append(False)
			else:
				forward.append(i + 1 == len(seen) and mn == 1 and (mx == i + 1))
		return forward
	forward = makeForward(A)
	backward = makeForward(A[::-1])
	ans = []
	for l1 in range(1, N):
		l2 = N - l1
		if forward[l1 - 1] and backward[l2 - 1]:
			ans.append(str(l1) + ' ' + str(l2))
	if ans:
		return str(len(ans)) + '\n' + '\n'.join(ans)
	return 0
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input())
for t in range(T):
	(N,) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	ans = solve(N, A)
	print(ans)


from bisect import bisect_left, bisect_right
from sys import stdin, stdout, setrecursionlimit
from collections import Counter
input = lambda : stdin.readline().strip()
print = stdout.write
t = int(input())
for _ in range(t):
	n = int(input())
	ls = list(map(int, input().split()))
	forward = []
	backward = []
	for i in range(n + 1):
		forward.append(False)
		backward.append(False)
	m = 1
	d = []
	for i in range(n + 1):
		d.append(False)
	for i in range(n):
		if d[ls[i]]:
			break
		d[ls[i]] = True
		if ls[i] == m:
			m += 1
			while d[m]:
				m += 1
		if m == i + 2:
			forward[i] = True
	m = 1
	d = []
	for i in range(n + 1):
		d.append(False)
	for i in range(n - 1, -1, -1):
		if d[ls[i]]:
			break
		d[ls[i]] = True
		if ls[i] == m:
			m += 1
			while d[m]:
				m += 1
		if m == len(ls) - i + 1:
			backward[i] = True
	soln = []
	for i in range(n - 1):
		if forward[i] and backward[i + 1]:
			soln.append((i + 1, n - i - 1))
	print(str(len(soln)) + '\n')
	for i in soln:
		print(str(i[0]) + ' ' + str(i[1]) + '\n')


import sys

def perm(p):
	d = {i: 0 for i in range(1, max(p) + 1)}
	for i in p:
		d[i] += 1
		if d[i] > 1:
			return False
	if 0 in d.values():
		return False
	return True
for i in range(int(sys.stdin.readline())):
	n = int(sys.stdin.readline())
	l = [*map(int, sys.stdin.readline().split())]
	m = max(l)
	if 2 * m == n:
		b = perm(l[:m]) and perm(l[m:])
		if b:
			print(1)
			print(m, m)
		else:
			print(0)
	else:
		b1 = perm(l[:m]) and perm(l[m:])
		b2 = perm(l[:-m]) and perm(l[-m:])
		print(b1 + b2)
		if b1:
			print(m, n - m)
		if b2:
			print(n - m, m)


t = int(input())
while t != 0:
	n = int(input())
	A = list(map(int, input().split()))
	l = max(A)
	B = set(range(l + 1)) - {0}
	C = set(range(n - l + 1)) - {0}
	res = 0
	res1 = []
	res2 = []
	if set(A[:l]) == B and set(A[l:]) == C:
		res += 1
		res1.append(l)
		res2.append(n - l)
	if set(A[:n - l]) == C and set(A[n - l:]) == B:
		res += 1
		res1.append(n - l)
		res2.append(l)
	if res == 0:
		print(res)
	else:
		if res1[0] == res2[0]:
			res -= 1
			res1.pop()
			res2.pop()
		print(res)
		for i in range(len(res1)):
			print(res1[i], res2[i])
	t -= 1


t = int(input())
for q in range(t):
	n = int(input())
	li = list(map(int, input().split(' ', n)[:n]))
	m = max(li)
	hs = [0] * (m + 1)
	ans = 0
	an = set([])
	fl = 0
	for i in range(m):
		hs[li[i]] += 1
		if hs[li[i]] != 1:
			fl = 1
			break
	if fl == 0:
		hs = [0] * (m + 1)
		for i in range(m, n):
			hs[li[i]] += 1
		for i in range(1, n - m + 1):
			if hs[i] != 1:
				fl = 1
				break
		if fl == 0:
			ans += 1
			an.add((m, n - m))
	li.reverse()
	hs = [0] * (m + 1)
	fl = 0
	for i in range(m):
		hs[li[i]] += 1
		if hs[li[i]] != 1:
			fl = 1
			break
	if fl == 0:
		hs = [0] * (m + 1)
		for i in range(m, n):
			hs[li[i]] += 1
		for i in range(1, n - m + 1):
			if hs[i] != 1:
				fl = 1
				break
		if fl == 0:
			ans += 1
			an.add((n - m, m))
	print(len(an))
	li = []
	for i in an:
		li.append([i[0], i[1]])
	li.sort()
	for i in li:
		print(i[0], i[1])


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	p1 = set()
	dict1 = {}
	m = -1
	for i in range(n):
		m = max(m, arr[i])
		if arr[i] in dict1:
			break
		else:
			dict1[arr[i]] = 1
		if i + 1 == m:
			p1.add(i)
	arr = arr[::-1]
	p2 = []
	dict1 = {}
	m = -1
	for i in range(n):
		m = max(m, arr[i])
		if arr[i] in dict1:
			break
		else:
			dict1[arr[i]] = 1
		if i + 1 == m:
			if n - (i + 1) - 1 in p1:
				p2.append(n - (i + 1) - 1)
	print(len(p2))
	for i in p2:
		print(i + 1, n - (i + 1))


def is_good(hh, l):
	for i in range(1, l + 1):
		if hh[i] == 0:
			return False
	return True
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	hash1 = [0] * n
	for val in arr:
		hash1[val] += 1
	ans = []
	hash2 = hash1[:]
	temp = [0] * n
	for (ind, val) in enumerate(arr):
		if temp[val] != 0 and is_good(temp, ind) and is_good(hash1, n - ind):
			ans.append((ind, n - ind))
			break
		if temp[val] == 0:
			temp[val] += 1
			hash1[val] -= 1
		else:
			break
	temp = [0] * n
	for ind in range(len(arr) - 1, -1, -1):
		val = arr[ind]
		if temp[val] != 0 and is_good(hash2, ind + 1) and is_good(temp, n - ind - 1):
			ans.append((ind + 1, n - ind - 1))
			break
		if temp[val] == 0:
			temp[val] += 1
			hash2[val] -= 1
		else:
			break
	ans = list(set(ans))
	print(len(ans))
	for val in ans:
		print(str(val[0]) + ' ' + str(val[1]))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	l1 = max(arr)
	ans = []
	for j in range(2):
		if set(arr[:l1]) == set(range(1, l1 + 1)) and set(arr[l1:]) == set(range(1, n - l1 + 1)):
			ans.append(l1)
		l1 = n - l1
	ans = set(ans)
	print(len(ans))
	for i in ans:
		print(i, n - i)


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	mx = max(arr)
	i = mx
	d = []
	for j in range(2):
		if set(arr[:i]) == set(range(1, i + 1)) and set(arr[i:]) == set(range(1, n - i + 1)):
			d.append(i)
		i = n - i
	d = set(d)
	print(len(d))
	if len(d) > 0:
		for i in d:
			print(i, n - i)


def linput():
	return [int(i) for i in input().split()]
q = int(input())
for ______ in range(q):
	n = int(input())
	a = linput()
	s = []
	m = max(a)
	if a.count(m) < 3:
		if sorted(a[:m]) == [i + 1 for i in range(m)]:
			if sorted(a[m:]) == [i + 1 for i in range(n - m)]:
				b = [m, n - m]
				if b not in s:
					s.append([m, n - m])
		if sorted(a[:n - m]) == [i + 1 for i in range(n - m)]:
			if sorted(a[n - m:]) == [i + 1 for i in range(m)]:
				b = [n - m, m]
				if b not in s:
					s.append([n - m, m])
	if len(s) == 0:
		print(0)
	else:
		print(len(s))
		for i in s:
			print(*i)


import sys
import math
input = sys.stdin.readline
T = int(input())
for t in range(T):
	N = int(input())
	A = list(map(int, input().split(' ')))
	l1 = max(A)
	ans = set()

	def check(l1, l2):
		if l1 == 0 or l2 == 0:
			return
		s = set()
		for i in range(l1):
			if A[i] > l1:
				return
			s.add(A[i])
		if len(s) != l1:
			return
		s = set()
		for i in range(l1, l1 + l2):
			if A[i] > l2:
				return
			s.add(A[i])
		if len(s) != l2:
			return
		ans.add((l1, l2))
	check(l1, N - l1)
	check(N - l1, l1)
	print(len(ans))
	for (x, y) in ans:
		print(x, y)


z = input
for _ in range(int(z())):
	n = int(z())
	l = list(map(int, z().split()))
	(l1, k, c) = ([], max(l), 0)
	for i in {k, n - k}:
		if set(l[:i]) == set(range(1, i + 1)) and set(l[i:]) == set(range(1, n - i + 1)):
			l1.append(i)
			c += 1
	print(c)
	for i in l1:
		print(i, n - i)


for t in range(int(input())):
	n = int(input())
	nums = list(map(int, input().split()))
	odinr = set()
	dvar = set()
	mx = max(nums)
	sl = []
	if mx < len(nums):
		n1 = nums[:mx]
		n2 = nums[mx:]
		if sorted(n1) == list(range(1, mx + 1)) and sorted(n2) == list(range(1, len(n2) + 1)):
			sl += [[mx, n - mx]]
		mx = n - mx
		n1 = nums[:mx]
		n2 = nums[mx:]
		if sorted(n1) == list(range(1, mx + 1)) and sorted(n2) == list(range(1, len(n2) + 1)):
			sl += [[mx, n - mx]]
	if len(sl) == 2:
		if sl[0] == sl[1]:
			print(1)
			print(*sl[0])
		else:
			print(len(sl))
			for i in sl:
				print(*i)
	else:
		print(len(sl))
		for i in sl:
			print(*i)


import sys, re, math
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from heapq import heappush, heappop, heapify, nlargest, nsmallest

def STR():
	return list(input())

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

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

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

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

def sortListWithIndex(listOfTuples, idx):
	return sorted(listOfTuples, key=lambda x: x[idx])

def sortDictWithVal(passedDic):
	temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))[::-1]
	toret = {}
	for tup in temp:
		toret[tup[0]] = tup[1]
	return toret

def sortDictWithKey(passedDic):
	return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def check(idx):
	temp1 = [0] * (idx + 1)
	temp2 = [0] * (n - idx - 1)
	try:
		for i in range(idx + 1):
			temp1[a[i] - 1] = 1
		for i in range(idx + 1, n):
			temp2[a[i] - 1] = 1
		if sum(temp1) == idx + 1 and sum(temp2) == n - idx - 1:
			return True
		return False
	except:
		return False
t = INT()
while t != 0:
	n = INT()
	a = LIST()
	occ = defaultdict(int)
	for el in a:
		occ[el] += 1
	flag = 0
	newOcc = sortDictWithKey(occ)
	tocheck = -1
	for (i, key) in enumerate(newOcc):
		if newOcc[key] == 1:
			tocheck = i - 1
			break
	if tocheck != -1:
		z1 = check(tocheck)
		z2 = check(n - tocheck - 2)
		if z1 and z2:
			print(2)
			print(tocheck + 1, n - tocheck - 1)
			print(n - tocheck - 1, tocheck + 1)
		elif z1:
			print(1)
			print(tocheck + 1, n - tocheck - 1)
		elif z2:
			print(1)
			print(n - tocheck - 1, tocheck + 1)
		else:
			print(0)
	elif 1 not in newOcc or newOcc[1] == 1:
		print(0)
	else:
		tocheck = n // 2 - 1
		z1 = check(tocheck)
		if z1:
			print(1)
			print(tocheck + 1, n - tocheck - 1)
		else:
			print(0)
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().rstrip().split()))
	chk = True
	d = {}
	for i in a:
		if i not in d:
			d[i] = 0
		d[i] += 1
	b = a.copy()
	b = b[::-1]
	ck = {}
	pos = []
	k = -1
	for i in range(n):
		if a[i] not in ck:
			ck[a[i]] = True
		else:
			k = i
			break
	tmp = k
	for j in range(1, tmp + 1):
		if j not in ck:
			chk = False
	ck2 = {}
	for j in a[k:]:
		ck2[j] = True
	for k in range(1, n - tmp + 1):
		if k not in ck2:
			chk = False
	if chk:
		pos.append((tmp, n - tmp))
	a = b.copy()
	chk = True
	ck = {}
	k = -1
	for i in range(n):
		if a[i] not in ck:
			ck[a[i]] = True
		else:
			k = i
			break
	tmp = k
	for j in range(1, tmp + 1):
		if j not in ck:
			chk = False
	ck2 = {}
	for j in a[k:]:
		ck2[j] = True
	for k in range(1, n - tmp + 1):
		if k not in ck2:
			chk = False
	if chk:
		pos.append((n - tmp, tmp))
	hi = False
	for j in pos:
		if j[0] == 0 or j[1] == 0:
			hi = True
	if hi:
		print(0)
	elif len(pos) == 1:
		print(len(pos))
		print(str(pos[0][0]) + ' ' + str(pos[0][1]))
	elif len(pos) == 2:
		if pos[0][0] == pos[1][0] and pos[0][1] == pos[1][1]:
			del pos[0]
			print(len(pos))
			print(str(pos[0][0]) + ' ' + str(pos[0][1]))
		else:
			print(len(pos))
			print(str(pos[0][0]) + ' ' + str(pos[0][1]))
			print(str(pos[1][0]) + ' ' + str(pos[1][1]))
	else:
		print(0)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	m = max(l)
	l1 = list(set(l[:m]))
	l2 = list(set(l[m:]))
	l3 = list(set(l[:n - m]))
	l4 = list(set(l[n - m:]))
	sol1 = 0
	sol2 = 0
	if len(l1) == m and len(l2) == n - m and (min(l1) == 1) and (max(l1) == m) and (min(l2) == 1) and (max(l2) == n - m):
		sol1 = 1
	if len(l3) == n - m and len(l4) == m and (min(l3) == 1) and (max(l3) == n - m) and (min(l4) == 1) and (max(l4) == m):
		sol2 = 1
	if sol1 + sol2 == 0:
		print(0)
	elif sol1 + sol2 == 2:
		if m != n // 2:
			print(2)
			print(str(m) + ' ' + str(n - m))
			print(str(n - m) + ' ' + str(m))
		else:
			print(1)
			print(str(m) + ' ' + str(n - m))
	elif sol1 == 1:
		print(1)
		print(str(m) + ' ' + str(n - m))
	else:
		print(1)
		print(str(n - m) + ' ' + str(m))


import sys
input = sys.stdin.readline
from math import *
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = [int(p) for p in input().split()]
	b = [0 for i in range(n + 1)]
	m = 1
	d = []
	if a.count(1) != 2:
		print(0)
		continue
	l = [0 for i in range(n + 1)]
	for i in range(n):
		b[a[i]] += 1
		if a[i] == m:
			while m <= n and b[m] != 0:
				m += 1
		l[i] = m
	b = [0 for i in range(n + 1)]
	r = [0 for i in range(n + 1)]
	m = 1
	a = a[::-1]
	for i in range(n):
		b[a[i]] += 1
		if a[i] == m:
			while m <= n and b[m] != 0:
				m += 1
		r[i] = m
	for i in range(n):
		if l[i] == i + 2 and r[n - i - 2] == n - i:
			d.append([i + 1, n - i - 1])
	print(len(d))
	for i in d:
		print(*i)


import sys
input = lambda : sys.stdin.readline().strip()
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	pre = [0] * n
	suf = [0] * n
	s1 = set()
	s2 = set()
	mex1 = 0
	mex2 = 0
	s1.add(0)
	s2.add(0)
	for i in range(n):
		s1.add(a[i])
		while mex1 in s1:
			mex1 += 1
		pre[i] = mex1
	for i in range(n - 1, -1, -1):
		s2.add(a[i])
		while mex2 in s2:
			mex2 += 1
		suf[i] = mex2
	k = 0
	ans = []
	for i in range(n - 1):
		if pre[i] - 1 == i + 1 and suf[i + 1] - 1 == n - i - 1:
			k += 1
			ans.append([i + 1, n - i - 1])
	print(k)
	for i in ans:
		print(' '.join(map(str, i)))


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	maxi = max(l)
	truth = [0 for j in range(n)]
	truth2 = [0 for j in range(n)]
	ans = 0
	ans_list = []
	for j in range(maxi):
		truth[l[j] - 1] += 1
	for j in range(maxi, n):
		truth2[l[j] - 1] += 1
	if truth[0:maxi].count(1) == maxi and truth2[0:n - maxi].count(1) == n - maxi:
		ans += 1
		ans_list.append([maxi, n - maxi])
	truth = [0 for j in range(n)]
	truth2 = [0 for j in range(n)]
	maxi = n - maxi
	for j in range(maxi):
		truth[l[j] - 1] += 1
	for j in range(maxi, n):
		truth2[l[j] - 1] += 1
	if truth[0:maxi].count(1) == maxi and truth2[0:n - maxi].count(1) == n - maxi:
		if [maxi, n - maxi] not in ans_list:
			ans += 1
			ans_list.append([maxi, n - maxi])
	print(ans)
	if ans != 0:
		for j in ans_list:
			print(*j)


t = int(input())

def pmok(aa):
	seen = set()
	cursum = 0
	ret = []
	for (i, a) in enumerate(aa, 1):
		if a in seen:
			break
		seen.add(a)
		cursum += a
		if cursum == i * (i + 1) // 2:
			ret.append(i)
	return ret
anss = []
for _ in range(t):
	n = int(input())
	aa = list(map(int, input().split()))
	ans = []
	sl2 = set(pmok(reversed(aa[1:])))
	for l1 in pmok(aa[:-1]):
		if n - l1 in sl2:
			ans.append(f'{l1} {n - l1}')
	anss.append(str(len(ans)))
	if ans:
		anss.append('\n'.join(ans))
print('\n'.join(anss))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	z = [0 for j in range(n - 1)]
	x = [0 for j in range(n - 1)]
	flage = 1
	falge1 = 1
	for i in range(n):
		if z[a[i] - 1] == 0:
			z[a[i] - 1] = 1
		else:
			flage1 = 0
			l = a[:i]
			m = a[i:]
			break
	a = a[::-1]
	for k in range(n):
		if x[a[k] - 1] == 0:
			x[a[k] - 1] = 1
		else:
			flage = 0
			g = a[:k]
			h = a[k:]
			break
	if flage and flage1:
		print(0)
		break
	acc1 = 0
	if flage == 0:
		if len(g) == 1:
			if g[0] == 1:
				flag1 = 1
			else:
				flag1 = 0
		else:
			g.sort()
			if g[0] != 1:
				flag1 = 0
			else:
				for j in range(1, k):
					if g[j] - g[j - 1] == 1:
						flag1 = 1
						continue
					else:
						flag1 = 0
						break
		if len(h) == 1:
			if h[0] == 1:
				flag = 1
			else:
				flag = 0
		else:
			h.sort()
			if h[0] != 1:
				flag = 0
			else:
				for j in range(1, n - k):
					if h[j] - h[j - 1] == 1:
						flag = 1
						continue
					else:
						flag = 0
						break
		if flag and flag1:
			acc1 = 1
	acc2 = 0
	if flage1 == 0:
		if len(l) == 1:
			if l[0] == 1:
				flag1a = 1
			else:
				flag1a = 0
		else:
			l.sort()
			if l[0] != 1:
				flag1a = 0
			else:
				for j in range(1, i):
					if l[j] - l[j - 1] == 1:
						flag1a = 1
						continue
					else:
						flag1a = 0
						break
		if len(m) == 1:
			if m[0] == 1:
				flaga = 1
			else:
				flaga = 0
		else:
			m.sort()
			if m[0] != 1:
				flaga = 0
			else:
				for j in range(1, n - i):
					if m[j] - m[j - 1] == 1:
						flaga = 1
						continue
					else:
						flaga = 0
						break
		if flaga and flag1a:
			acc2 = 1
	if flag and flag1 and flaga and flag1a and (n - k == i):
		print(1)
		print(n - k, k)
	else:
		print(acc1 + acc2)
		if flag and flag1:
			print(n - k, k)
		if flaga and flag1a:
			print(i, n - i)


for __ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	mx = [0] * n
	mn = [0] * n
	c = [0] * (n + 2)
	a = 1
	for i in range(n):
		c[ar[i]] += 1
		if c[ar[i]] > 1:
			break
		while a < n + 1:
			if c[a] == 0:
				break
			a += 1
		mn[i] = a
	temp = 0
	for i in range(n):
		if temp < ar[i]:
			temp = ar[i]
		mx[i] = temp + 1
	mx1 = [0] * n
	mn1 = [0] * n
	c1 = [0] * (n + 2)
	a = 1
	ar = ar[::-1]
	for i in range(n):
		c1[ar[i]] += 1
		if c1[ar[i]] > 1:
			break
		while a < n + 1:
			if c1[a] == 0:
				break
			a += 1
		mn1[i] = a
	temp = 0
	for i in range(n):
		if temp < ar[i]:
			temp = ar[i]
		mx1[i] = temp + 1
	mx1 = mx1[::-1]
	mn1 = mn1[::-1]
	ans = []
	for i in range(n - 1):
		if mx[i] == mn[i] and mx1[i + 1] == mn1[i + 1]:
			ans.append([i + 1, n - i - 1])
	print(len(ans))
	if len(ans) > 0:
		for i in range(len(ans)):
			print(*ans[i])


from sys import stdin, stdout
from collections import defaultdict, Counter
from functools import lru_cache
from math import gcd, floor, ceil

def ilist():
	return [int(x) for x in stdin.readline().strip().split(' ')]

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

def istr():
	return stdin.readline().strip()
t = iint()
for _x in range(t):
	res = []
	n = iint()
	arr = ilist()
	(s1, s2) = (set(), set())
	choice = set()
	maxi = 0
	for (i, x) in enumerate(arr, 1):
		if x in s1:
			break
		s1.add(x)
		maxi = max(maxi, x)
		if maxi == len(s1):
			choice.add((i, n - i))
	maxi = 0
	for (i, x) in enumerate(arr[::-1], 1):
		if x in s2:
			break
		s2.add(x)
		maxi = max(maxi, x)
		if maxi == len(s2):
			if (n - i, i) in choice:
				res.append((n - i, i))
	print(len(res))
	for (x, y) in res:
		print(x, y)


import sys
input = sys.stdin.readline
testcaseNum = int(input())
for testcase in range(testcaseNum):
	n = int(input())
	a = list(map(int, input().split()))
	front = [False] * n
	used = [False] * n
	mi = n
	ma = -1
	for i in range(n):
		if used[a[i]]:
			break
		used[a[i]] = True
		if a[i] < mi:
			mi = a[i]
		if a[i] > ma:
			ma = a[i]
		if mi == 1 and ma == i + 1:
			front[i] = True
	back = [False] * n
	used = [False] * n
	mi = n
	ma = -1
	for i in range(n - 1, -1, -1):
		if used[a[i]]:
			break
		used[a[i]] = True
		if a[i] < mi:
			mi = a[i]
		if a[i] > ma:
			ma = a[i]
		if mi == 1 and ma == n - i:
			back[i] = True
	res = []
	for i in range(n - 1):
		if front[i] and back[i + 1]:
			res.append(i + 1)
	print(len(res))
	for e in res:
		print(e, n - e)


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
import string

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

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

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

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

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

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
for _ in range(ii()):
	n = ii()
	d = li()
	left = set()
	f = set()
	s = 0
	for i in range(n - 1):
		s += d[i]
		f.add(d[i])
		j = i + 1
		if len(f) != j:
			break
		if s == j * (j + 1) // 2:
			left.add(i)
	f = set()
	s = 0
	res = []
	for i in range(n - 1, 0, -1):
		s += d[i]
		f.add(d[i])
		j = n - i
		if len(f) != j:
			break
		if s == j * (j + 1) // 2 and i - 1 in left:
			res.append(f'{i} {j}')
	print(len(res))
	if len(res) > 0:
		prr(res, '\n')


def get():
	return int(input())
t = get()
while t > 0:
	n = get()
	a = list(map(int, input().split()))
	sum = 0
	s = set()
	s2 = set()
	mp = dict()
	for i in a:
		mp[i] = 0
	for i in a:
		sum += i
		mp[i] = mp[i] + 1
		s2.add(i)
	x = 0
	ans = []
	for i in a:
		s.add(i)
		x += i
		y = len(s)
		mp[i] = mp[i] - 1
		if mp[i] == 0:
			s2.remove(i)
		if y * (y + 1) / 2 == x:
			y = len(s2)
			if y * (y + 1) / 2 == sum - x:
				ans.append([n - y, y])
	print(len(ans))
	for i in ans:
		print(f'{i[0]} {i[1]}')
	t = t - 1


class Seq:

	def __init__(self):
		self.max = 0
		self.count = 0

	def add(self, v):
		self.max = max(v, self.max)
		self.count += 1

	def __bool__(self):
		return self.max == self.count

def tsk():
	n = int(input())
	orig = list(map(int, input().split()))
	p2 = dict()
	e1 = 0
	for i in range(n):
		if orig[i] in p2.keys():
			e1 = i + 1
			p2[orig[i]] += 1
			break
		else:
			p2[orig[i]] = 1
	for i in range(e1 + 1, n):
		if orig[i] in p2.keys():
			p2[orig[i]] += 1
		else:
			p2[orig[i]] = 1
		if p2[orig[i]] > 2:
			print(0)
			return
	L = set()
	s1 = Seq()
	for i in range(e1):
		s1.add(orig[i])
		if s1:
			L.add(i + 1)
	e2 = n - 1
	p2 = set()
	s2 = Seq()
	for i in range(n - 1, -1, -1):
		if orig[i] in p2:
			e2 = i
			break
		p2.add(orig[i])
		s2.add(orig[i])
		if not s2:
			L.discard(i)
	LC = []
	for l in L:
		if e2 < l < e1:
			LC.append(l)
	print(len(LC))
	for l in LC:
		print(l, n - l)
t = int(input())
for _ in range(t):
	tsk()


t = int(input())
for j in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	q = max(a)
	A = a[0:q]
	counter = [0] * q
	limit = q
	i1 = 0
	while i1 < q:
		if not 1 <= A[i1] <= limit:
			break
		elif counter[A[i1] - 1] != 0:
			break
		else:
			counter[A[i1] - 1] = 1
			i1 += 1
	A = a[q:n]
	counter = [0] * (n - q)
	limit = n - q
	i2 = 0
	while i2 < n - q:
		if not 1 <= A[i2] <= limit:
			break
		elif counter[A[i2] - 1] != 0:
			break
		else:
			counter[A[i2] - 1] = 1
			i2 += 1
	A = a[0:n - q]
	counter = [0] * (n - q)
	limit = n - q
	i3 = 0
	while i3 < n - q:
		if not 1 <= A[i3] <= limit:
			break
		elif counter[A[i3] - 1] != 0:
			break
		else:
			counter[A[i3] - 1] = 1
			i3 += 1
	A = a[n - q:n]
	counter = [0] * q
	limit = q
	i4 = 0
	while i4 < q:
		if not 1 <= A[i4] <= limit:
			break
		elif counter[A[i4] - 1] != 0:
			break
		else:
			counter[A[i4] - 1] = 1
			i4 += 1
	if i1 + i2 == n and i3 + i4 == n:
		if 2 * q == n:
			print(1)
			print(i1, i2)
		else:
			print(2)
			print(i1, i2)
			print(i3, i4)
	elif i1 + i2 == n:
		print(1)
		print(i1, i2)
	elif i3 + i4 == n:
		print(1)
		print(i3, i4)
	else:
		print(0)


from sys import stdin
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin

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

def fi():
	return float(stdin.readline())

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

def fmi():
	return map(float, stdin.readline().split())

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

def lsi():
	x = list(stdin.readline())
	x.pop()
	return x

def si():
	return stdin.readline()

def create_z(s):
	z = [0] * len(s)
	x = y = 0
	for i in range(1, len(s)):
		z[i] = max(0, min(z[i - x], y - i + 1))
		while i + z[i] < len(s) and s[z[i]] == s[i + z[i]]:
			x = i
			y = i + z[i]
			z[i] += 1
	return z
for _ in range(ii()):
	n = ii()
	s = li()
	a = [s[0]]
	for i in range(1, n):
		a.append(a[i - 1] + s[i])
	res = []
	for i in range(1, n):
		if a[i - 1] == i * (i + 1) // 2 and a[-1] - a[i - 1] == (n - i) * (n - i + 1) // 2:
			res.append([i, n - i])
	ans = []
	for i in res:
		if sorted(s[:i[0]]) == [z for z in range(1, i[0] + 1)] and sorted(s[i[0]:]) == [z for z in range(1, 1 + i[1])]:
			ans.append(i)
	print(len(ans))
	for i in ans:
		print(*i)


def seq(list):
	list = sorted(list)
	for i in range(1, len(list) + 1):
		if i == list[i - 1]:
			continue
		else:
			return False
	return True
import sys
num = int(sys.stdin.readline().strip())
k = 0
while k < num:
	line1 = sys.stdin.readline().strip()
	line2 = sys.stdin.readline().strip()
	a = line2.split()
	ans = []
	for i in range(len(a)):
		a[i] = int(a[i])
	ma = max(a)
	if seq(a[:ma]) and seq(a[ma:]):
		ans.append((ma, len(a) - ma))
	if ma != len(a) - ma:
		if seq(a[:len(a) - ma]) and seq(a[len(a) - ma:]):
			ans.append((len(a) - ma, ma))
	print(len(ans))
	for item in ans:
		print(item[0], item[1])
	k += 1


from sys import stdin
input = stdin.readline
T = int(input())
for _ in range(T):
	(n, p) = (int(input()), list(map(int, input().split())))
	(la, ra) = ([0] * n, [0] * n)
	(lS, rS) = (set(), set())
	(lmx, rmx) = (0, 0)
	for i in range(n):
		lS.add(p[i])
		lmx = max(lmx, p[i])
		rS.add(p[n - i - 1])
		rmx = max(rmx, p[n - i - 1])
		if len(lS) == i + 1 and lmx == i + 1:
			la[i] = 1
		if len(rS) == i + 1 and rmx == i + 1:
			ra[n - i - 1] = 1
	res = []
	for i in range(1, n):
		if la[i - 1] and ra[i]:
			res.append(i)
	print(len(res))
	for u in res:
		print(u, n - u)


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')
testcases = int(input())
for j in range(testcases):
	n = int(input())
	ints = list(map(int, input().split()))
	counts = [0 for k in range(max(ints))]
	for h in range(n):
		counts[ints[h] - 1] += 1
	highestsofar = 0
	indexhigh = 0
	for s in range(len(counts)):
		if counts[s] == 2:
			indexhigh = s
	highest = indexhigh + 1
	checker = 0
	output1 = []
	output2 = []
	same = False
	if max(ints) == highest:
		same = True
	if sorted(ints[0:highest]) == list(range(1, highest + 1)) and sorted(ints[highest:]) == list(range(1, max(ints) + 1)):
		checker += 1
		output1 += [str(highest), str(max(ints))]
	if sorted(ints[0:max(ints)]) == list(range(1, max(ints) + 1)) and sorted(ints[max(ints):]) == list(range(1, highest + 1)):
		checker += 1
		output2 += [str(max(ints)), str(highest)]
	if checker == 0:
		print(0)
	elif checker == 1:
		print(1)
		if len(output1) != 0:
			print(' '.join(output1))
		if len(output2) != 0:
			print(' '.join(output2))
	elif checker == 2 and same == False:
		print(2)
		if len(output1) != 0:
			print(' '.join(output1))
		if len(output2) != 0:
			print(' '.join(output2))
	elif checker == 2 and same == True:
		print(1)
		print(' '.join(output1))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))[:n]
	x = 0
	k = 0
	l1 = max(a)
	l2 = n - l1
	if l1 == n:
		print(0)
	else:
		p = sorted(a[:l1])
		q = sorted(a[l1:])
		r = sorted(a[:l2])
		s = sorted(a[l2:])
		A = [i for i in range(1, l1 + 1)]
		B = [i for i in range(1, l2 + 1)]
		if p == A and q == B:
			x += 1
			k = l1
		if r == B and s == A:
			x += 1
			k = l2
		if l1 == l2 and x > 0:
			x = 1
		print(x)
		if x == 1:
			print(k, n - k)
		elif x == 2:
			print(l1, l2)
			print(l2, l1)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	(a, r) = ([], [])
	d = [0 for _ in range(n + 1)]
	for i in range(n):
		if d[l[i]] == 1:
			x = i
			break
		else:
			d[l[i]] = 1
			a.append(l[i])
	b = l[i:].copy()
	a.sort()
	b.sort()
	f = 0
	for i in range(1, x + 1):
		if a[i - 1] != i:
			f = 1
			break
	if f == 0:
		for i in range(1, n - x + 1):
			if b[i - 1] != i:
				f = 1
				break
		if f == 0:
			r.append([x, n - x])
	l.reverse()
	a = []
	d = [0 for _ in range(n + 1)]
	for i in range(n):
		if d[l[i]] == 1:
			x = i
			break
		else:
			d[l[i]] = 1
			a.append(l[i])
	b = l[i:].copy()
	a.sort()
	b.sort()
	f = 0
	for i in range(1, x + 1):
		if a[i - 1] != i:
			f = 1
			break
	if f == 0:
		for i in range(1, n - x + 1):
			if b[i - 1] != i:
				f = 1
				break
		if f == 0:
			if [n - x, x] not in r:
				r.append([n - x, x])
	print(len(r))
	for i in r:
		print(*i)


import sys
from collections import defaultdict as dc
import math
from bisect import bisect, bisect_left, bisect_right
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	p = max(l)
	q = n - p
	x = dc(int)
	c = 0
	t = []
	f1 = 1
	for i in range(p):
		x[l[i]] = 1
	for i in range(1, p + 1):
		if x[i] == 1:
			continue
		else:
			f1 = 0
			break
	if f1:
		x = dc(int)
		for i in range(n - 1, n - q - 1, -1):
			x[l[i]] = 1
		for i in range(1, q + 1):
			if x[i] == 1:
				continue
			else:
				f1 = 0
				break
		if f1:
			c += 1
			t.append([p, q])
	f2 = 1
	x = dc(int)
	for i in range(n - 1, n - p - 1, -1):
		x[l[i]] = 1
	for i in range(1, p + 1):
		if x[i] == 1:
			continue
		else:
			f2 = 0
			break
	if f2:
		x = dc(int)
		for i in range(q):
			x[l[i]] = 1
		for i in range(1, q + 1):
			if x[i] == 1:
				continue
			else:
				f2 = 0
				break
		if f2:
			c += 1
			t.append([q, p])
	if p == q:
		if c > 0:
			c -= 1
			t.pop()
	print(c)
	for i in range(c):
		print(*t[i])


t = int(input())
for _ in range(t):
	n = int(input())
	ary = list(map(int, input().split()))
	v = 1
	z = 0
	h = 0
	arys = sorted(ary)
	arys1 = sorted(ary[:arys[n - 1]])
	arys2 = sorted(ary[arys[n - 1]:])
	for i in range(1, n - arys[n - 1] + 1):
		if arys2[i - 1] != i:
			z += 1
			break
	if z != 1:
		for i in range(1, arys[n - 1] + 1):
			if arys1[i - 1] != i:
				z += 1
				break
	arys1 = sorted(ary[:n - arys[n - 1]])
	arys2 = sorted(ary[n - arys[n - 1]:])
	for i in range(1, arys[n - 1] + 1):
		if arys2[i - 1] != i:
			h += 1
			break
	if h != 1:
		for i in range(1, n - arys[n - 1] + 1):
			if arys1[i - 1] != i:
				h += 1
				break
	if z == 1 and h == 1:
		print('0')
	elif z == 1 and h == 0:
		print('1')
		print(n - arys[n - 1], arys[n - 1])
	elif z == 0 and h == 1:
		print('1')
		print(arys[n - 1], n - arys[n - 1])
	elif z == 0 and h == 0:
		if n - arys[n - 1] == arys[n - 1]:
			print('1')
			print(n - arys[n - 1], arys[n - 1])
		else:
			print('2')
			print(n - arys[n - 1], arys[n - 1])
			print(arys[n - 1], n - arys[n - 1])


import sys
from collections import Counter

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

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

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

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

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

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

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

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

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7

def check(A):
	S = set()
	div = False
	x = -1
	for (i, a) in enumerate(A):
		if a in S:
			if div or max(S) != i:
				return -1
			else:
				div = True
				x = i
				S = set([a])
		else:
			S.add(a)
	if x + max(S) == N:
		return x
	else:
		return -1
for _ in range(INT()):
	N = INT()
	A = LIST()
	res1 = check(A)
	res2 = check(A[::-1])
	if res2 != -1:
		res2 = N - res2
	if res1 != -1 and res2 != -1:
		if res1 != res2:
			print(2)
			print(res1, N - res1)
			print(res2, N - res2)
		else:
			print(1)
			print(res1, N - res1)
	elif res1 != -1:
		print(1)
		print(res1, N - res1)
	elif res2 != -1:
		print(1)
		print(res2, N - res2)
	else:
		print(0)


for _ in range(int(input())):
	n = int(input())
	data = list(map(int, input().split(' ')))
	front_list = {}
	temp = {}
	max_value = 0
	length = 0
	for i in data:
		max_value = max(max_value, i)
		length += 1
		if i not in temp:
			temp[i] = 1
			if length == max_value:
				front_list[length] = 1
		else:
			break
	data.reverse()
	temp = {}
	max_value = 0
	length = 0
	result_count = 0
	result = []
	for i in data:
		max_value = max(max_value, i)
		length += 1
		if i not in temp:
			temp[i] = 1
			if length == max_value:
				if n - length in front_list:
					result_count += 1
					result.append((n - length, length))
		else:
			break
	print(result_count)
	for i in result:
		print(i[0], i[1])


def check1(a, m, n):
	ct = [0] * m
	f = 0
	for i in range(m):
		if a[i] > m:
			f = 1
			break
		ct[a[i] - 1] += 1
		if ct[a[i] - 1] != 1:
			f = 1
			break
	for i in ct:
		if i != 1:
			f = 1
			break
	if f == 1:
		return 0
	f = 0
	ct = [0] * max(a)
	for i in range(m, len(a)):
		ct[a[i] - 1] += 1
		if ct[a[i] - 1] != 1:
			f = 1
			break
	for i in ct:
		if i != 1:
			f = 1
			break
	if f == 1:
		return 0
	return 1

def check2(a, m, n):
	ct = [0] * n
	f = 0
	for i in range(m, len(a)):
		if a[i] > n:
			f = 1
			break
		ct[a[i] - 1] += 1
		if ct[a[i] - 1] != 1:
			f = 1
			break
	for i in ct:
		if i != 1:
			f = 1
			break
	if f == 1:
		return 0
	ct = [0] * max(a)
	for i in range(m):
		ct[a[i] - 1] += 1
		if ct[a[i] - 1] != 1:
			f = 1
			break
	for i in ct:
		if i != 1:
			f = 1
			break
	if f == 1:
		return 0
	return 1
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().strip().split()))
	count = [0] * max(a)
	for j in range(n):
		count[a[j] - 1] += 1
	m = 0
	while m < len(count) and count[m] == 2:
		m += 1
	flag = 0
	for j in range(m, len(count)):
		if count[j] != 1:
			flag = 1
			break
	if flag == 1:
		print(0)
	elif m == 0:
		print(0)
	else:
		a0 = check1(a, m, len(count))
		b = check2(a, len(count), m)
		if a0 == 1 and b == 1 and (m != len(count)):
			print(2)
			print(m, len(count))
			print(len(count), m)
		elif a0 == 1:
			print(1)
			print(m, len(count))
		elif b == 1:
			print(1)
			print(len(count), m)
		elif a0 == 0 and b == 0:
			print(0)


def create_farr():
	mx = max(arr)
	carr = [0 for _ in range(mx)]
	farr = []
	fm = 1
	for (i, x) in enumerate(arr):
		carr[x - 1] += 1
		if carr[x - 1] == 2:
			while len(farr) < n:
				farr.append(False)
			break
		if fm == x:
			for j in range(fm, mx + 1):
				if j == mx or not carr[j]:
					fm = j + 1
					break
		if fm > i + 1:
			farr.append(fm - 1)
		else:
			farr.append(False)
	return farr

def create_barr():
	mx = max(arr)
	carr = [0 for _ in range(mx)]
	barr = []
	fm = 1
	for (i, x) in enumerate(reversed(arr)):
		carr[x - 1] += 1
		if carr[x - 1] == 2:
			while len(barr) < n:
				barr.append(False)
			break
		if fm == x:
			for j in range(fm, mx + 1):
				if j == mx or not carr[j]:
					fm = j + 1
					break
		if fm > i + 1:
			barr.append(fm - 1)
		else:
			barr.append(False)
	return list(reversed(barr))
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	farr = create_farr()
	barr = create_barr()
	coll = []
	for i in range(n - 1):
		if farr[i] and barr[i + 1]:
			coll.append((farr[i], barr[i + 1]))
	print(len(coll))
	for t in coll:
		print(*t)


def readIntArray():
	return list(map(int, input().split()))
t = int(input())
for _ in range(t):
	n = int(input())
	a = readIntArray()
	mp = {}
	for val in a:
		if val not in mp:
			mp[val] = 0
		mp[val] += 1
	l1 = max(a)
	l2 = n - l1
	if l2 <= 0:
		print(0)
		continue
	good = True
	for i in range(1, l2 + 1):
		if i not in mp or mp[i] != 2:
			good = False
			break
	for i in range(l2 + 1, l1 + 1):
		if i not in mp or mp[i] != 1:
			good = False
			break
	if not good:
		print(0)
		continue
	mp = {}
	ans = set()
	cur = 0
	st = set()
	used = set()
	for i in range(n):
		if a[i] in used:
			break
		st.add(a[i])
		used.add(a[i])
		while cur + 1 in st:
			st.remove(cur + 1)
			cur += 1
		if cur == l1 or (cur == l2 and len(st) == 0):
			ans.add((cur, n - cur))
	print(len(ans))
	for val in ans:
		print(val[0], val[1])


def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		first_max_num = max(a)
		second_max_num = n - first_max_num
		counter = int()
		res = str()
		if first_max_num * second_max_num != 0:
			left = set(a[:first_max_num])
			right = set(a[first_max_num:])
			if len(left) == first_max_num and max(left) == first_max_num and (len(right) == second_max_num) and (max(right) == second_max_num):
				counter += 1
				res += f'{len(left)} {len(right)}\n'
			if first_max_num != second_max_num:
				left = set(a[:second_max_num])
				right = set(a[second_max_num:])
				if len(left) == second_max_num and max(left) == second_max_num and (len(right) == first_max_num) and (max(right) == first_max_num):
					counter += 1
					res += f'{len(left)} {len(right)}\n'
		print(counter)
		if counter:
			print(res.strip())
main()


t = int(input())
from heapq import heappush as pu
from heapq import heappop as po
for _ in range(t):
	n = int(input())
	a = [0] + list(map(int, input().split()))
	c = [False for i in range(n + 1)]
	an = []
	tr = set()
	d = []
	for i in range(1, n + 1):
		pu(d, a[i])
		while d:
			x = po(d)
			if x <= i:
				tr.add(x)
			else:
				pu(d, x)
				break
		if len(tr) == i:
			c[i] = True
	cc = [False for i in range(n + 1)]
	an = []
	tr = set()
	d = []
	for i in range(n, 0, -1):
		j = n + 1 - i
		pu(d, a[i])
		while d:
			x = po(d)
			if x <= j:
				tr.add(x)
			else:
				pu(d, x)
				break
		if len(tr) == j:
			cc[i] = True
	for i in range(1, n):
		if c[i] and cc[i + 1]:
			an.append((i, n - i))
	print(len(an))
	for i in an:
		print(*i)


def disp(a):
	for i in range(len(a)):
		print(a[i], end=' ')
	print()
t = int(input())
for k in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	setf = set(a)
	count = 0
	ans = [[]]
	eh = max(a)
	he = len(a) - len(setf)
	for i in range(1, n):
		if i != eh and i != he:
			continue
		temp = a[:i]
		temp2 = a[i:]
		set1 = set(temp)
		set2 = set(temp2)
		if len(set1) != len(temp) or len(set2) != len(temp2):
			continue
		if max(temp) == i and max(temp2) == n - i:
			count += 1
			ans.append([len(temp), len(temp2)])
	print(count)
	num = 0
	for i in ans:
		if num > 0:
			print(i[0], end=' ')
			print(i[1])
		num += 1


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	mp = Counter(a)
	maxi = -1
	fr = [0] * n
	lst = [0] * n
	fr[0] = a[0]
	lst[n - 1] = a[n - 1]
	for i in range(1, n):
		if fr[i - 1] < a[i]:
			fr[i] = a[i]
		else:
			fr[i] = fr[i - 1]
	for i in range(n - 2, -1, -1):
		if lst[i + 1] > a[i]:
			lst[i] = lst[i + 1]
		else:
			lst[i] = a[i]
	ls = set(mp.keys())
	fs = set()
	path = []
	count = 0
	for i in range(n):
		fs.add(a[i])
		if mp[a[i]] == 1:
			ls.remove(a[i])
		if len(fs) == fr[i] and i + 1 == fr[i]:
			if len(ls) == lst[i + 1] and n - i - 1 == lst[i + 1]:
				count += 1
				path.append([fr[i], lst[i + 1]])
	print(count)
	for e in path:
		print(e[0], e[1])


import math as mt
import sys, string, bisect
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
t = I()
for _ in range(t):
	n = I()
	l = L()
	d = defaultdict(int)
	s = defaultdict(int)
	flag = 0
	c = 0
	r = []
	key = 0
	for i in range(n):
		d[l[i]] += 1
		if d[l[i]] == 2:
			d[l[i]] -= 1
			key = i
			break
	if key == 0:
		print(0)
	else:
		for i in range(key):
			if d[i + 1] != 1:
				flag = 1
				break
		if flag == 0:
			w = l[key::1]
			w.sort()
			for i in range(len(w)):
				if w[i] != i + 1:
					flag = 1
					break
			if flag == 0:
				c += 1
				r.append((key, n - key))
		x = l[-1::-1]
		flag = 0
		key = 0
		for i in range(n):
			s[x[i]] += 1
			if s[x[i]] == 2:
				s[x[i]] -= 1
				key = i
				break
		for j in range(key):
			if s[j + 1] != 1:
				flag = 1
				break
		if flag == 0:
			w = x[key:]
			w.sort()
			for i in range(len(w)):
				if w[i] != i + 1:
					flag = 1
					break
			if flag == 0:
				c += 1
				r.append((n - key, key))
		if c != 0:
			r = set(r)
			c = len(r)
		print(c)
		for i in r:
			print(*i)


for case in range(int(input())):
	N = int(input())
	L = list(map(int, input().split()))
	back = [False for i in range(N)]
	mis = set()
	ma = 0
	for i in range(N - 1, 0, -1):
		num = L[i]
		if num > ma:
			for j in range(ma + 1, num):
				mis.add(j)
			ma = num
		else:
			if num not in mis:
				break
			mis.remove(num)
		if len(mis) == 0:
			back[i] = True
	out = []
	mis = set()
	ma = 0
	for i in range(N - 1):
		num = L[i]
		if num > ma:
			for j in range(ma + 1, num):
				mis.add(j)
			ma = num
		else:
			if num not in mis:
				break
			mis.remove(num)
		if len(mis) == 0 and back[i + 1]:
			out.append((i + 1, N - i - 1))
	print(len(out))
	for (l1, l2) in out:
		print(l1, l2)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	c = Counter(x)
	u1 = set((v for v in c if c[v] == 1))
	u2 = set((v for v in c if c[v] == 2))
	l1 = len(u1)
	l2 = len(u2)
	if not l2 or l1 + 2 * l2 != n:
		print(0)
	elif u2 != set(range(1, l2 + 1)):
		print(0)
	elif u1 != set(range(l2 + 1, n - l2 + 1)):
		print(0)
	else:
		r = []
		if set(x[:l2]) == u2:
			r.append((l2, n - l2))
		if l1 and set(x[-l2:]) == u2:
			r.append((n - l2, l2))
		print(len(r))
		for v in r:
			print(*v)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	p1 = [0] * n
	p2 = [0] * n
	s = 0
	ctr = 0
	max = 1
	sett = set()
	c = 0
	for i in a:
		s += i
		ctr += 1
		if i in sett:
			break
		if ctr * (ctr + 1) // 2 == s:
			p1[c] = 1
		else:
			p1[c] = 0
		sett.add(i)
		c += 1
	a.reverse()
	c = 0
	s = 0
	ctr = 0
	sett1 = set()
	for i in a:
		s += i
		ctr += 1
		if i in sett1:
			break
		if ctr * (ctr + 1) // 2 == s:
			p2[c] = 1
		else:
			p2[c] = 0
		sett1.add(i)
		c += 1
	p2.reverse()
	p3 = []
	ans = []
	for i in range(n):
		if p1[i] == 1 and p2[i + 1] == 1:
			ans.append([i + 1, n - i - 1])
	print(len(ans))
	for i in ans:
		print(i[0], i[1])


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = [0] + a[:]
	left = [0] * (n + 1)
	right = [0] * (n + 1)
	ma = 1
	d = {}
	for i in range(1, n + 1):
		if b[i] in d:
			break
		d[b[i]] = 1
		ma = max(ma, b[i])
		if ma == i:
			left[i] = 1
	b = [0] + a[::-1]
	ma = 1
	d = {}
	for i in range(1, n + 1):
		if b[i] in d:
			break
		d[b[i]] = 1
		ma = max(ma, b[i])
		if ma == i:
			right[i] = 1
	ans = 0
	ind = []
	for i in range(1, n + 1):
		if left[i] * right[n - i]:
			ans += 1
			ind.append(i)
	print(ans)
	for i in ind:
		print(i, n - i)


from collections import defaultdict
tc = int(input())
for zzz in range(tc):
	svn = defaultdict(int)
	zah = defaultdict(int)
	n = int(input())
	arr = list(map(int, input().split()))
	left = [0] * n
	right = [0] * n
	deci = True
	sum1 = 0
	sum2 = 0
	for i in range(n):
		sum1 += i + 1
		sum2 += arr[i]
		if svn[arr[i]] != 0:
			deci = False
		svn[arr[i]] += 1
		if sum1 == sum2 and deci:
			left[i] = 1
	sum1 = 0
	sum2 = 0
	deci = True
	for i in range(n - 1, -1, -1):
		sum1 += n - 1 - i + 1
		sum2 += arr[i]
		if zah[arr[i]] != 0:
			deci = False
		zah[arr[i]] += 1
		if sum1 == sum2 and deci:
			right[i] = 1
	coun = 0
	ans = []
	for i in range(0, n - 1):
		if left[i] == 1 and right[i + 1] == 1:
			coun += 1
			ans.append((i + 1, n - (i + 1)))
	print(coun)
	for ele in ans:
		print(ele[0], ele[1])


import sys
from sys import stdin, stdout

def R():
	return map(int, stdin.readline().strip().split())
ans = []
for h in range(int(input())):
	n = int(input())
	arr = list(R())
	dp1 = [0 for i in range(n)]
	dp2 = [0 for i in range(n)]
	seti = set()
	maxi = 0
	for i in range(n):
		if arr[i] in seti:
			break
		seti.add(arr[i])
		maxi = max(arr[i], maxi)
		if maxi == i + 1:
			dp1[i] = 1
	seti = set()
	maxi = 0
	for i in range(n - 1, -1, -1):
		if arr[i] in seti:
			break
		seti.add(arr[i])
		maxi = max(arr[i], maxi)
		if maxi == n - i:
			dp2[i] = 1
	t = []
	tot = 0
	for i in range(n - 1):
		if dp1[i] == dp2[i + 1] == 1:
			tot += 1
			t.append((i + 1, n - i - 1))
	print(tot)
	if tot:
		for i in t:
			print(*i)


from math import *
mod = 1000000007
for zz in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	ans = []
	cs = set()
	d = {}
	c = 0
	for i in range(n):
		if a[i] not in d:
			c += 1
			d[a[i]] = 0
		d[a[i]] += 1
	mv = 0
	m = [0] * n
	m[-1] = a[-1]
	for i in range(n - 2, -1, -1):
		m[i] = max(m[i + 1], a[i])
	for i in range(n):
		mv = max(a[i], mv)
		if a[i] in cs:
			break
		cs.add(a[i])
		d[a[i]] -= 1
		if d[a[i]] <= 0:
			c -= 1
		if mv == i + 1 and c == n - i - 1 and (m[i + 1] == n - i - 1):
			ans.append(i)
	print(len(ans))
	for i in ans:
		print(i + 1, n - i - 1)


from sys import stdin
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	arr = list(map(int, stdin.readline().rstrip().split(' ')))
	m = max(arr)
	answer = 0
	l = [i + 1 for i in range(m)]
	s = [i + 1 for i in range(n - m)]
	flag1 = False
	flag2 = False
	if set(l) == set(arr[:m]) and set(s) == set(arr[m:]):
		answer += 1
		flag1 = True
	if set(l) == set(arr[n - m:]) and set(s) == set(arr[:n - m]) and (n - m != m):
		answer += 1
		flag2 = True
	print(answer)
	if flag1:
		print(m, n - m)
	if flag2:
		print(n - m, m)


from sys import stdin
for _ in ' ' * int(stdin.readline()):
	a = int(stdin.readline())
	z = list(map(int, stdin.readline().split()))
	k = max(z)
	k1 = a - k
	f = []
	u = [*range(1, k + 1)]
	v = [*range(1, k1 + 1)]
	if u == sorted(z[:k]) and v == sorted(z[k:]):
		f += [[k, k1]]
	if v == sorted(z[:k1]) and u == sorted(z[k1:]):
		f += [[k1, k]]
	if len(f) == 2:
		if f[0] == f[1]:
			f.pop()
	print(len(f))
	for i in f:
		print(*i)


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

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

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

def inputstring():
	return [x for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d

def permutation(arr, n):
	s = set()
	maxEle = 0
	for i in range(n):
		s.add(arr[i])
		maxEle = max(maxEle, arr[i])
	if maxEle != n:
		return False
	if len(s) == n:
		return True
	return False
t = int(input())
for q in range(t):
	n = inputnum()
	a = inputlist()
	count = 0
	ans1 = []
	ans2 = []
	a1 = sorted(a)
	mx = a1[n - 1]
	b = a[:mx]
	c = a[mx:]
	d = a[:n - mx]
	e = a[n - mx:]
	if permutation(b, mx) and permutation(c, n - mx):
		count += 1
		ans1.append(mx)
		ans2.append(n - mx)
	if mx != n - mx:
		if permutation(d, n - mx) and permutation(e, mx):
			count += 1
			ans1.append(n - mx)
			ans2.append(mx)
	print(count)
	for i in range(count):
		print(ans1[i], ans2[i])


import sys
input = lambda : sys.stdin.readline().strip()
ipnut = input
for i in range(int(input())):
	n = int(ipnut())
	a = list(map(int, ipnut().split()))
	ans = []
	s = {}
	ma = a[0]
	f = False
	u = [0] * n
	for j in a:
		u[j - 1] += 1
	must = 2
	an = 0
	f = False
	flag = True
	k = -1
	for i in u:
		k += 1
		if must < i:
			f = True
			break
		elif flag and i <= 1:
			an = k
			flag = False
		must = i
	if f or an == n or an == 0:
		print(0)
		continue
	f1 = True
	f2 = True
	t = [0] * n
	t1 = [0] * n
	for i in range(an):
		if a[i] > an or t[a[i] - 1]:
			f1 = False
		if a[-1 - i] > an or t1[a[-1 - i] - 1]:
			f2 = False
		t[a[i] - 1] += 1
		t1[a[-1 - i] - 1] += 1
	print(max(0, f1 + f2 - int(an == n - an)))
	if f1:
		print(an, n - an)
	if f2 and an != n - an:
		print(n - an, an)


t = int(input())
for test in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	min1 = [0 for i in range(n)]
	min2 = [0 for i in range(n)]
	max1 = [0 for i in range(n)]
	max2 = [0 for i in range(n)]
	visited = [False for i in range(n + 5)]
	asc = [False for i in range(n)]
	asc[0] = True
	visited[arr[0]] = True
	for i in range(1, n):
		if visited[arr[i]]:
			asc[i] = False
		else:
			visited[arr[i]] = True
			asc[i] = asc[i - 1]
	visited = [False for i in range(n + 5)]
	desc = [False for i in range(n)]
	desc[n - 1] = True
	visited[arr[n - 1]] = True
	for i in range(n - 2, -1, -1):
		if visited[arr[i]]:
			desc[i] = False
		else:
			visited[arr[i]] = True
			desc[i] = desc[i + 1]
	min1[0] = arr[0]
	max1[0] = arr[0]
	for i in range(1, n):
		min1[i] = min(min1[i - 1], arr[i])
		max1[i] = max(max1[i - 1], arr[i])
	min2[n - 1] = arr[n - 1]
	max2[n - 1] = arr[n - 1]
	for i in range(n - 2, -1, -1):
		min2[i] = min(min2[i + 1], arr[i])
		max2[i] = max(max2[i + 1], arr[i])
	res = []
	for i in range(n - 1):
		flag1 = False
		if min1[i] == 1 and max1[i] == i + 1:
			flag1 = True
		flag2 = False
		if min2[i + 1] == 1 and max2[i + 1] == n - 1 - i:
			flag2 = True
		if flag1 and flag2 and asc[i] and desc[i + 1]:
			res.append([i + 1, n - 1 - i])
	print(len(res))
	for i in range(len(res)):
		print(res[i][0], res[i][1])


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
cases = int(input())
for t in range(cases):
	n = int(input())
	a = list(map(int, input().split()))
	out = 0
	outl = []
	pos = -1
	f = 0
	f1 = []
	d1 = {}
	mv = 0
	c = 0
	p = 0
	a.append(a[-1])
	for i in range(n + 1):
		if a[i] in d1:
			if c == mv:
				p += 1
				if p == 2:
					pos = i
					f = 1
					f1 = [n - mv, mv]
				d1 = {}
				d1[a[i]] = 1
				c = 1
				mv = a[i]
			else:
				p = -1
				break
		else:
			d1[a[i]] = 1
			c += 1
			mv = max(mv, a[i])
	if p == 2 and pos == n:
		out += f
		outl.append(f1)
	pos = -1
	f = 0
	f1 = []
	d1 = {}
	mv = 0
	c = 0
	p = 0
	a = a[:-1]
	a = a[::-1]
	a.append(a[-1])
	for i in range(n + 1):
		if a[i] in d1:
			if c == mv:
				p += 1
				if p == 2:
					pos = i
					f = 1
					f1 = [mv, n - mv]
				d1 = {}
				d1[a[i]] = 1
				c = 1
				mv = a[i]
			else:
				p = -1
				break
		else:
			d1[a[i]] = 1
			c += 1
			mv = max(mv, a[i])
	if p == 2 and pos == n:
		if f1 not in outl:
			outl.append(f1)
			out += 1
	print(out)
	for (i, j) in outl:
		print(i, j)


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	ans = []
	L = set()
	S = set()
	Max = -1
	for i in range(N):
		Max = max(Max, A[i])
		S.add(A[i])
		if len(S) == i + 1 and i + 1 == Max:
			L.add(i + 1)
	S = set()
	Max = -1
	for i in range(N):
		Max = max(Max, A[-i - 1])
		S.add(A[-i - 1])
		if len(S) == i + 1 and i + 1 == Max:
			if N - i - 1 in L:
				ans.append((N - i - 1, i + 1))
	if ans:
		print(len(ans))
		for (a, b) in ans:
			print(a, b)
	else:
		print(0)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	count = 1
	s1 = set([arr[0]])
	max1 = arr[0]
	d1 = {}
	if max1 == 1:
		d1[1] = 1
	for i in range(1, n):
		max1 = max(max1, arr[i])
		s1.add(arr[i])
		count += 1
		if len(s1) == max1 and count == max1:
			d1[count] = 1
	d2 = {}
	s2 = set([arr[n - 1]])
	max2 = arr[n - 1]
	count = 1
	if max2 == 1:
		d2[1] = 1
	for i in range(n - 2, -1, -1):
		max2 = max(max2, arr[i])
		s2.add(arr[i])
		count += 1
		if len(s2) == max2 and count == max2:
			d2[max2] = 1
	dicts = []
	for i in d1:
		if n - i in d2:
			dicts.append([i, n - i])
	print(len(dicts))
	for i in dicts:
		print(*i)


t = int(input())
for i in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	number = sum(a)
	ans1 = []
	ans2 = []
	k = 0
	flag = [False] * n
	num = 0
	ans = 0
	for j in range(0, n):
		if flag[a[j] - 1]:
			break
		flag[a[j] - 1] = True
		num += 1
		while flag[k] and k < n:
			k += 1
		if k == num and num != 0:
			if ans != 0:
				if ans1[ans - 1] != num:
					ans1.append(k)
					ans += 1
			else:
				ans1.append(k)
				ans += 1
	k = 0
	flag = [False] * n
	num = 0
	a.reverse()
	ans = 0
	for j in range(0, n):
		if flag[a[j] - 1]:
			break
		flag[a[j] - 1] = True
		num += 1
		while flag[k] and k < n:
			k += 1
		if k == num and num != 0:
			if ans != 0:
				if ans2[ans - 1] != n - num:
					ans2.append(n - k)
					ans += 1
			else:
				ans2.append(n - k)
				ans += 1
	lg1 = len(ans1)
	lg2 = len(ans2)
	ans2.reverse()
	ansarr = []
	ans = 0
	for j in range(0, lg1):
		l = 0
		r = lg2 - 1
		if lg2 == 0:
			break
		while r - l > 1:
			m = (r + l) // 2
			if ans2[m] > ans1[j]:
				r = m
			else:
				l = m
		if ans2[l] == ans1[j]:
			ansarr.append([ans1[j], n - ans1[j]])
			ans += 1
		elif ans2[r] == ans1[j]:
			ansarr.append([ans1[j], n - ans1[j]])
			ans += 1
	print(ans)
	for j in range(0, ans):
		print(*ansarr[j])


def perm(l, k):
	d = set(l)
	if len(d) == k:
		if max(d) == k:
			return True
		else:
			return False
	else:
		return False
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = max(l)
	ans = []
	if n - d != d:
		if perm(l[:d], d) and perm(l[d:], n - d):
			ans.append([d, n - d])
		if perm(l[n - d:], d) and perm(l[:n - d], n - d):
			ans.append([n - d, d])
	elif perm(l[:d], d) and perm(l[d:], n - d):
		ans.append([d, n - d])
	print(len(ans))
	for i in ans:
		print(*i, sep=' ')


import sys
from collections import defaultdict
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	x = max(lis) + 1
	l = [0] * x
	for i in lis:
		l[i] += 1
	f = 0
	j = x - 1
	for i in range(1, x):
		if f == 0:
			if l[i] == 0 or l[i] > 2:
				break
			if l[i] == 1:
				j = i - 1
				f = 1
		elif l[i] != 1:
			break
	else:
		res = set()
		d = defaultdict(list)
		for i in range(n):
			d[lis[i]].append(i)
		s = set()
		for i in d:
			s.add(d[i][0])
		if list(sorted(s)) == list(range(min(s), min(s) + x - 1)):
			res.add((x - 1, n - x + 1))
		s = set()
		for i in d:
			if len(d[i]) == 2:
				s.add(d[i][1])
			else:
				s.add(d[i][0])
		if list(sorted(s)) == list(range(min(s), min(s) + x - 1)):
			res.add((n - x + 1, x - 1))
		print(len(res))
		for i in res:
			print(*i)
		continue
	print(0)


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	d = defaultdict(lambda : 0, d)
	ans = []
	i = 0
	s = 0
	flag = 0
	comp = 0
	while i < n - 1:
		if d[a[i]] == 0:
			d[a[i]] = 1
			s += a[i]
		else:
			s1 = i * (i + 1) // 2
			if s == s1:
				comp = 1
				break
			else:
				flag = 1
		i += 1
	if flag == 1:
		flag = 2
	else:
		s = f = 0
		d = {}
		d = defaultdict(lambda : 0, d)
		length = n - i
		s1 = length * (length + 1) // 2
		while i < n:
			if d[a[i]] == 0:
				d[a[i]] = 1
				s += a[i]
			else:
				f = 1
				break
			i += 1
		if f == 0:
			if s == s1:
				ans.append((n - length, length))
			else:
				flag = 2
		else:
			flag = 2
	d = {}
	d = defaultdict(lambda : 0, d)
	i = n - 1
	s = 0
	flag1 = 0
	comp = 0
	while i > 0:
		if d[a[i]] == 0:
			d[a[i]] = 1
			s += a[i]
		else:
			i += 1
			s1 = (n - i) * (n - i + 1) // 2
			if s == s1:
				comp = 1
				break
			else:
				flag1 = 1
				break
		i -= 1
	if flag1 != 1:
		if comp != 0:
			i -= 1
		s = f = 0
		d = {}
		d = defaultdict(lambda : 0, d)
		length = i + 1
		s1 = length * (length + 1) // 2
		while i >= 0:
			if d[a[i]] == 0:
				d[a[i]] = 1
				s += a[i]
			else:
				f = 1
				break
			i -= 1
		if f == 0:
			if s == s1:
				ans.append((length, n - length))
				ans = set(ans)
				print(len(ans))
				for i in ans:
					print(i[0], i[1])
			elif flag != 2:
				ans = set(ans)
				print(len(ans))
				for i in ans:
					print(i[0], i[1])
			else:
				print(0)
		else:
			print(0)
	elif flag1 == 1 and flag == 2:
		print(0)
	else:
		ans = set(ans)
		print(len(ans))
		for i in ans:
			print(i[0], i[1])


from sys import stdin
input = stdin.buffer.readline

def f(i, pref):
	if pref[i] == (i + 1) * (i + 2) // 2 and pref[-1] - pref[i] == (n - i - 1) * (n - i) // 2:
		return True
	return False
for _ in range(int(input())):
	n = int(input())
	(*a,) = map(int, input().split())
	d = {}
	flag = 0
	(l, r) = (0, n - 1)
	for i in range(n):
		if a[i] not in d:
			d[a[i]] = [i]
		else:
			if len(d[a[i]]) == 2:
				flag = 1
				break
			d[a[i]].append(i)
			l = max(l, d[a[i]][0])
			r = min(r, d[a[i]][1])
	if flag or r < l:
		print(0)
		continue
	pref = [a[0]]
	for i in range(1, n):
		pref.append(pref[-1] + a[i])
	ans = []
	for i in range(l, r):
		if f(i, pref):
			ans.append([i + 1, n - i - 1])
	print(len(ans))
	for i in ans:
		print(*i)


t = int(input())
for i in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	len_p1 = len(set(a))
	len_p2 = n - len_p1
	if len_p1 + len_p2 != n or len_p1 == n or len_p2 == n:
		print(0)
	else:
		length = []
		ans = 0
		f1 = 0
		if len_p2 == len_p1:
			j = 1
		else:
			j = 2
		for p in range(0, j):
			if p == 0:
				k = len_p2 - 1
			else:
				k = len_p1 - 1
			p1 = set(a[:k + 1])
			p2 = set(a[k + 1:])
			if len(p1) == k + 1 and len(p2) == n - (k + 1):
				if max(p1) == k + 1 and max(p2) == n - (k + 1):
					f1 = 1
				else:
					continue
			else:
				continue
			if f1 == 1:
				ans += 1
				length.append(k + 1)
				length.append(n - (k + 1))
		print(ans)
		if ans > 0:
			for k in range(0, ans):
				p = 2 * k
				print(length[p], length[p + 1])


T = int(input())
for _ in range(0, T):
	n = int(input())
	s = [int(x1) for x1 in input().split()]
	c = 0
	kk11 = 0
	kk12 = 0
	kk21 = 0
	kk22 = 0
	ln1 = max(s)
	ln2 = len(s) - ln1
	pos11 = [0] * (n + 1)
	pos12 = [0] * (n + 1)
	for i in range(ln1):
		pos11[s[i]] = 1
	for i in range(ln1, len(s)):
		pos12[s[i]] = 1
	pos11 = pos11[1:ln1 + 1]
	pos12 = pos12[1:ln2 + 1]
	if len(set(pos11)) == 1 and len(set(pos12)) == 1 and (pos11[0] == 1) and (pos12[0] == 1):
		kk11 = ln1
		kk12 = ln2
		c += 1
	pos21 = [0] * (n + 1)
	pos22 = [0] * (n + 1)
	for i in range(ln2):
		pos21[s[i]] = 1
	for i in range(ln2, len(s)):
		pos22[s[i]] = 1
	pos21 = pos21[1:ln2 + 1]
	pos22 = pos22[1:ln1 + 1]
	if len(set(pos21)) == 1 and len(set(pos22)) == 1 and (pos21[0] == 1) and (pos22[0] == 1) and (ln2 != kk11 or ln1 != kk12):
		kk21 = ln2
		kk22 = ln1
		c += 1
	print(c)
	if c > 0:
		if kk11 > 0 and kk12 > 0:
			print(kk11, kk12)
		else:
			print(kk21, kk22)
	if c > 1:
		print(kk21, kk22)


import sys
input = sys.stdin.buffer.readline
from collections import Counter as C
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	cnts = C(a)
	for i in range(1, n + 3):
		if cnts[i] < 2:
			p1Len = i - 1
			break
	p2Len = n - p1Len
	ans = []
	if p1Len > 0 and p2Len > 0:
		if set(a[:p1Len]) == set(range(1, p1Len + 1)) and set(a[p1Len:]) == set(range(1, p2Len + 1)):
			ans.append([p1Len, p2Len])
		if p1Len != p2Len:
			if set(a[:p2Len]) == set(range(1, p2Len + 1)) and set(a[p2Len:]) == set(range(1, p1Len + 1)):
				ans.append([p2Len, p1Len])
	print(len(ans))
	for (l1, l2) in ans:
		print('{} {}'.format(l1, l2))


def solve():
	n = int(input())
	arr = [int(v) for v in input().split()]
	st = set()
	ans = set()
	for i in range(n):
		if arr[i] in st:
			lfst = set(arr[:i])
			rfst = set(arr[i:])
			if set(range(1, i + 1)) == lfst and set(range(1, n - i + 1)) == rfst:
				ans.add((i, n - i))
			break
		st.add(arr[i])
	st = set()
	for i in reversed(range(n)):
		if arr[i] in st:
			lfst = set(arr[:i + 1])
			rfst = set(arr[i:])
			if lfst == set(range(1, i + 2)) and rfst == set(range(1, n - i)):
				ans.add((i + 1, n - i - 1))
			break
		st.add(arr[i])
	print(len(ans))
	if len(ans):
		print('\n'.join(['%s %s' % (u, v) for (u, v) in ans]))
t = int(input())
for _ in range(t):
	solve()


from math import factorial
from collections import Counter, defaultdict
from heapq import heapify, heappop, heappush
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')

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

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

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 1000000007
INF = float('inf')

def main():
	for _ in range(N()):
		n = N()
		arr = list(RL())
		dic = defaultdict(int)
		dic1 = defaultdict(int)
		res = []
		for i in range(n):
			dic[arr[i]] += 1
			if dic[arr[i]] > 1:
				res.append(i)
				break
		dic = defaultdict(int)
		for i in range(n - 1, -1, -1):
			dic[arr[i]] += 1
			if dic[arr[i]] > 1:
				res.append(i + 1)
				break
		ret = set()
		for i in res:
			if set(arr[:i]) == set([i for i in range(1, len(arr[:i]) + 1)]):
				if set(arr[i:]) == set([i for i in range(1, len(arr[i:]) + 1)]):
					ret.add((i, len(arr) - i))
		print(len(ret))
		for i in ret:
			print(*i)
main()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	(max1, min1, max2, min2) = ([], [], [], [])
	(dict_1, dict_2) = ([], [])
	for i in range(n):
		max1.append(0)
		max2.append(0)
		min1.append(0)
		min2.append(0)
		dict_1.append(0)
		dict_2.append(0)
	max1[0] = a[0]
	min1[0] = a[0]
	max2[n - 1] = a[n - 1]
	min2[n - 1] = a[n - 1]
	dict = {}
	dict[a[0]] = 1
	dict_1[0] = 1
	for i in range(1, n):
		if dict.get(a[i]) is None:
			dict[a[i]] = 1
		max1[i] = max(max1[i - 1], a[i])
		min1[i] = min(min1[i - 1], a[i])
		dict_1[i] = len(dict)
	dict = {}
	dict[a[n - 1]] = 1
	dict_2[n - 1] = 1
	for i in range(n - 2, -1, -1):
		if dict.get(a[i]) is None:
			dict[a[i]] = 1
		max2[i] = max(max2[i + 1], a[i])
		min2[i] = min(min2[i + 1], a[i])
		dict_2[i] = len(dict)
	count = 0
	ans = []
	for i in range(n - 1):
		a = i + 1
		b = n - a
		if dict_1[i] == a and dict_2[i + 1] == b and (min1[i] == 1) and (max1[i] == a) and (max2[i + 1] == b) and (min2[i + 1] == 1):
			count += 1
			ans.append((a, b))
	print(count)
	for i in range(len(ans)):
		print(ans[i][0], ans[i][1])


def judge_list(num_list, max_num):
	l = len(num_list)
	temp = [0] * (max_num + 1)
	temp_max = max(num_list)
	if temp_max != l:
		return False
	for i in range(0, l):
		if temp[num_list[i]] == 0:
			temp[num_list[i]] = 1
		else:
			return False
	return True
n = int(input())
for i in range(n):
	ori_len = int(input())
	ori_list = [int(q) for q in input().split()]
	max_num = max(ori_list)
	max_tags = [m for (m, n) in enumerate(ori_list) if n == max_num]
	res_num = 0
	res_mark_list = []
	if len(max_tags) == 1 and max_num < ori_len:
		if max_tags[0] + 1 <= max_num:
			if judge_list(ori_list[0:max_num], max_num) and judge_list(ori_list[max_num:ori_len], max_num):
				res_num += 1
				res_mark_list.append(max_num)
		if ori_len - max_tags[0] - 1 <= max_num:
			if judge_list(ori_list[0:ori_len - max_num], max_num) and judge_list(ori_list[ori_len - max_num:ori_len], max_num):
				res_num += 1
				res_mark_list.append(ori_len - max_num)
	elif len(max_tags) == 2 and max_num * 2 == ori_len:
		if judge_list(ori_list[0:max_num], max_num) and judge_list(ori_list[max_num:ori_len], max_num):
			res_num += 1
			res_mark_list.append(max_num)
	print(res_num)
	for m in res_mark_list[::-1]:
		print(str(m) + ' ' + str(ori_len - m))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	ha = [0] * (n + 1)
	ha2 = [0] * (n + 1)
	i = 0
	s = 0
	ma1 = 0
	ma2 = 0
	b = 0
	while i < n:
		if s == 0 and ha[arr[i]] == 0:
			ha[arr[i]] = 1
			ma1 = max(ma1, arr[i])
		elif s == 0 and ha[arr[i]] == 1:
			s = 1
			for j in range(1, ma1 + 1):
				if ha[j] != 1:
					b = 1
					break
			i -= 1
			if b == 1:
				break
		elif s == 1 and ha2[arr[i]] == 0:
			ha2[arr[i]] = 1
			ma2 = max(ma2, arr[i])
		elif s == 1 and ha2[arr[i]] == 1:
			b = 1
			break
		i += 1
	for i in range(1, ma2 + 1):
		if ha2[i] != 1:
			b = 1
			break
	ha = [0] * (n + 1)
	ha2 = [0] * (n + 1)
	ma3 = 0
	ma4 = 0
	i = 0
	s = 0
	b2 = 0
	arr.reverse()
	while i < n:
		if s == 0 and ha[arr[i]] == 0:
			ha[arr[i]] = 1
			ma3 = max(ma3, arr[i])
		elif s == 0 and ha[arr[i]] == 1:
			s = 1
			for j in range(1, ma3 + 1):
				if ha[j] != 1:
					b2 = 1
					break
			i -= 1
			if b2 == 1:
				break
		elif s == 1 and ha2[arr[i]] == 0:
			ha2[arr[i]] = 1
			ma4 = max(ma4, arr[i])
		elif s == 1 and ha2[arr[i]] == 1:
			b2 = 1
			break
		i += 1
	for i in range(1, ma4 + 1):
		if ha2[i] != 1:
			b2 = 1
			break
	if b == 1 and b2 == 1:
		print(0)
	elif b == 0 and b2 == 0:
		if ma1 == ma4 and ma2 == ma3:
			print(1)
			print(ma1, ma2)
		else:
			print(2)
			print(ma1, ma2)
			print(ma4, ma3)
	elif b == 1:
		print(1)
		print(ma4, ma3)
	elif b2 == 1:
		print(1)
		print(ma1, ma2)


def solution():
	for _ in range(int(input())):
		n = int(input())
		arr = [int(i) for i in input().split()]
		temp = sorted(arr)
		current = 0
		while current < n - 1:
			if temp[current] == temp[current + 1]:
				current += 2
			else:
				length = current // 2
				break
		else:
			length = n // 2
		origin = {i for i in range(1, length + 1)}
		mid = set(temp[current:])
		if len(mid) != n - length * 2 or mid != {i for i in range(length + 1, n - length + 1)}:
			print(0)
			continue
		left = set(arr[:length])
		right = set(arr[n - length:])
		counter = 0
		if left == origin and length != n - length:
			counter += 1
		if right == origin:
			counter += 1
		print(counter)
		if counter == 0:
			continue
		if left == origin and length != n - length:
			print(length, n - length)
		if origin == right:
			print(n - length, length)
solution()


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

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

def out(var):
	sys.stdout.write(str(var))

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

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().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)]
for _ in range(int(data())):
	n = int(data())
	arr = l()
	ind = set()
	s = set()
	m = arr[0]
	for i in range(n):
		if arr[i] in s:
			break
		s.add(arr[i])
		m = max(arr[i], m)
		if len(s) == m:
			ind.add(i)
	revind = set()
	s = set()
	m = arr[n - 1]
	for i in range(n - 1, -1, -1):
		if arr[i] in s:
			break
		s.add(arr[i])
		m = max(arr[i], m)
		if len(s) == m:
			revind.add(i)
	answer = 0
	result = []
	for i in ind:
		if i + 1 in revind:
			answer += 1
			result.append((i + 1, n - i - 1))
	outln(answer)
	for i in result:
		for j in i:
			out(str(j) + ' ')
		outln('')


from sys import stdin, gettrace
if not gettrace():

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

def main():

	def solve():
		n = int(input())
		aa = [int(a) for a in input().split()]
		counts = [0] * (n + 1)
		mx = 0
		for a in aa:
			counts[a] += 1
			mx = max(a, mx)
		if mx == n:
			print(0)
			return
		twocounts = 0
		mxtwo = 0
		for (i, c) in enumerate(counts[1:mx + 1], 1):
			if c > 2 or c == 0:
				print(0)
				return
			if c == 2:
				twocounts += 1
				mxtwo = max(mxtwo, i)
		if mxtwo != twocounts:
			print(0)
			return
		found = [0] * (mxtwo + 1)
		for a in aa[:mxtwo]:
			if a > mxtwo:
				break
			found[a] += 1
		start = all(map(lambda f: f == 1, found[1:]))
		found = [0] * (mxtwo + 1)
		for a in aa[-1:-mxtwo - 1:-1]:
			if a > mxtwo:
				break
			found[a] += 1
		end = all(map(lambda f: f == 1, found[1:]))
		if mxtwo == n - mxtwo:
			end = False
		if start and end:
			print(2)
		elif start or end:
			print(1)
		else:
			print(0)
		if start:
			print(mxtwo, n - mxtwo)
		if end:
			print(n - mxtwo, mxtwo)
	q = int(input())
	for _ in range(q):
		solve()
main()


def fun(lst, ele, n):
	dic1 = {}
	for j in range(1, ele + 1):
		dic1[j] = 0
	e = 0
	for j in range(ele):
		if lst[j] not in dic1:
			e += 1
			break
		else:
			dic1[lst[j]] += 1
	for j in dic1.keys():
		if dic1[j] != 1:
			e += 1
			break
	dic1 = {}
	for j in range(1, n - ele + 1):
		dic1[j] = 0
	for j in range(ele, n):
		if lst[j] not in dic1:
			e += 1
			break
		else:
			dic1[lst[j]] += 1
	for j in dic1.keys():
		if dic1[j] != 1:
			e += 1
			break
	if e == 0:
		return 1
	return 0
t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	ma = max(lst)
	s = set()
	if fun(lst, ma, n) == 1:
		s.add((ma, n - ma))
	if fun(lst, n - ma, n) == 1:
		s.add((n - ma, ma))
	l = len(s)
	print(l)
	for j in s:
		print(j[0], j[1])


from sys import stdin, stdout
input = stdin.readline
print = stdout.write
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	x = max(a)
	ans = []
	for i in range(2):
		if (len(set(a[:x])) == x and x * (x + 1) // 2 == sum(a[:x])) and (len(set(a[x:])) == n - x and (n - x) * (n - x + 1) // 2 == sum(a[x:])):
			ans.append([x, n - x])
		if x == n - x:
			break
		x = n - x
	print(str(len(ans)) + '\n')
	for i in range(len(ans)):
		for j in range(len(ans[i])):
			print(str(ans[i][j]) + ' ')
		print('\n')


y = int(input())
for i in range(y):
	ans = []
	a = int(input())
	al = input().split()
	m = list(map(int, al))
	l = [0] * a
	mas = 0
	for j in range(a):
		if mas < m[j]:
			mas = m[j]
		if l[m[j]] == 1:
			break
		elif l[m[j]] == 0:
			l[m[j]] = 1
	s = sum(l)
	l = [0] * a
	if s == mas:
		mas1 = 0
		for k in range(j, a):
			if mas1 < m[k]:
				mas1 = m[k]
			if l[m[k]] == 1:
				break
			elif l[m[k]] == 0:
				l[m[k]] = 1
		s = sum(l)
		if s == mas1 and mas + mas1 == a:
			ans.append([mas, mas1])
	m = m[::-1]
	l = [0] * a
	mas = 0
	for j in range(a):
		if mas < m[j]:
			mas = m[j]
		if l[m[j]] == 1:
			break
		elif l[m[j]] == 0:
			l[m[j]] = 1
	s = sum(l)
	l = [0] * a
	if s == mas:
		mas1 = 0
		for k in range(j, a):
			if mas1 < m[k]:
				mas1 = m[k]
			if l[m[k]] == 1:
				break
			elif l[m[k]] == 0:
				l[m[k]] = 1
		s = sum(l)
		if s == mas1 and mas + mas1 == a:
			if len(ans) == 0:
				ans.append([mas1, mas])
			elif len(ans) == 1:
				if ans[0] != [mas1, mas]:
					ans.append([mas1, mas])
	print(len(ans))
	for bv in ans:
		print(bv[0], bv[1])


import sys
input = sys.stdin.readline
Q = int(input())
Query = []
for _ in range(Q):
	N = int(input())
	A = list(map(int, input().split()))
	Query.append((N, A))
for (N, A) in Query:
	leftOK = [True] * (N + 1)
	already = set()
	MAX = 0
	for (i, a) in enumerate(A):
		if a in already:
			ok = False
		else:
			already.add(a)
			MAX = max(MAX, a)
			if len(already) == i + 1 and MAX == i + 1:
				ok = True
			else:
				ok = False
		leftOK[i + 1] = ok
	rightOK = [True] * (N + 1)
	already = set()
	MAX = 0
	for i in reversed(range(N)):
		a = A[i]
		if a in already:
			ok = False
		else:
			already.add(a)
			MAX = max(MAX, a)
			if len(already) == MAX and MAX == N - i:
				ok = True
			else:
				ok = False
		rightOK[i] = ok
	ans = []
	for n in range(1, N):
		if leftOK[n] and rightOK[n]:
			ans.append(str(n) + ' ' + str(N - n))
	print(len(ans))
	print('\n'.join(ans))


from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
from collections import defaultdict as dd, deque

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

def mdata():
	return map(int, data().split())
mod = int(1000000000.0 + 7)
for t in range(int(data())):
	(n,) = mdata()
	A = list(mdata())
	dp1 = [0] * n
	dp2 = [0] * n
	m1 = 0
	m2 = 0
	s1 = set()
	s2 = set()
	for i in range(n):
		s1.add(A[i])
		m1 = max(m1, A[i])
		dp1[i] = [m1, len(s1)]
		s2.add(A[n - i - 1])
		m2 = max(m2, A[n - 1 - i])
		dp2[n - 1 - i] = [m2, len(s2)]
	cnt = 0
	l = []
	for i in range(n - 1):
		if dp1[i][1] == dp1[i][0] == i + 1 and dp2[i + 1][1] == dp2[i + 1][0] == n - i - 1:
			cnt += 1
			l.append([i + 1, n - i - 1])
	print(cnt)
	for i in range(cnt):
		print(l[i][0], l[i][1])


import heapq, sys

def ps(l):
	n = len(l)
	nxt = 1
	heap = []
	ans = []
	for i in range(n):
		heapq.heappush(heap, l[i])
		while heap and heap[0] == nxt:
			nxt += 1
			heapq.heappop(heap)
		if not heap:
			ans.append(i)
	return ans
for q in range(int(sys.stdin.readline())):
	n = int(sys.stdin.readline())
	d = [int(i) for i in sys.stdin.readline().split()]
	st = set(ps(d))
	d.reverse()
	anss = []
	ap = ps(d)
	for a in ap:
		b = n - 2 - a
		if b in st:
			anss.append(str(b + 1) + ' ' + str(n - b - 1) + '\n')
	sys.stdout.write(str(len(anss)) + '\n')
	sys.stdout.write(''.join(anss))


from sys import stdin
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	n = int(inp())
	a = [int(x) for x in inp().split()]
	maxi = max(a)
	answers = 0
	ans = []
	p1 = n - maxi
	p2 = maxi
	needed1 = list(range(1, p1 + 1))
	needed2 = list(range(1, p2 + 1))
	found1 = []
	found2 = []
	flag = True
	for i in range(n):
		if i <= p1 - 1:
			found1.append(a[i])
		else:
			found2.append(a[i])
		if i == p1 - 1:
			if list(sorted(found1)) == list(sorted(needed1)):
				continue
			else:
				flag = False
				break
		elif i == n - 1:
			if list(sorted(found2)) == list(sorted(needed2)):
				continue
			else:
				flag = False
				break
	if flag:
		answers += 1
		ans.append([p1, p2])
	p1 = maxi
	p2 = n - maxi
	needed1 = list(range(1, p1 + 1))
	needed2 = list(range(1, p2 + 1))
	found1 = []
	found2 = []
	flag = True
	for i in range(n):
		if i <= p1 - 1:
			found1.append(a[i])
		else:
			found2.append(a[i])
		if i == p1 - 1:
			if list(sorted(found1)) == list(sorted(needed1)):
				continue
			else:
				flag = False
				break
		elif i == n - 1:
			if list(sorted(found2)) == list(sorted(needed2)):
				continue
			else:
				flag = False
				break
	if flag:
		answers += 1
		ans.append([p1, p2])
	if len(ans) > 1 and ans[0] == ans[1]:
		ans.pop()
		answers -= 1
	print(answers)
	for i in ans:
		print(*i)


import sys
input = sys.stdin.readline
from collections import defaultdict as dd
t = int(input())
while t:
	n = int(input())
	l = list(map(int, input().split()))
	lm = 0
	rm = n - 1
	d = dd(list)
	mx = -1
	for i in range(n):
		d[l[i]].append(i)
		mx = max(mx, l[i])
	lol = 0
	for i in range(1, mx + 1):
		le = len(d[i])
		if le == 0 or le > 2:
			lol = 1
			break
		if le == 2:
			lm = max(lm, d[i][0])
			rm = min(rm, d[i][1])
	if lm >= rm:
		lol = 1
	mi = 1
	mj = 1
	ci = lm + 1
	cj = n - rm
	lo = 0
	if lol == 0:
		for i in range(lm + 1):
			mi = max(mi, l[i])
		for j in range(n - 1, rm - 1, -1):
			mj = max(mj, l[j])
		if ci != mi and cj != mj:
			lol = 1
		elif ci != mi:
			for i in range(lm + 1, rm):
				ci += 1
				mi = max(mi, l[i])
			if ci != mi:
				lol = 1
		elif cj != mj:
			for i in range(rm - 1, lm, -1):
				cj += 1
				mj = max(mj, l[i])
			if cj != mj:
				lol = 1
		elif mi > mj:
			for i in range(lm + 1, rm):
				ci += 1
				mi = max(mi, l[i])
			if ci != mi:
				lol = 1
		elif mj > mi:
			for i in range(rm - 1, lm, -1):
				cj += 1
				mj = max(mj, l[i])
			if cj != mj:
				lol = 1
		else:
			lo = 1
			cci = ci
			ccj = cj
			for i in range(lm + 1, rm):
				ci += 1
				mi = max(mi, l[i])
			if ci != mi:
				lol = 1
	if lol == 1:
		print(0)
	elif lo == 0:
		print(1)
		print(ci, cj)
	elif ci == cj:
		print(1)
		print(ci, cj)
	else:
		print(2)
		print(ci, cj)
		print(cj, ci)
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	s1 = set()
	s2 = set()
	flag = 0
	flag1 = 0
	m = 0
	k = 0
	j = n
	a = 0
	b = 0
	c = 0
	d = 0
	for i in range(n):
		if l[i] not in s1:
			s1.add(l[i])
		else:
			j = i
			break
	for i in range(j, n):
		if l[i] not in s2:
			s2.add(l[i])
		else:
			j = i
			flag = 1
			break
	if flag == 1:
		pass
	else:
		for i in range(1, len(s1) + 1):
			if i in s1:
				a = i
				continue
			else:
				flag = 2
				break
		if flag == 2:
			pass
		else:
			for i in range(1, len(s2) + 1):
				if i in s2:
					b = i
					continue
				else:
					flag = 3
					break
			if flag == 3:
				pass
			else:
				k += 1
	s3 = set()
	s4 = set()
	for i in range(n - 1, -1, -1):
		if l[i] not in s3:
			s3.add(l[i])
		else:
			j = i
			break
	if j != n:
		for i in range(j, -1, -1):
			if l[i] not in s4:
				s4.add(l[i])
			else:
				flag1 = 1
				break
		if flag1 == 1:
			if k == 1 and a != 0 and (b != 0):
				m = 10
				print(k)
				print(a, b)
			else:
				m = 10
				print(0)
		else:
			for i in range(1, len(s3) + 1):
				if i in s3:
					c = i
					continue
				else:
					flag1 = 2
					break
			if flag1 == 2:
				if k == 1 and a != 0 and (b != 0):
					m = 10
					print(k)
					print(a, b)
				else:
					m = 10
					print(0)
			else:
				for i in range(1, len(s4) + 1):
					if i in s4:
						d = i
						continue
					else:
						flag1 = 3
						break
				if flag1 == 3:
					if k == 1 and a != 0 and (b != 0):
						m = 10
						print(k)
						print(a, b)
					else:
						m = 10
						print(0)
				else:
					k += 1
					if k == 2 and a != 0 and (b != 0) and (c != 0) and (d != 0):
						m = 10
						if a == d and b == c:
							print(1)
							print(a, b)
						else:
							print(k)
							print(a, b)
							print(d, c)
					elif k == 1 and c != 0 and (d != 0):
						m = 10
						print(k)
						print(d, c)
					else:
						m = 10
						print(0)
	if m != 10:
		print(0)


import sys
input = sys.stdin.readline
from math import *
from collections import *
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	f = set()
	f1 = set()
	flag = 0
	bb = 0
	s = 0
	r = []
	for i in a:
		if i not in f and flag == 0:
			f.add(i)
		elif i not in f1:
			flag = 1
			f1.add(i)
		else:
			bb = 1
			break
	if len(f) == 0 or len(f1) == 0:
		bb = 1
	if bb != 1:
		b = list(f)
		c = list(f1)
		b.sort()
		c.sort()
		tt = 0
		for i in range(len(b)):
			if i + 1 == b[i]:
				continue
			tt += 1
			break
		for i in range(len(c)):
			if i + 1 == c[i]:
				continue
			tt += 1
			break
		if tt == 0:
			s += 1
			r.append([len(f), len(f1)])
		bb = 0
		flag = 0
		f = set()
		f1 = set()
	for i in a[::-1]:
		if i not in f and flag == 0:
			f.add(i)
		elif i not in f1:
			flag = 1
			f1.add(i)
		else:
			bb = 1
			break
	if len(f) == 0 or len(f1) == 0:
		bb = 1
	if bb != 1:
		b = list(f)
		c = list(f1)
		b.sort()
		c.sort()
		tt = 0
		for i in range(len(b)):
			if i + 1 == b[i]:
				continue
			tt += 1
			break
		for i in range(len(c)):
			if i + 1 == c[i]:
				continue
			tt += 1
			break
		if tt == 0:
			s += 1
			r.append([len(f1), len(f)])
	if s == 2:
		if r[0] == r[1]:
			s -= 1
	print(s)
	for i in range(s):
		print(*r[i])


from sys import stdin

def func(n):
	a = n * (n + 1)
	b = n + n + 1
	return a * b // 6
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	arr = list(map(int, stdin.readline().split()))
	ans = []
	pre = []
	suff = []
	P = []
	S = []
	m = 0
	M = 0
	for i in range(n):
		m += arr[i]
		M += pow(arr[i], 2)
		pre.append(m)
		P.append(M)
	m = 0
	M = 0
	for i in range(n - 1, -1, -1):
		m += arr[i]
		M += pow(arr[i], 2)
		suff.append(m)
		S.append(M)
	for i in range(1, n):
		if pre[i - 1] == i * (i + 1) // 2 and P[i - 1] == func(i):
			if suff[n - i - 1] == (n - i) * (n - i + 1) // 2 and S[n - i - 1] == func(n - i):
				ans.append([i, n - i])
	print(len(ans))
	for ele in ans:
		print(ele[0], ele[1])


for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	m1 = [0] * n
	m2 = [0] * n
	x = set()
	ans = []
	mx = 0
	one = False
	for i in range(n):
		if l[i] in x:
			break
		else:
			if l[i] == 1:
				one = True
			mx = max(mx, l[i])
			x.add(l[i])
			if one and mx == len(x):
				m1[i] = len(x)
	x = set()
	mx = 0
	one = False
	for i in range(n - 1, -1, -1):
		if l[i] in x:
			break
		else:
			if l[i] == 1:
				one = True
			mx = max(mx, l[i])
			x.add(l[i])
			if one and mx == len(x):
				m2[i] = len(x)
	for i in range(n):
		if m1[i] != 0 and i + 1 < n:
			if m2[i + 1] != 0:
				ans.append((m1[i], m2[i + 1]))
	print(len(ans))
	for i in range(len(ans)):
		print(ans[i][0], ans[i][1])


from sys import exit
from collections import Counter

def i():
	return input()

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

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

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

def print_array(a):
	print(' '.join(map(str, a)))
t = ii()
for _ in range(t):
	n = ii()
	a = liis()
	jose = Counter(a)
	cur = 0
	for i in range(1, n):
		if i not in jose:
			break
		if jose[i] == 2:
			cur += 1
		else:
			break
	maxi = cur
	for i in range(cur + 1, n):
		if i in jose:
			maxi += 1
		else:
			break
	first = [i for i in range(1, cur + 1)]
	final = [i for i in range(1, maxi + 1)]
	first_set = set(first)
	final_first_set = set(final)
	second_set = set(first)
	final_second_set = set(final)
	possible = 0
	ans = []
	can = True
	for i in range(len(first)):
		if a[i] in first_set:
			first_set.remove(a[i])
		else:
			can = False
			break
	for i in range(len(final)):
		if a[len(a) - i - 1] in final_first_set:
			final_first_set.remove(a[len(a) - i - 1])
		else:
			can = False
			break
	if can and (not len(first_set)) and (not len(final_first_set)):
		possible += 1
		ans.append([len(first), n - len(first)])
	can = True
	for i in range(len(first)):
		if a[len(a) - i - 1] in second_set:
			second_set.remove(a[len(a) - i - 1])
		else:
			can = False
			break
	for i in range(len(final)):
		if a[i] in final_second_set:
			final_second_set.remove(a[i])
		else:
			can = False
			break
	if can and (not len(final_second_set)) and (not len(second_set)):
		possible += 1
		ans.append([n - len(first), len(first)])
	if len(ans) == 2 and ans[0] == ans[1]:
		ans.pop()
	if possible and len(final) + len(first) == n:
		print(len(ans))
		for i in ans:
			print(i[0], i[1])
	else:
		print(0)


def run(n, list_elements):
	n_long = max(list_elements)
	n_short = n - n_long
	way1 = False
	way2 = False
	w1_long_list = list_elements[:n_long]
	w1_short_list = list_elements[n_long:]
	w1_long_list_mask = [False] * n_long
	w1_short_list_mask = [False] * n_short
	for i in range(len(w1_long_list)):
		index = w1_long_list[i] - 1
		if index >= len(w1_long_list_mask):
			break
		w1_long_list_mask[index] = True
	for i in range(len(w1_short_list)):
		index = w1_short_list[i] - 1
		if index >= len(w1_short_list_mask):
			break
		w1_short_list_mask[index] = True
	if all(w1_short_list_mask) and all(w1_long_list_mask):
		way1 = True
	w2_long_list = list_elements[n_short:]
	w2_short_list = list_elements[:n_short]
	w2_long_list_mask = [False] * n_long
	w2_short_list_mask = [False] * n_short
	for i in range(len(w2_long_list)):
		index = w2_long_list[i] - 1
		if index >= len(w2_long_list_mask):
			break
		w2_long_list_mask[index] = True
	for i in range(len(w2_short_list)):
		index = w2_short_list[i] - 1
		if index >= len(w2_short_list_mask):
			break
		w2_short_list_mask[index] = True
	if all(w2_short_list_mask) and all(w2_long_list_mask):
		way2 = True
	if way1 == True and way2 == True:
		if n_short == n_long:
			print('1')
		else:
			print('2')
	elif way1 == True or way2 == True:
		print('1')
	else:
		print('0')
	if way1 == True:
		print(str(n_long) + ' ' + str(n_short))
	if way2 == True:
		if n_short == n_long and way1 == True:
			pass
		else:
			print(str(n_short) + ' ' + str(n_long))
	return
i = int(input())
for _ in range(i):
	n = int(input())
	lst = list(map(int, input().split()))
	run(n, lst)


import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
from functools import lru_cache
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

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

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
for _ in range(int(input())):
	n = int(input())
	a = [0] + list(mapi())
	mx = 0
	mp = {}
	dp = [[0] * 2 for i in range(n + 5)]
	for i in range(1, n + 1):
		if a[i] not in mp:
			mp[a[i]] = 1
			mx = max(mx, a[i])
			if mx == i:
				dp[i][0] = 1
		else:
			break
	mp = {}
	mx = 0
	for i in range(n, 0, -1):
		if a[i] not in mp:
			mp[a[i]] = 1
			mx = max(a[i], mx)
			if mx == n - i + 1:
				dp[i][1] = 1
		else:
			break
	mp = {}
	res = 0
	for i in range(2, n + 1):
		if dp[i - 1][0] and dp[i][1]:
			res += 1
	print(res)
	for i in range(2, n + 1):
		if dp[i - 1][0] and dp[i][1]:
			print(i - 1, n - i + 1)
		dp[i][1] = 0


def check(arr):
	larr = len(arr)
	r = [0] * (larr + 1)
	for i in arr:
		if i > larr:
			return False
		r[i] += 1
	return all([i == 1 for i in r[1:]])
N = int(input())
for _ in range(N):
	K = int(input())
	A = list(map(int, input().split()))
	doubled = [0] * K
	for i in A:
		doubled[i] += 1
	md = max([num for (num, i) in enumerate(doubled) if i == 2] + [0])
	if md == 0:
		print(0)
	elif K == md * 2:
		if check(A[:md]) and check(A[md:]):
			print(1)
			print(md, md)
		else:
			print(0)
	else:
		res = []
		if check(A[:md]) and check(A[md:]):
			res.append((md, K - md))
		if check(A[K - md:]) and check(A[:K - md]):
			res.append((K - md, md))
		print(len(res))
		for (i, j) in res:
			print('%d %d' % (i, j))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	pre = [False] * n
	pos = [False] * n
	count = [0] * (n + 1)
	d = 0
	su = 0
	for i in range(len(a)):
		if count[a[i]] == 0:
			count[a[i]] += 1
			su = su + a[i]
			d += 1
		else:
			break
		if d == i + 1 and d * (d + 1) // 2 == su:
			pre[i] = True
	a.reverse()
	count = [0] * (n + 1)
	d = 0
	su = 0
	for i in range(len(a)):
		if count[a[i]] == 0:
			count[a[i]] += 1
			su = su + a[i]
			d += 1
		else:
			break
		if d == i + 1 and d * (d + 1) // 2 == su:
			pos[i] = True
	pos.reverse()
	ans = []
	count = 0
	for i in range(n - 1):
		if pre[i] and pos[i + 1]:
			count += 1
			ans.append((i + 1, n - (i + 1)))
	print(count)
	for i in ans:
		print(i[0], i[1])


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().strip().split()]
	aset = set([])
	res = []
	s = 0
	ts = sum(a)
	dic = {}
	for e in a:
		if e not in dic:
			dic[e] = 0
		dic[e] += 1
	flag = True
	bad = set([])
	for d in dic:
		if dic[d] > 2:
			flag = False
			break
		elif dic[d] == 2:
			bad.add(d)
	if flag:
		for i in range(n - 1):
			if a[i] not in aset:
				s += a[i]
				aset.add(a[i])
				if a[i] in bad:
					bad.remove(a[i])
				if (i + 1) * (i + 2) // 2 == s:
					ps = ts - s
					rem = n - (i + 1)
					if ps == rem * (rem + 1) // 2 and len(bad) == 0:
						res.append(i + 1)
			else:
				break
		print(len(res))
		for r in res:
			print(r, n - r)
	else:
		print(0)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	d1 = {}
	d2 = {}
	stop = -1
	for (num, i) in enumerate(arr[::-1]):
		if i not in d2:
			d2[i] = 0
		d2[i] += 1
		if stop == -1 and d2[i] > 1:
			stop = num
	if stop != -1:
		stop = n - stop - 1
	(left, right) = ([(10 ** 9, 0)], [(10 ** 9, 0)])
	for i in arr:
		left.append((min(left[-1][0], i), max(left[-1][1], i)))
	left = left[1:]
	for i in arr[::-1]:
		right.append((min(right[-1][0], i), max(right[-1][1], i)))
	right = right[1:]
	right = right[::-1]
	ans = []
	for (num, i) in enumerate(arr[:-1]):
		if i in d1:
			break
		d1[i] = 1
		d2[i] -= 1
		if d2[i] == 0:
			d2.pop(i)
		if left[num] == (1, len(d1)) and right[num + 1] == (1, len(d2)) and (stop == -1 or num >= stop):
			ans.append((len(d1), len(d2)))
	print(len(ans))
	for line in ans:
		print(*line)


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

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

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

def insr():
	s = input().rstrip()
	return s[:len(s) - 1]

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

def cal(n):
	return n * (n + 1) // 2
t = inp()
for _ in range(t):
	n = inp()
	nums = inlt()
	pre = [0 for i in range(n)]
	pre[0] = nums[0]
	for i in range(1, n):
		pre[i] = pre[i - 1] + nums[i]
	fs = 0
	ss = 0
	ans = []
	d = defaultdict(int)
	for i in nums:
		d[i] += 1
	big = max(nums)
	has = True
	for i in range(1, big + 1):
		if i not in d:
			has = False
			break
		if d[i] >= 3:
			has = False
			break
	if has:
		vl = set()
		for i in range(n):
			if nums[i] in vl:
				break
			vl.add(nums[i])
			d[nums[i]] -= 1
			if d[nums[i]] <= 0:
				del d[nums[i]]
			if len(d) != n - i - 1:
				continue
			first_s = pre[i]
			se_s = pre[n - 1] - pre[i]
			if cal(i + 1) == first_s and cal(n - i - 1) == se_s:
				if i + 1 < n:
					ans.append(i + 1)
	print(len(ans))
	for i in ans:
		print(i, n - i)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	m = 0
	c = 0
	s = set()
	ans = [True] * n
	for i in range(n):
		m = max(m, a[i])
		if a[i] not in s:
			s.add(a[i])
			c += 1
		if not (c == i + 1 and m == i + 1):
			ans[i] = False
	m = 0
	c = 0
	s = set()
	for i in range(n - 1, 0, -1):
		m = max(m, a[i])
		if a[i] not in s:
			s.add(a[i])
			c += 1
		if not (c == n - i and m == n - i):
			ans[i - 1] = False
	print(ans.count(True))
	for i in range(n - 1):
		if ans[i]:
			print(i + 1, n - i - 1)


T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	left = []
	right = []
	f = [0] * (n + 1)
	ans = []
	tilltrue = -1
	notfoundcount = 0
	mx = -1
	newelm = 0
	leftF = [0] * (n + 1)
	for i in range(n):
		if f[a[i]] == 0:
			newelm += 1
			if a[i] > mx:
				mx = a[i]
			if newelm == mx and mx == i + 1:
				left.append(i + 1)
				leftF[i + 1] += 1
		f[a[i]] += 1
	rf = [0] * (n + 1)
	newelm = 0
	mx = -1
	j = 0
	for i in range(n):
		j = n - i - 1
		if rf[a[j]] == 0:
			newelm += 1
			if a[j] > mx:
				mx = a[j]
			if newelm == mx == i + 1:
				right.append(j)
				if leftF[j] > 0:
					ans.append([j, n - j])
		rf[a[j]] += 1
	print(len(ans))
	k = 0
	while len(ans) > k:
		print(ans[k][0], ans[k][1])
		k = k + 1


def main():
	import sys
	input = sys.stdin.readline

	def is_ok(p, l):
		used = [0] * l
		ret = True
		for i in range(l):
			if p[i] > l or used[p[i] - 1] == 1:
				ret = False
				break
			else:
				used[p[i] - 1] = 1
		return ret
	t = int(input())
	for _ in range(t):
		n = int(input())
		A = list(map(int, input().split()))
		l1 = max(A)
		l2 = n - l1
		if l2 > l1:
			print(0)
		elif l1 == l2:
			ans = 0
			ans_ = []
			p1 = A[:l1]
			p2 = A[l1:]
			if is_ok(p1, l1) and is_ok(p2, l2):
				ans += 1
				ans_.append([l1, l2])
			print(ans)
			for i in range(ans):
				print(*ans_[i])
		else:
			ans = 0
			ans_ = []
			p1 = A[:l1]
			p2 = A[l1:]
			if is_ok(p1, l1) and is_ok(p2, l2):
				ans += 1
				ans_.append([l1, l2])
			p1 = A[:l2]
			p2 = A[l2:]
			if is_ok(p1, l2) and is_ok(p2, l1):
				ans += 1
				ans_.append([l2, l1])
			print(ans)
			for i in range(ans):
				print(*ans_[i])
main()


t = int(input())
for i in range(t):
	a = int(input())
	array = [int(s) for s in input().split()]
	check = {}
	exists = True
	max_with_2 = -1
	for i in range(len(array)):
		if array[i] not in check:
			check[array[i]] = 1
		else:
			check[array[i]] += 1
	for (key, value) in check.items():
		if value > 2:
			exists = False
		elif value == 2 and key > max_with_2:
			max_with_2 = key
	for i in range(1, max_with_2):
		if i not in check:
			exists = False
		elif check[i] != 2 and i <= max_with_2:
			exists = False
	if not exists:
		print(0)
		continue
	counter = 0
	max_ls = []
	max_l = -1
	max_r = -1
	max_rs = []
	sums_l = [0]
	sums_r = [0]
	for i in range(len(array)):
		if array[i] > max_l:
			max_l = array[i]
		max_ls.append(max_l)
		sums_l.append(sums_l[-1] + array[i])
		if array[len(array) - 1 - i] > max_r:
			max_r = array[len(array) - 1 - i]
		sums_r.append(sums_r[-1] + array[len(array) - 1 - i])
		max_rs.append(max_r)
	sums_l = sums_l[1:]
	sums_r = sums_r[1:]
	ans = []
	for i in range(len(array)):
		if i + 1 == max_ls[i] and len(array) - i - 1 == max_rs[len(array) - i - 2]:
			if sums_l[i] == max_ls[i] * (max_ls[i] + 1) // 2 and sums_r[len(array) - i - 2] == max_rs[len(array) - i - 2] * (max_rs[len(array) - i - 2] + 1) // 2:
				ans.append([i + 1, len(array) - i - 1])
	print(len(ans))
	for i in range(len(ans)):
		print(ans[i][0], ans[i][1])


from sys import stdin
input = stdin.readline

def getSub(a, n):
	visited = [False] * (n + 1)
	currMax = 0
	tru = [False] * n
	for i in range(n - 1):
		if visited[a[i]]:
			break
		visited[a[i]] = True
		if a[i] > currMax:
			currMax = a[i]
		if i + 1 == currMax:
			tru[i + 1] = True
	return tru
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = getSub(a, n)
	c = getSub(a[::-1], n)
	good = set()
	for i in range(n):
		if b[i] and c[n - i]:
			good.add((i, n - i))
	print(len(good))
	for (l1, l2) in good:
		print(l1, l2)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
from collections import deque
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()

def check(arr):
	ch = list(arr)
	ch.sort()
	sam = [i for i in range(1, len(arr) + 1)]
	if sam == ch:
		return True
	else:
		return False
t = ip()
for _ in range(t):
	n = ip()
	arr = list(inp())
	dic = defaultdict(bool)
	for i in range(n):
		if dic[arr[i]]:
			break
		else:
			dic[arr[i]] = True
	arr1 = arr[:i]
	arr2 = arr[i:]
	ans = 0
	ch = []
	store = None
	if check(arr1) and check(arr2):
		ch.append('{} {}'.format(len(arr1), len(arr2)))
	arr = arr[::-1]
	dic = defaultdict(bool)
	for i in range(n):
		if dic[arr[i]]:
			break
		else:
			dic[arr[i]] = True
	arr1 = arr[:i]
	arr2 = arr[i:]
	if check(arr1) and check(arr2):
		ch.append('{} {}'.format(len(arr2), len(arr1)))
	ch = list(set(ch))
	print(len(ch))
	for i in ch:
		print(i)


t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	cml = [0] + A
	for i in range(1, n + 1):
		cml[i] = max(cml[i - 1], cml[i])
	cmr = A + [0]
	cmr.reverse()
	for i in range(1, n + 1):
		cmr[i] = max(cmr[i - 1], cmr[i])
	l = []
	import copy
	r = copy.copy(A)
	r.reverse()
	k = 0
	ans = []
	ng = set()
	l_ = set()
	l_temp = []
	for i in range(n - 1):
		l_temp.append(A[i])
		l_.add(A[i])
		if len(l_temp) != len(l_):
			ng.add(i)
	r_temp = []
	r_ = set()
	for j in range(n - 1):
		r_temp.append(A[n - j - 1])
		r_.add(A[n - j - 1])
		if len(r_temp) != len(r_):
			ng.add(n - j - 2)
	for i in range(n - 1):
		l.append(A[i])
		r.pop()
		if i in ng:
			continue
		if cml[i + 1] == i + 1 and cmr[n - i - 1] == n - i - 1:
			k += 1
			ans.append([i + 1, n - i - 1])
	print(k)
	if k != 0:
		for i in range(len(ans)):
			print(*ans[i])


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

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

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

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

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

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

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

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

def S():
	return input()

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

def pe(s):
	return print(str(s), file=sys.stderr)

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

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

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		n = I()
		a = LI()
		c = collections.Counter(a)
		m = max(a)
		m2 = n - m
		ok = m2 > 0
		for i in range(1, m2 + 1):
			if c[i] != 2:
				ok = 0
				break
		for i in range(m2 + 1, m + 1):
			if c[i] != 1:
				ok = 0
				break
		if ok:
			r = []
			if max(a[:m2]) == m2 and len(set(a[:m2])) == m2:
				r.append([m2, m])
			if m != m2 and max(a[-m2:]) == m2 and (len(set(a[-m2:])) == m2):
				r.append([m, m2])
			rr.append(len(r))
			if r:
				rr.append(JAA(r, '\n', ' '))
		else:
			rr.append(0)
	return JA(rr, '\n')
print(main())


def helper(sa, a, sb, b, seen):
	return a * (a + 1) // 2 == sa and b * (b + 1) // 2 == sb and (a == len(seen))
t = int(input())
while t > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	all_sum = sum(arr)
	cur_sum = 0
	cnt = 0
	ans = []
	(fwd, bck) = (set(), [])
	tmp = set()
	for i in range(len(arr) - 1):
		cur_sum += arr[i]
		tmp.add(arr[i])
		if helper(cur_sum, i + 1, all_sum - cur_sum, n - i - 1, tmp):
			fwd.add((i + 1, n - i - 1))
	arr = arr[::-1]
	(cur_sum, tmp) = (0, set())
	for i in range(len(arr) - 1):
		cur_sum += arr[i]
		tmp.add(arr[i])
		if helper(cur_sum, i + 1, all_sum - cur_sum, n - i - 1, tmp):
			if (n - i - 1, i + 1) in fwd:
				bck.append((n - i - 1, i + 1))
				cnt += 1
	print(cnt)
	for (i, j) in bck:
		print(i, j)
	t -= 1


from sys import stdin as inp
from math import gcd, sqrt, floor, ceil, log2
for _ in range(int(inp.readline())):
	n = int(inp.readline())
	arr = list(map(int, inp.readline().split()))
	maxx = max(arr)
	if maxx >= n:
		print(0)
	else:
		ind_f = -1
		ind_b = n
		dic = {}
		front = True
		t = maxx
		back = True
		for i in range(1, maxx + 1):
			dic[i] = 0
		for i in range(n):
			if t:
				if dic[arr[i]] == 0:
					dic[arr[i]] = 1
					ind_f = i
					t -= 1
				else:
					front = False
			else:
				break
		for i in range(1, maxx + 1):
			dic[i] = 0
		t = maxx
		for i in range(n - 1, -1, -1):
			if t:
				if dic[arr[i]] == 0:
					dic[arr[i]] = 1
					t -= 1
					ind_b = i
				else:
					back = False
			else:
				break
		two = n - maxx
		front2 = True
		back2 = True
		t = two
		ind_t_f = -1
		ind_t_b = n
		for i in range(1, two + 1):
			dic[i] = 0
		for i in range(n):
			if t:
				if dic[arr[i]] == 0:
					dic[arr[i]] = 1
					ind_t_f = i
					t -= 1
				else:
					front2 = False
			else:
				break
		for i in range(1, two + 1):
			dic[i] = 0
		t = two
		for i in range(n - 1, -1, -1):
			if t:
				if dic[arr[i]] == 0:
					dic[arr[i]] = 1
					t -= 1
					ind_t_b = i
				else:
					back2 = False
			else:
				break
		ans = []
		if front and back2 and (ind_f + 1 == ind_t_b):
			ans.append([ind_f + 1, n - (ind_f + 1)])
		if front2 and back and (ind_t_f + 1 == ind_b):
			if [ind_t_f + 1, n - (ind_t_f + 1)] not in ans:
				ans.append([ind_t_f + 1, n - (ind_t_f + 1)])
		if ans:
			print(len(ans))
			for i in ans:
				print(*i)
		else:
			print(0)


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

def su(x):
	product = x * (x + 1) // 2
	return product
for i in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	maxi = max(li)
	pairs = []
	s1 = set()
	s2 = set()
	s3 = set()
	s4 = set()
	s5 = set()
	s6 = set()
	for j in range(1, maxi + 1):
		s1.add(j)
	for j in range(1, n - maxi + 1):
		s2.add(j)
	try:
		for j in range(maxi):
			s3.add(li[j])
		for j in range(maxi, n):
			s4.add(li[j])
		for j in range(n - maxi):
			s5.add(li[j])
		for j in range(n - maxi, n):
			s6.add(li[j])
		if s3 == s1 and s4 == s2:
			pairs.append((maxi, n - maxi))
		if s5 == s2 and s6 == s1:
			pairs.append((n - maxi, maxi))
		if len(pairs) == 2 and pairs[0][0] == pairs[0][1]:
			print(1)
			print(pairs[0][0], pairs[0][1])
		else:
			print(len(pairs))
			if len(pairs) != 0:
				for j in range(len(pairs)):
					print(pairs[j][0], pairs[j][1])
	except:
		print(0)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ma = max(a)
	arr = []
	ma1 = n - ma
	ans = 0
	dp = [0] * (ma + 1)
	c = 0
	for i in range(ma):
		if a[i] <= ma and dp[a[i]] == 0:
			dp[a[i]] = 1
			c += 1
	if c == ma:
		dp = [0] * (ma1 + 1)
		c = 0
		for i in range(ma, n):
			if a[i] <= ma1 and dp[a[i]] == 0:
				dp[a[i]] = 1
				c += 1
		if c == ma1:
			ans = 1
			arr.append([ma, ma1])
	if ma != ma1:
		dp = [0] * (ma1 + 1)
		c = 0
		for i in range(ma1):
			if a[i] <= ma1 and dp[a[i]] == 0:
				dp[a[i]] = 1
				c += 1
		if c == ma1:
			dp = [0] * (ma + 1)
			c = 0
			for i in range(ma1, n):
				if a[i] <= ma and dp[a[i]] == 0:
					dp[a[i]] = 1
					c += 1
			if c == ma:
				ans += 1
				arr.append([ma1, ma])
	print(ans)
	for i in arr:
		print(*i)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d1 = {}
	d2 = {}
	for elem in a:
		d1[elem] = 1 + d1.get(elem, 0)
	b = []
	s = sum(a)
	c = 0
	for i in range(n):
		c += a[i]
		d2[a[i]] = 1 + d2.get(a[i], 0)
		d1[a[i]] -= 1
		if d1[a[i]] == 0:
			d1.pop(a[i], None)
		if (i + 1) * (i + 2) // 2 == c and s - c == (n - 1 - i) * (n - i) // 2 and (len(d2) == i + 1) and (len(d1) == n - i - 1):
			b.append((i + 1, n - i - 1))
	print(len(b))
	for elem in b:
		print(*elem)


import sys
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
ni = lambda : int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda : list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda : float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda : list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda : stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda : stdin.readline().split()
from collections import defaultdict

def check(a):
	a.sort()
	j = 1
	for i in a:
		if i != j:
			return False
		j += 1
	return True

def sol():
	n = ni()
	a = na()
	maxA = max(a)
	ans = []
	if check(a[:n - maxA]) and check(a[n - maxA:]):
		ans.append((n - maxA, maxA))
	if maxA * 2 != n and check(a[:maxA]) and check(a[maxA:]):
		ans.append((maxA, n - maxA))
	print(len(ans))
	for (l, r) in ans:
		print(l, r)
t = ni()
for i in range(t):
	sol()


import os
import sys
from io import BytesIO, IOBase
import threading
from collections import Counter
mod = 998244353

def main():
	for _ in range(int(input())):
		n = int(input())
		s = set()
		arr = list(map(int, input().split()))
		ma = max(arr)
		ans = []
		a = [i for i in range(1, n + 10)]
		s1 = sorted(arr[:ma])
		s2 = sorted(arr[ma:])
		if s1 == a[:ma] and s2 == a[:n - ma]:
			ans.append((len(s1), len(s2)))
		s1 = sorted(arr[:n - ma])
		s2 = sorted(arr[n - ma:])
		if s1 == a[:n - ma] and s2 == a[:ma] and (n - ma != ma):
			ans.append((len(s1), len(s2)))
		print(len(ans))
		for (i, j) in ans:
			print(i, j)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	n = int(input())
	a = [int(o) for o in input().split()]
	maxm = max(a)
	count = [0 for i in range(n + 1)]
	count1 = [0 for i in range(maxm + 1)]
	count2 = [0 for i in range(maxm + 1)]
	for i in a:
		count[i] += 1
	i = 1
	while count[i] > 1:
		i += 1
	lower = i - 1
	flag1 = 0
	flag2 = 0
	for i in range(maxm):
		count1[a[i]] += 1
	for i in range(1, maxm + 1):
		if count1[i] != 1:
			flag1 = 1
	for i in range(n - 1, n - 1 - maxm, -1):
		count2[a[i]] += 1
	for i in range(1, maxm + 1):
		if count2[i] != 1:
			flag2 = 1
	if lower + maxm is not n:
		print(0)
	elif maxm == n:
		print(0)
	elif flag1 is 1 and flag2 is 1:
		print(0)
	elif flag1 is 0 and flag2 is 0:
		if maxm == n - maxm:
			print(1)
			print(maxm, n - maxm)
		else:
			print(2)
			print(n - maxm, maxm)
			print(maxm, n - maxm)
	elif flag1 is 0:
		print(1)
		print(maxm, n - maxm)
	elif flag2 is 0:
		print(1)
		print(n - maxm, maxm)


from collections import defaultdict

def traverse(a):
	d = defaultdict(lambda : 0)
	res_left = [False] * len(a)
	mx_left = 0
	for (i, val) in enumerate(a):
		d[val] += 1
		if d[val] > 1:
			break
		mx_left = max(mx_left, val)
		if mx_left == i + 1:
			res_left[i] = True
	return res_left

def solve(a):
	(validity_left, validity_right) = (traverse(a), traverse(a[::-1]))
	validity_right = validity_right[::-1]
	res = list()
	for i in range(len(validity_left) - 1):
		if validity_left[i] and validity_right[i + 1]:
			res.append((i + 1, n - i - 1))
	return res
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	(right_res, left_res) = ([], [])
	res = solve(a)
	print(len(res))
	for r in res:
		print(r[0], r[1])


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	a = [int(ai) for ai in input().split()]
	s = sum(a)
	summer = 0
	res = []
	setter = set()
	rsetter = Counter(a)
	rsetter_cnt = n
	for (i, ai) in enumerate(a):
		summer += ai
		setter.add(ai)
		rsetter[ai] -= 1
		if rsetter[ai] == 0:
			del rsetter[ai]
		rsetter_cnt -= 1
		if summer == (i + 1) * (i + 2) // 2 and len(setter) == i + 1:
			rem = s - summer
			j = n - i - 1
			if rem == j * (j + 1) // 2 and rsetter_cnt == len(rsetter):
				res.append((i + 1, j))
	print(len(res))
	for (i, j) in res:
		print(i, j)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	mySet = set()
	rank = 1
	dpL1 = [0 for i in range(n)]
	for i in range(n):
		if l[i] in mySet:
			break
		mySet.add(l[i])
		while rank in mySet:
			mySet.remove(rank)
			rank += 1
		if len(mySet) == 0:
			dpL1[i] = 1
		else:
			dpL1[i] = 0
	l.reverse()
	mySet = set()
	rank = 1
	dpL2 = [0 for i in range(n)]
	for i in range(n):
		if l[i] in mySet:
			break
		mySet.add(l[i])
		while rank in mySet:
			mySet.remove(rank)
			rank += 1
		if len(mySet) == 0:
			dpL2[i] = 1
		else:
			dpL2[i] = 0
	dpL2.reverse()
	res = []
	for i in range(n - 1):
		if dpL1[i] == dpL2[i + 1] == 1:
			res.append((i + 1, n - i - 1))
	if len(res) == 0:
		print(0)
	else:
		print(len(res))
		for (i, j) in res:
			print(i, j)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	m = max(a)
	b = []
	if m == n - m:
		c = [m]
	else:
		c = [n - m, m]
	for j in c:
		a1 = a[:j]
		a2 = a[j:]
		if len(a1) == len(set(a1)) and max(a1) == len(a1) and (len(a2) == len(set(a2))) and (max(a2) == len(a2)):
			b.append(len(a1))
			b.append(len(a2))
	bb = int(len(b) / 2)
	print(bb)
	if bb > 0:
		for j in range(0, len(b), 2):
			print(b[j], b[j + 1])


import sys
input = lambda : sys.stdin.readline().rstrip()

def I():
	return [int(iI) for iI in input().split()]

def II():
	return int(input())

def SI():
	return [i for i in input()]
from collections import Counter
for _ in range(II()):
	n = II()
	a = I()
	summ = sum(a)
	sa = summ
	sb = 0
	b = []
	ans = []
	sta = Counter(a)
	stb = {}
	while a:
		if sa == len(sta) * (len(sta) + 1) // 2 and sb == len(stb) * (len(stb) + 1) // 2:
			if len(sta) == len(a) and len(stb) == len(b):
				ans.append([len(a), len(b)])
		sb += a[-1]
		sa -= a[-1]
		sta[a[-1]] -= 1
		if sta[a[-1]] == 0:
			del sta[a[-1]]
		if a[-1] in stb:
			stb[a[-1]] += 1
		else:
			stb[a[-1]] = 1
		b.append(a.pop())
	print(len(ans))
	for i in ans:
		print(*i)


import os
import sys
from math 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')

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

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

def calc(n):
	return n * (n - 1) // 2
for _ in range(int(input())):
	n = int(input())
	a = array()
	f = {}
	ans = []
	flag = 1
	for i in a:
		try:
			f[i] += 1
		except:
			f[i] = 1
		if f[i] >= 3:
			flag = 0
			break
	if flag == 0:
		print(0)
		continue
	ma = [a[0]]
	for i in range(1, n):
		ma.append(max(ma[-1], a[i]))
	ma[-1] = (ma[-1], a[-1])
	for i in range(1, n):
		ma[n - 1 - i] = (ma[n - 1 - i], max(ma[n - i][1], a[n - i - 1]))
	for i in range(n - 1):
		if i + 1 == ma[i][0] and n - i - 1 == ma[i + 1][1]:
			if len(set(a[:i + 1])) == i + 1 and len(set(a[i + 1:])) == n - i - 1:
				ans.append((i + 1, n - i - 1))
	print(len(ans))
	for i in ans:
		print(*i)


import sys
from collections import Counter
mod = 10 ** 9 + 7
INF = float('inf')

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

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

def chk(tmp):
	now = 0
	for i in tmp:
		if i - now != 1:
			return False
		now = i
	return True
for _ in range(inp()):
	res = []
	n = inp()
	a = inpl()
	c = Counter(a)
	ok = True
	now = 0
	s = set()
	for key in sorted(list(c)):
		if c[key] >= 3 or key - now > 1:
			ok = False
			break
		if c[key] == 2:
			s.add(key)
		now = key
	if not ok:
		print(0)
		continue
	d = [-1] * n
	ss = set()
	for (i, x) in enumerate(a):
		if x in ss:
			d[i] = 1
		elif x in s:
			d[i] = 0
			ss.add(x)
	cnt = d.count(0)
	ind = 0
	ok = True
	while cnt > 0 and ind < n:
		if d[ind] != 0:
			ok = False
			break
		cnt -= 1
		ind += 1
	if ok:
		ok = True
		tmp1 = sorted(a[:ind])
		tmp2 = sorted(a[ind:])
		if chk(tmp1) and chk(tmp2):
			res += [[ind, n - ind]]
	cnt = d.count(1)
	ind = n - 1
	ok = True
	while cnt > 0 and 0 <= ind:
		if d[ind] != 1:
			ok = False
			break
		cnt -= 1
		ind -= 1
	if ok:
		ok = True
		tmp1 = sorted(a[:ind + 1])
		tmp2 = sorted(a[ind + 1:])
		if chk(tmp1) and chk(tmp2):
			res += [[ind + 1, n - ind - 1]]
	if len(res) == 2 and res[0] == res[1]:
		res = [res[0]]
	print(len(res))
	for i in res:
		print(*i)


def check(n):
	return n * (n + 1) // 2
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	temp = [0] * (n + 1)
	s = 0
	(pre, suf) = ([0] * n, [0] * n)
	for i in range(n):
		if temp[l[i]] == 1:
			break
		temp[l[i]] = 1
		s += l[i]
		if s == check(i + 1):
			pre[i] = 1
	s = 0
	temp = [0] * (n + 1)
	for i in range(n - 1, -1, -1):
		if temp[l[i]]:
			break
		temp[l[i]] = 1
		s += l[i]
		if s == check(n - i):
			suf[i] = 1
	ans = []
	for i in range(1, n):
		if pre[i - 1] == 1 and suf[i] == 1:
			ans.append([i, n - i])
	print(len(ans))
	for i in ans:
		print(i[0], i[1])


from sys import stdin, stdout

def read():
	x0 = stdin.readline().rstrip()
	return x0

def __main__():
	t = int(read())
	for t0 in range(t):
		n = int(read())
		ax = [int(i) for i in read().split()]
		ind = 0
		fl = True
		s1_left = set()
		while fl:
			elem = ax[ind]
			if elem not in s1_left:
				s1_left.add(elem)
			else:
				fl = False
			ind += 1
			if ind == n:
				fl = False
		s2_left = set(ax[ind - 1:])
		res1left = len(s1_left)
		res2left = n - res1left
		sx = set((g + 1 for g in range(res1left)))
		sy = set((g + 1 for g in range(res2left)))
		if sx - s1_left or sy - s2_left:
			res1 = False
		else:
			res1 = True
		ind = n - 1
		fl = True
		s1_right = set()
		while fl:
			elem = ax[ind]
			if elem not in s1_right:
				s1_right.add(elem)
			else:
				fl = False
			ind -= 1
			if ind < 0:
				fl = False
		s2_right = set(ax[:ind + 2])
		res1right = len(s1_right)
		res2right = n - res1right
		sx = set((g + 1 for g in range(res1right)))
		sy = set((g + 1 for g in range(res2right)))
		if sx - s1_right or sy - s2_right:
			res2 = False
		else:
			res2 = True
		if res1 and res2:
			p0 = '2\n'
		elif res1 or res2:
			p0 = '1\n'
		else:
			p0 = '0\n'
		if p0 == '2\n' and res1left == res2right:
			p0 = '1\n'
			p = str(res1left) + ' ' + str(res2left) + '\n'
			stdout.write(p0)
			stdout.write(p)
		else:
			stdout.write(p0)
			if res1:
				p = str(res1left) + ' ' + str(res2left) + '\n'
				stdout.write(p)
			if res2:
				p = str(res2right) + ' ' + str(res1right) + '\n'
				stdout.write(p)
__main__()


for test in range(int(input())):
	n = int(input())
	lt = [int(x) for x in input().split()]
	m = max(lt)
	p1 = set(lt[:m])
	p2 = set(lt[m:])
	q1 = set(lt[:n - m])
	q2 = set(lt[n - m:])
	nlt = []
	if max(p1) == len(p1) and max(p2) == len(p2) and (len(p1) + len(p2) == n):
		nlt += [[m, n - m]]
	if max(q1) == len(q1) and max(q2) == len(q2) and (len(q1) + len(q2) == n):
		nlt += [[n - m, m]]
	if len(nlt) == 1:
		print(1)
		print(*nlt[0])
	elif len(nlt) == 2:
		if nlt[0] == nlt[1]:
			print(1)
			print(*nlt[0])
		else:
			print(2)
			print(*nlt[0])
			print(*nlt[1])
	else:
		print(0)


T = int(input())
for t in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	c = 0
	cs = 0
	cnt = [0] * n
	cnts = [0] * n
	for i in range(n):
		c += a[i]
		cs += a[i] * a[i] * a[i]
		cnt[i] = c
		cnts[i] = cs
	c = 0
	res = []
	for i in range(n - 1):
		N = i + 1
		k = n - N
		if cnt[i] == N * (N + 1) // 2 and cnt[-1] - cnt[i] == k * (k + 1) // 2 and (cnts[i] == N * (N + 1) // 2 * (N * (N + 1) // 2)) and (cnts[-1] - cnts[i] == k * (k + 1) // 2 * (k * (k + 1) // 2)):
			c += 1
			res.append([N, k])
	print(c)
	for i in res:
		print(*i)


def check(a1, a2):
	(o1, o2) = (True, True)
	for i in range(len(a1)):
		if a1[i] != i + 1:
			o1 = False
	for i in range(len(a2)):
		if a2[i] != i + 1:
			o2 = False
	if o1 and o2:
		return True
	return False
for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	div = n - max(A)
	m = max(A)
	b1 = A.copy()
	b11 = sorted(b1[:m])
	b12 = sorted(b1[m:])
	(o1, o2) = (False, False)
	if check(b11, b12):
		o1 = True
	b2 = A.copy()
	b21 = sorted(b2[:div])
	b22 = sorted(b2[div:])
	if check(b21, b22):
		o2 = True
	if o1 and o2:
		if div != m:
			print(2)
			print(m, div)
			print(div, m)
		else:
			print(1)
			print(m, div)
	elif o1:
		print(1)
		print(m, div)
	elif o2:
		print(1)
		print(div, m)
	else:
		print(0)


t = int(input())
for _ in range(t):
	input()
	nums = list(map(int, input().split()))
	lcandidates = set()
	seen = set()
	maxseen = -1
	for (i, x) in enumerate(nums):
		seen.add(x)
		maxseen = max(maxseen, x)
		if len(seen) == i + 1 and maxseen == len(seen):
			lcandidates.add(i)
	seen = set()
	maxseen = -1
	sol = 0
	sols = []
	for i in range(len(nums) - 1, -1, -1):
		x = nums[i]
		seen.add(x)
		maxseen = max(maxseen, x)
		if len(seen) == len(nums) - i and maxseen == len(seen) and (i - 1 in lcandidates):
			sol += 1
			sols.append((i, len(nums) - i))
	print(sol)
	for (l, r) in sols:
		print(l, r)


from math import *
from copy import *
from string import *
from random import *
from bisect import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
from collections import defaultdict

def solve(l):
	n = len(l)
	pre = [0] + list(accumulate(l))
	ans = []
	(d1, d2) = (defaultdict(int), defaultdict(int))
	(left, right) = ([0] * n, [0] * n)
	(s1, s2) = (set(), set())
	(minn, maxx) = (maxsize, -maxsize)
	for i in range(n):
		minn = min(minn, l[i])
		maxx = max(maxx, l[i])
		s1.add(l[i])
		nn = len(s1)
		if minn == 1 and maxx == nn and (i + 1 == nn):
			if i == 0:
				left[i] = 1
			else:
				left[i] = 1
	j = 0
	(minn, maxx) = (maxsize, -maxsize)
	for i in range(n - 1, -1, -1):
		minn = min(minn, l[i])
		maxx = max(maxx, l[i])
		s2.add(l[i])
		nn = len(s2)
		if minn == 1 and maxx == nn and (j + 1 == nn):
			if i == n - 1:
				right[i] = 1
			else:
				right[i] = 1
		j += 1
	ans = []
	for i in range(n - 1):
		if left[i] == right[i + 1] == 1:
			ans.append([i + 1, n - i - 1])
	return ans
	for i in range(1, n + 1):
		pred = i * (i + 1) // 2
		d1[l[i - 1]] += 1
		d2[l[n - i]] += 1
		if len(d1) == i and len(d2) == n - i and (pre[i] == pred) and (pre[-1] - pre[i] == (n - i) * (n - i + 1) // 2) and (n - i != 0):
			ans.append([i, n - i])
	return ans
T = int(input())
for _ in range(T):
	N = int(stdin.readline())
	l = list(map(int, stdin.readline().rstrip().split()))
	ans = solve(l)
	print(len(ans))
	for i in ans:
		print(*i)


t = int(input())
for query in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	results = set()
	left_side = set()
	i = 0
	while True:
		next = a[i]
		if next not in left_side:
			left_side.add(next)
			i += 1
		else:
			break
	left_len = len(left_side)
	if all([l <= left_len for l in left_side]):
		right_side = set(a[i:])
		desired_right_len = n - i
		right_len = len(right_side)
		if right_len == desired_right_len and all([r <= right_len for r in right_side]):
			results.add(str(left_len) + ' ' + str(right_len))
	right_side = set()
	i = n - 1
	while True:
		next = a[i]
		if next not in right_side:
			right_side.add(next)
			i -= 1
		else:
			break
	right_len = len(right_side)
	if all([r <= right_len for r in right_side]):
		left_side = set(a[0:i + 1])
		desired_left_len = i + 1
		left_len = len(left_side)
		if left_len == desired_left_len and all([l <= left_len for l in left_side]):
			results.add(str(left_len) + ' ' + str(right_len))
	print(len(results))
	for result in results:
		print(result)


for _ in range(int(input())):
	n = int(input())
	ls = [int(x) for x in input().split()]
	m = max(ls)
	ls1 = [i for i in range(1, m + 1)]
	ls2 = [j for j in range(1, n - m + 1)]
	first = False
	last = False
	lsp = ls[0:m]
	lsq = ls[m:n]
	lsp.sort()
	lsq.sort()
	if lsp == ls1 and lsq == ls2:
		first = True
	lsp = ls[0:n - m]
	lsq = ls[n - m:n]
	lsp.sort()
	lsq.sort()
	if lsp == ls2 and lsq == ls1:
		last = True
	if first and last:
		if m != n - m:
			print(2)
			print(m, n - m)
			print(n - m, m)
		else:
			print(1)
			print(m, n - m)
	elif first or last:
		print(1)
		if first:
			print(m, n - m)
		else:
			print(n - m, m)
	else:
		print(0)


import random
import math
from collections import defaultdict
import itertools
from sys import stdin, stdout
import sys
import operator
from decimal import Decimal
p2D = lambda x: print(*x, sep='\n')

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

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

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

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def BI():
	return sys.stdin.buffer.readline().rstrip()

def SI():
	return sys.stdin.buffer.readline().rstrip().decode()

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

def lli(rows):
	return [li() for _ in range(rows)]

def si():
	return input()

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

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

def main():
	for _ in range(ii()):
		n = ii()
		a = li()
		m = max(a)
		cnt = 0
		ans = []
		p1 = a[:m]
		p2 = a[m:]
		q1 = a[:n - m]
		q2 = a[n - m:]
		p1.sort()
		p2.sort()
		q1.sort()
		q2.sort()
		r1 = list(range(1, m + 1))
		r2 = list(range(1, n - m + 1))
		if p1 == r1 and p2 == r2:
			cnt += 1
			ans.append('{} {}'.format(m, n - m))
		if n - m != m:
			if q1 == r2 and q2 == r1:
				cnt += 1
				ans.append('{} {}'.format(n - m, m))
		print(cnt)
		for i in range(cnt):
			print(ans[i])
main()


def check_if_permutation(array):
	get_max = len(array)
	list_range = list(range(1, get_max + 1))
	set_array = set(array)
	for i in list_range:
		if i not in set_array:
			return False
	return True
test_cases = int(input(''))
for i in range(test_cases):
	length = int(input(''))
	string = [int(x) for x in str(input('')).split(' ')]
	set2 = set()
	left_right_set = list()
	for i in string:
		if i not in set2:
			set2.add(i)
			left_right_set.append(i)
		else:
			break
	left_right_set2 = string[len(left_right_set):]
	set3 = set()
	right_left1 = list()
	for i in string[::-1]:
		if i not in set3:
			set3.add(i)
			right_left1.append(i)
		else:
			break
	right_left2 = string[::-1][len(right_left1):]
	if check_if_permutation(left_right_set) == True and check_if_permutation(left_right_set2) == True and (check_if_permutation(right_left1) == True) and (check_if_permutation(right_left2) == True):
		if str(len(right_left2)) == str(len(left_right_set)):
			print(1)
			print(str(len(left_right_set)) + ' ' + str(len(left_right_set2)))
		else:
			print(2)
			print(str(len(left_right_set)) + ' ' + str(len(left_right_set2)))
			print(str(len(right_left2)) + ' ' + str(len(right_left1)))
	elif (check_if_permutation(left_right_set) == True and check_if_permutation(left_right_set2) == True) and (check_if_permutation(right_left1) == False or check_if_permutation(right_left2) == False) == True:
		print(1)
		print(str(len(left_right_set)) + ' ' + str(len(left_right_set2)))
	elif (check_if_permutation(left_right_set) == False or check_if_permutation(left_right_set2) == False) == True and (check_if_permutation(right_left1) == True and check_if_permutation(right_left2) == True) == True:
		print(1)
		print(str(len(right_left2)) + ' ' + str(len(right_left1)))
	else:
		print(0)


from sys import stdin, stdout
from collections import defaultdict
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, stdin.readline().split()))
	d = defaultdict(int)
	(mx, mx1) = (0, 0)
	(mn, mn1) = (20000000, 200000000)
	(ans, ans1) = (True, True)
	c = 0
	l1 = []
	l2 = []
	d1 = defaultdict(int)
	d3 = defaultdict(int)
	d4 = defaultdict(int)
	for j in range(n):
		mx = max(mx, l[j])
		mn = min(mn, l[j])
		d[l[j]] += 1
		if d[l[j]] >= 2:
			ans = False
			break
		if mx == j + 1 and mn == 1 and (ans == True):
			d3[str(j + 1) + ' ' + str(n - j - 1)] = 1
	for j in range(n):
		mx1 = max(mx1, l[n - 1 - j])
		mn1 = min(mn1, l[n - 1 - j])
		d1[l[n - 1 - j]] += 1
		if d1[l[n - 1 - j]] >= 2:
			ans1 = False
			break
		if mx1 == j + 1 and mn1 == 1 and (ans1 == True):
			d4[str(n - j - 1) + ' ' + str(j + 1)] = 1
	for j in d3:
		if d4[j] == 1:
			c += 1
			l1.append(j)
	print(c)
	for j in range(c):
		print(l1[j])


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		ina = int(input())
		lst = list(map(int, input().split()))
		ansp = [lst[0]] + [None] * (ina - 1)
		ansb = [None] * (ina - 1) + [lst[ina - 1]]
		dic1 = {lst[0]: 1}
		dic2 = {}
		for i in range(1, ina):
			front = lst[i]
			back = lst[ina - i - 1]
			currmaxf = ansp[i - 1]
			currmaxb = ansb[ina - i]
			ansp[i] = max(front, currmaxf)
			ansb[ina - i - 1] = max(back, currmaxb)
			freq = dic2.get(lst[i], 0)
			dic2[lst[i]] = freq + 1
		(len1, len2) = (len(dic1), len(dic2))
		ans = []
		if ansp[0] == 1 and ansb[1] == len2 and (ansb[1] == ina - 1):
			ans.append([1, ina - 1])
		for i in range(1, ina - 1):
			front = ansp[i]
			back = ansb[i + 1]
			ele = lst[i]
			freq1 = dic1.get(ele)
			if freq1:
				break
			else:
				len1 += 1
				dic1[ele] = 1
			freq2 = dic2.get(ele)
			dic2[ele] = freq2 - 1
			if freq2 == 1:
				len2 -= 1
			if front == i + 1 and back == ina - i - 1 and (front == len1) and (back == len2):
				ans.append([i + 1, ina - (i + 1)])
		yield len(ans)
		for kap in ans:
			yield (str(kap[0]) + ' ' + str(kap[1]))
t = int(input())
ans = gift()
print(*ans, sep='\n')


import sys
import math as m
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c = [0] * n
	for (i, x) in enumerate(a):
		c[x] += 1
	d = 0
	for i in range(1, n):
		if c[i] != 2:
			break
		d += 1
	e = d > 0
	e = e and all((i == j for (i, j) in zip(sorted(a[:d]), range(1, d + 1))))
	e = e and all((i == j for (i, j) in zip(sorted(a[d:]), range(1, n - d + 1))))
	f = d > 0 and 2 * d < n
	f = f and all((i == j for (i, j) in zip(sorted(a[:n - d]), range(1, n - d + 1))))
	f = f and all((i == j for (i, j) in zip(sorted(a[n - d:]), range(1, d + 1))))
	print(e + f)
	if e:
		print(d, n - d)
	if f:
		print(n - d, d)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	min1 = float('inf')
	max1 = 0
	s1 = set()
	is_perm_pref = [False]
	for i in range(n):
		min1 = min(min1, a[i])
		max1 = max(max1, a[i])
		s1.add(a[i])
		if len(s1) == i + 1 and min1 == 1 and (max1 == i + 1):
			is_perm_pref.append(True)
		else:
			is_perm_pref.append(False)
	min2 = float('inf')
	max2 = 0
	s2 = set()
	is_perm_suff = [False]
	for i in range(n - 1, -1, -1):
		min2 = min(min2, a[i])
		max2 = max(max2, a[i])
		s2.add(a[i])
		if len(s2) == n - i and min2 == 1 and (max2 == n - i):
			is_perm_suff.append(True)
		else:
			is_perm_suff.append(False)
	is_perm_suff.reverse()
	ans = []
	for i in range(n + 1):
		if is_perm_pref[i] and is_perm_suff[i]:
			ans.append((i, n - i))
	print(len(ans))
	for i in ans:
		print(*i)