You are given an array [A_{1}, \ldots, A_{N}]. You want to split it into several (≥ 2) [subarrays] so that the following condition holds:

Calculate the sum of elements in each subarray. Then, the AND of all these sums is nonzero, where AND denotes the bitwise AND operation.

Determine if it's possible. If it's possible, find one such split. You don't have to minimize the number of subarrays.

------ Input Format ------ 

- The first line of the input contains a single integer T - the number of test cases. The description of the test cases follows.
- The first line of each test case contains a single integer N - the length of the array.
- The second line of each test case contains N space-separated integers A_{1}, A_{2}, \ldots, A_{N}.

------ Output Format ------ 

For each test case, if it's not possible to split the array so that the condition from the statement holds, output NO. 

Otherwise, output YES. In the next line, output K (2 ≤ K ≤ N) - the number of subarrays you are splitting into. 

In the i-th of the next K lines, output two integers L_{i}, R_{i} (1 ≤ L_{i} ≤ R_{i} ≤ N), where [L_{i}, R_{i}] denotes the i-th subarray. 

Each number from 1 to N has to appear in exactly one of the segments [L_{i}, R_{i}].

You can output each letter in either uppercase or lowercase. You can output any solution. You don't have to minimize K.

------ Constraints ------ 

$1 ≤ T ≤ 10^{5}$
$2 ≤ N ≤ 10^{5}$
$0 ≤ A_{i} < 2^{30}$
- Sum of $N$ over all test cases doesn't exceed $2\cdot 10^{5}$

----- Sample Input 1 ------ 
5
4
1 9 8 4
3
0 0 0
2
16 15
5
1 2 6 24 120
7
8 6 0 16 24 0 8

----- Sample Output 1 ------ 
YES
2
2 4
1 1
NO
NO
YES
2
1 2
3 5
YES
3
1 1
6 7
2 5
----- explanation 1 ------ 
Test case $1$: You can split the array into two subarrays $[2, 4]$ and $[1, 1]$. They have sums $21$ and $1$ correspondingly, whose AND is $1$.

Test case $4$: You can split the array into two subarrays $[1, 2]$ and $[3, 5]$. They have sums $3$ and $150$ correspondingly, whose AND is $2$.

Test case $5$: You can split the array into three subarrays $[1, 1]$, $[6, 7]$, $[2, 5]$. They have sums $8$, $8$, $46$, whose AND is $8$.

It's possible to show that it's impossible to split in the desired way in the second and the third test cases.

Source: codechef | Difficulty: HARD
Tags: Greedy algorithms

Constructive algorithms


Solutions:
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	ar = [int(x) for x in input().split()]
	f = 0
	b = [[0 for x in range(31)] for x in range(n)]
	for i in range(n):
		x = ar[i]
		j = 0
		while x > 0:
			d = x % 2
			x //= 2
			b[i][j] = d
			j += 1
	bit = 0
	while bit < 31:
		a = []
		for i in range(n):
			if b[i][bit] == 1:
				a.append(i + 1)
		bit += 1
		if len(a) < 2:
			continue
		print('YES')
		f = 1
		print(len(a))
		i = 0
		print(1, a[i])
		a[len(a) - 1] = n
		while i < len(a) - 1:
			print(a[i] + 1, a[i + 1])
			i += 1
		break
	if f == 0:
		print('NO')


import sys
import os
import math
from collections import *
import bisect
from heapq import *
from itertools import permutations, combinations
if os.path.exists('input.txt') and os.path.exists('output.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
input = sys.stdin.readline

def lcm(a, b):
	k1 = math.gcd(a, b)
	k2 = a * b
	return k2 // k1

def inp():
	return map(int, input().strip().split(' '))

def lis():
	return list(inp())
mod = 998244353

def prim(n):
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True

def dfs(adj, vis, u, l):
	vis[u] = 1
	l.add(u)
	for i in adj[u]:
		if vis[i] == 0:
			dfs(adj, vis, i, l)
mod = 10 ** 9 + 7
ma = 1002
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

def dfs(i, j, arr, vis, n, m):
	vis[i][j] = 1
	for x in range(4):
		mx = i + dx[x]
		my = j + dy[x]
		if mx >= 0 and mx < n and (my >= 0) and (my < m) and (vis[mx][my] == 0):
			if arr[i][j] >= arr[mx][my]:
				dfs(mx, my, arr, vis, n, m)

def dfs(a, vis, node, c):
	vis[node] = 1
	c[0] += 1
	if vis[a[node]] == 0:
		dfs(a, vis, a[node], c)
mod = 998244353
ma = 2 * (10 ** 5 + 1)
mod = 10 ** 9 + 7

def f(n):
	if n % 4 == 0:
		return n
	if n % 4 == 1:
		return 1
	if n % 4 == 2:
		return n + 1
	return 0

def dfs(node, par, adj, dp, v):
	dp[node] = 1
	for i in adj[node]:
		if i[0] != par:
			dfs(i[0], node, adj, dp, v)
			dp[node] += dp[i[0]]

def dfs1(node, par, adj, dp, v):
	for i in adj[node]:
		if i[0] != par:
			if i[1] == 1:
				v.append(dp[i[0]])
			else:
				dfs1(i[0], node, adj, dp, v)
l = []
for i in range(1, 2 ** 9 + 1):
	l.append(int(bin(i)[2:]))

def finv(p, q):
	expo = 0
	expo = mod - 2
	while expo:
		if expo & 1:
			p = p * q % mod
		q = q * q % mod
		expo >>= 1
	return p

def pal(s):
	n = len(s)
	for i in range(n):
		if s[i] != s[n - 1 - i]:
			return False
	return True

def f(n):
	res = 2
	while res * res <= n:
		if n % res == 0:
			return False
		res += 1
	return True

def f(l):
	mp = {word[::-1]: index for (index, word) in enumerate(l)}
	ans = []
	for (index, word) in enumerate(l):
		for i in range(len(word)):
			(left, right) = (word[:i + 1], word[i + 1:])
			if not len(left) == 0 and left == left[::-1] and (right in mp) and (mp[right] != index):
				ans.append([mp[right], index])
			if right == right[::-1] and left in mp and (mp[left] != index):
				ans.append([index, mp[left]])
	return ans

def pal(s):
	n = len(s)
	for i in range(n):
		if s[i] != s[n - 1 - i]:
			return False
	return True
mod = 10 ** 9 + 7

def solve():
	n = int(input())
	a = lis()
	c = 1
	for j in range(32):
		l = []
		for i in range(n):
			if a[i] & c:
				l.append(i)
		if len(l) > 1:
			cur = 0
			print('YES')
			print(len(l))
			for i in range(len(l) - 1):
				print(cur + 1, l[i] + 1)
				cur = l[i] + 1
			print(cur + 1, n)
			return
		c <<= 1
	print('NO')
t = int(input())
for _ in range(t):
	solve()


from collections import defaultdict
from collections import Counter
import math
import bisect

class dsu:

	def __init__(self):
		self.parent = defaultdict(int)
		self.size = [0] * (n + 1)

	def start(self):
		for i in range(1, n + 1):
			self.parent[i] = i

	def find(self, x):
		if x != self.parent[x]:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, u, v):
		(u, v) = (self.find(u), self.find(v))
		if u != v:
			self.parent[v] = u

	def treeinput(self, m):
		for i in range(m):
			(u, v) = map(int, input().split())
			self.union(u, v)

	def printt(self):
		print(self.parent)

def setbit(arr):
	mask = 1
	bit = [0] * 32
	for i in range(32):
		for k in arr:
			if k & mask:
				bit[i] += 1
		mask <<= 1
	return bit

def prefix_sum(nums):
	prefix = [0]
	for i in range(len(nums)):
		prefix.append(prefix[-1] + nums[i])
	return prefix

def mx_lensubarray(nums):
	res = 0
	j = 0
	mp = defaultdict(int)
	prefix = prefixsum(nums)
	mxSum = 0
	for i in range(len(nums)):
		if nums[i] in mp:
			temp = mp[nums[i]]
		else:
			temp = 0
		j = max(temp, j)
		mp[nums[i]] = i + 1
		res = max(res, i - j + 1)
		mxSum = max(mxSum, prefix[i + 1] - prefix[j])
	return res

def lenOfLongSubarr(self, A, N, k):
	mp = {}
	sm = 0
	mxlen = 0
	for i in range(N):
		sm += A[i]
		if sm == k:
			mxlen = i + 1
		if sm - k in mp:
			mxlen = max(mxlen, i - mp[sm - k])
		if sm not in mp:
			mp[sm] = i
	return mxlen

def no_of_factor(s):
	cnt = 0
	x = int(s ** 0.5)
	for i in range(1, x + 1):
		if not s % i:
			cnt = cnt + 1 if s / i == i else cnt + 2
		i += 1
	return cnt

def primes(n):
	arr = []
	i = 2
	while i * i <= n:
		if not n % i:
			cnt = 0
			while not n % i:
				cnt += 1
				n //= i
			arr.append([i, cnt])
		i += 1
	if n > 1:
		arr.append([n, 1])
	return arr

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
	res = []
	for i in range(2, n + 1):
		if prime[i]:
			res.append(i)
	return res

def treeinput():
	adj = [[] for i in range(n + 1)]
	for i in range(n - 1):
		(u, v) = map(int, input().split())
		adj[u].append(v)
		adj[v].append(u)

def dfs_size(node, parent):
	sum_size[node] = 1
	for child in adj[node]:
		if child != parent:
			dfs_size(child, node)
			sum_size[node] += sum_size[child]

def anda(arr):
	res = arr[0]
	for i in arr:
		res &= i
	return res

def ora(arr):
	res = arr[0]
	for i in arr:
		res |= i
	return res

def xora(arr):
	res = 0
	for i in arr:
		res ^= i
	return res
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	(f, mask) = (0, 1)
	for i in range(32):
		cnt = 0
		for num in arr:
			if num & mask:
				cnt += 1
		if cnt >= 2:
			f = 1
			break
		mask <<= 1
	if f:
		print('YES')
		l = 0
		r = 0
		ans = []
		for i in range(n):
			if arr[i] & mask:
				ans.append([l + 1, i + 1])
				l = i + 1
		ans[-1][-1] = n
		print(len(ans))
		for i in ans:
			print(*i)
	else:
		print('NO')


resultAns = ''
for _ in range(int(input())):
	number = int(input())
	arrayList = list(map(int, input().split()))
	inclusive = -1
	countNumber = 0
	for i in range(32):
		counter = 0
		for j in range(number):
			if arrayList[j] & 1 << i != 0:
				counter += 1
		if counter > 1:
			inclusive = i
			countNumber = counter
			break
	if inclusive == -1:
		resultAns += 'NO\n'
	else:
		resultAns += 'YES\n'
		resultAns += str(countNumber) + '\n'
		lastDigit = 1
		for i in range(number):
			if arrayList[i] & 1 << inclusive != 0 and countNumber > 1:
				resultAns += str(lastDigit) + ' ' + str(i + 1) + '\n'
				lastDigit = i + 2
				countNumber -= 1
		resultAns += str(lastDigit) + ' ' + str(number) + '\n'
print(resultAns)


ans = ''
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ind = -1
	count = 0
	for i in range(32):
		cnt = 0
		for j in range(n):
			if arr[j] & 1 << i != 0:
				cnt += 1
		if cnt > 1:
			ind = i
			count = cnt
			break
	if ind == -1:
		ans += 'NO\n'
	else:
		ans += 'YES\n'
		ans += str(count) + '\n'
		last = 1
		for i in range(n):
			if arr[i] & 1 << ind != 0 and count > 1:
				ans += str(last) + ' ' + str(i + 1) + '\n'
				last = i + 2
				count -= 1
		ans += str(last) + ' ' + str(n) + '\n'
print(ans)


t = int(input())
while t > 0:
	n = int(input())
	ar = [int(i) for i in input().split(' ')]
	ind = [1]
	i = 0
	while i < 30 and len(ind) < 2:
		ind.clear()
		x = 1 << i
		for j in range(n):
			if ar[j] & x > 0:
				ind.append(j)
		i += 1
	length = len(ind)
	if length >= 2:
		print('YES')
		print(len(ind))
		prev = 0
		for i in ind[:-1]:
			print(prev + 1, i + 1)
			prev = i + 1
		print(prev + 1, n)
	else:
		print('NO')
	t -= 1


from math import *
import sys

def input():
	return sys.stdin.readline().replace('\n', '').strip()
sys.setrecursionlimit(10 ** 9)

def process(l):
	start = 1
	n = len(l)
	print(n)
	for i in range(n):
		end = l[i] + 1
		print(start, end)
		start = end + 1
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	max_bit = 65
	bin_array = [[0 for i in range(max_bit)] for j in range(n)]
	for i in range(n):
		num = l[i]
		_bin = str(bin(num)[2:])
		c = 0
		for j in _bin[::-1]:
			bin_array[i][c] = int(j)
			c += 1
	for i in range(max_bit):
		split_point = []
		j = 0
		while j < n:
			if bin_array[j][i] == 1:
				split_point.append(j)
			j += 1
		if split_point == []:
			continue
		elif split_point[-1] != n - 1:
			split_point[-1] = n - 1
		if len(split_point) > 1:
			print('YES')
			process(split_point)
			break
	else:
		print('NO')


import math
from bisect import bisect, bisect_left, bisect_right
import heapq
from functools import reduce
from math import gcd, floor, sqrt, log
from collections import defaultdict as ddc
from collections import Counter

def intin():
	return int(input())

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

def strin():
	return input().split()
INF = 10 ** 20
mod = 1000000007

def LIS(arr, n):
	dp = [10 ** 9] * (n + 1)
	for ele in arr:
		dp[bisect_left(dp, ele)] = ele
	return bisect_left(dp, 10 ** 9)

def exponentiation(bas, exp, mod=1000000007):
	t = 1
	while exp > 0:
		if exp % 2 != 0:
			t = t * bas % mod
		bas = bas * bas % mod
		exp //= 2
	return t % mod

def MOD(p, q=1, mod=1000000007):
	expo = 0
	expo = mod - 2
	while expo:
		if expo & 1:
			p = p * q % mod
		q = q * q % mod
		expo >>= 1
	return p
yes = 'YES'
no = 'NO'
even = 'EVEN'
odd = 'ODD'

def process(arr, n):
	AND = reduce(lambda a, b: a & b, arr)
	if AND != 0:
		print('YES')
		print(n)
		for i in range(n):
			print(i + 1, i + 1)
		return
	bits = [0] * 32
	for num in arr:
		i = 0
		while num:
			bits[i] += num & 1
			num >>= 1
			i += 1
	idx = 0
	while idx < 32:
		if bits[idx] > 1:
			break
		idx += 1
	if idx == 32:
		print('NO')
		return
	print('YES')
	print(bits[idx])
	last = 1
	for i in range(n):
		if arr[i] & 1 << idx:
			print(last, i + 1)
			last = i + 2
			bits[idx] -= 1
		if bits[idx] == 1:
			break
	print(last, n)

def main():
	for _ in range(int(input())):
		n = intin()
		arr = list(mapin())
		process(arr, n)
main()


import sys
sys.setrecursionlimit(1000000)

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

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

def si():
	return str(input())

def ni():
	return int(input())

def printyes():
	print('YES')

def printno():
	print('NO')

def find(a, j):
	count = 0
	loc = [0]
	for i in range(len(a)):
		if a[i] & 1 << j:
			count += 1
			loc.append(i + 1)
	if count < 2:
		return False
	ans = []
	for i in range(1, len(loc) - 1):
		ans.append((loc[i - 1] + 1, loc[i]))
	ans.append((loc[-2] + 1, len(a)))
	return ans
for t in range(int(input())):
	n = ni()
	a = li()
	final = 'NO'
	ans = []
	for j in range(32):
		temp = find(a, j)
		if temp:
			final = 'YES'
			ans = temp
			break
	print(final)
	if ans:
		print(len(ans))
		for i in ans:
			print(*i)


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	for i in range(31):
		(cnt, target) = (0, 1 << i)
		v = []
		for j in range(n):
			if a[j] & target:
				v.append(j + 1)
		if len(v) > 1:
			break
	if len(v) > 1:
		print('YES')
		print(len(v))
		print(f'1 {v[0]}')
		for i in range(1, len(v)):
			if i + 1 < len(v):
				print(f'{v[i - 1] + 1} {v[i]}')
			else:
				print(f'{v[i - 1] + 1} {n}')
	else:
		print('NO')


def solve(n, arr):
	for i in range(31):
		left = 0
		intervals = []
		for j in range(n):
			if arr[j] & 1 << i > 0:
				intervals.append([left + 1, j + 1])
				left = j + 1
		if len(intervals) <= 1:
			continue
		intervals[-1][1] = n
		break
	if not intervals:
		return 'NO'
	res = f'YES\n{len(intervals)}\n'
	for (left, right) in intervals:
		res += f'{left} {right}\n'
	return res[:-1]
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	print(solve(n, arr))


test = int(input())
while test:
	n = int(input())
	a = [bin(int(x)) for x in input().split()]
	ans = []
	for i in range(-1, -31, -1):
		for j in range(n):
			if len(a[j]) - 2 >= -i and a[j][i] == '1':
				ans.append(j + 1)
		if len(ans) > 1:
			break
		else:
			ans.clear()
	if ans:
		print('YES')
		print(len(ans))
		ans.insert(0, 0)
		ans[-1] = n
		for i in range(1, len(ans)):
			print(ans[i - 1] + 1, ans[i])
	else:
		print('NO')
	test -= 1


import math
from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	d = defaultdict(list)
	for (i, x) in enumerate(arr):
		nt = x
		while nt > 0:
			temp = 2 ** int(math.log(nt, 2))
			nt -= temp
			d[temp].append(i + 1)
	key = list(d.keys())
	val = list(d.values())
	key.sort()
	if len(val) == 0:
		print('NO')
	else:
		flag = True
		for k in key:
			x = d[k]
			lx = len(x)
			if lx > 1:
				flag = False
				print('YES')
				print(lx)
				print(1, x[0])
				for i in range(1, lx):
					if i == lx - 1:
						print(x[i - 1] + 1, n)
						break
					print(x[i - 1] + 1, x[i])
				break
		if flag:
			print('NO')


from sys import stdin, stdout
from collections import defaultdict, Counter, deque
import math, heapq, bisect
input = stdin.readline
t = int(input().strip())
for _ in range(t):
	n = int(input().strip())
	a = list(map(int, input().strip().split()))
	k = 1
	flag = 0
	for i in range(31):
		total = 0
		res = list()
		start = 1
		for j in range(n):
			total += a[j]
			if total & k:
				res.append([start, j + 1])
				total = 0
				start = j + 2
		if len(res) >= 2:
			flag = 1
			res[-1][1] = n
			break
		k <<= 1
	if flag:
		print('YES')
		print(len(res))
		for li in res:
			print(*li)
	else:
		print('NO')


from math import ceil, log, floor, sqrt, gcd
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if a == [0] * n:
		print('NO')
	else:
		s = 1
		for i in range(32):
			p2 = 2 ** i
			lst = []
			for j in range(n):
				if p2 & a[j]:
					lst += [j]
			if len(lst) > 1:
				break
		else:
			print('NO')
			continue
		print('YES')
		print(len(lst))
		s = 1
		for i in range(len(lst) - 1):
			print(s, lst[i] + 1)
			s = lst[i] + 2
		print(s, n)


from bisect import bisect_left
from re import sub
import re
from typing import DefaultDict
import math
from collections import defaultdict
from math import sqrt
import collections
from sys import maxsize
from itertools import combinations_with_replacement
import sys
import copy

def sieve_erasthones(n):
	cnt = 0
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p ** 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = False
	prime[1] = False
	return prime

def calculate(p, q):
	mod = 998244353
	expo = 0
	expo = mod - 2
	while expo:
		if expo & 1:
			p = p * q % mod
		q = q * q % mod
		expo >>= 1
	return p

def count_factors(n):
	i = 1
	c = 0
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				c += 1
			else:
				c += 2
		i += 1
	return c

def ncr_modulo(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 isprime(n):
	prime_flag = 0
	if n > 1:
		for i in range(2, int(sqrt(n)) + 1):
			if n % i == 0:
				prime_flag = 1
				break
		if prime_flag == 0:
			return True
		else:
			return False
	else:
		return True

def smallestDivisor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i * i <= n:
		if n % i == 0:
			return i
		i += 2
	return n

def dict_ele_count(l):
	d = DefaultDict(lambda : 0)
	for ele in l:
		d[ele] += 1
	return d

def max_in_dict(d):
	maxi = 0
	for ele in d:
		if d[ele] > maxi:
			maxi = d[ele]
	return maxi

def element_count(s):
	l = []
	k = s[0]
	c = 0
	for ele in s:
		if ele == k:
			c += 1
		else:
			l.append([k, c])
			k = ele
			c = 1
	l.append([k, c])
	return l

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

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

def twosum(a, n, x):
	rem = []
	for i in range(x):
		rem.append(0)
	for i in range(n):
		if a[i] < x:
			rem[a[i] % x] += 1
	for i in range(1, x // 2):
		if rem[i] > 0 and rem[x - i] > 0:
			return True
	if i >= x // 2:
		if x % 2 == 0:
			if rem[x // 2] > 1:
				return True
			else:
				return False
		elif rem[x // 2] > 0 and rem[x - x // 2] > 0:
			return True
		else:
			return False

def divSum(num):
	result = 0
	i = 2
	while i <= math.sqrt(num):
		if num % i == 0:
			if i == num / i:
				result = result + i
			else:
				result = result + (i + num / i)
		i = i + 1
	return result + 1 + num

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

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

def calc(s):
	ans = 0
	for ele in s:
		ans += ord(ele) - 96
	return ans

def modInverse(b, m):
	g = math.gcd(b, m)
	if g != 1:
		return -1
	else:
		return pow(b, m - 2, m)

def modDivide(a, b, m):
	a = a % m
	inv = modInverse(b, m)
	return inv * a % m

def count(n):
	ans = 0
	while n:
		ans += n % 10
		n //= 10
	return ans

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

def solve():
	n = int(input())
	bool = True
	l = list(map(int, input().split()))
	x = -1
	for i in range(31):
		c = 0
		k = 2 ** i
		for ele in l:
			if ele & k != 0:
				c += 1
		if c > 1:
			x = k
			break
	if x == -1:
		print('NO')
	else:
		ans = []
		for i in range(n):
			if l[i] & x != 0:
				ans.append(i + 1)
		print('YES')
		print(len(ans))
		print(1, ans[0])
		for i in range(1, len(ans) - 1):
			print(ans[i - 1] + 1, ans[i])
		print(ans[-2] + 1, n)
for _ in range(int(input())):
	solve()


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	bit = [0] * 32
	ok = False
	for i in a:
		for j in range(32):
			if i & 1 << j > 0:
				bit[j] += 1
				if bit[j] > 1:
					ok = True
	if ok:
		print('YES')
		ans = -1
		for i in range(32):
			if bit[i] > 1:
				print(bit[i])
				ans = i
				break
		s = 0
		st = 1
		c = 1
		for i in range(n):
			s += a[i]
			if s & 1 << ans > 0:
				if c != bit[ans]:
					print(st, i + 1)
					st = i + 2
					s = 0
				else:
					print(st, n)
					break
				c += 1
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	i = 1
	flag = True
	while i < 1000000000.0:
		t = 0
		for j in range(n):
			if a[j] & i == i:
				t += 1
		if t >= 2:
			flag = False
			print('YES')
			print(t)
			f = 1
			s = -1
			for j in range(n):
				if a[j] & i == i:
					s = j + 1
					print(f, s)
					t -= 1
					f = j + 2
				if t == 1:
					break
			print(f, n)
			break
		i *= 2
	if flag:
		print('NO')


from math import ceil
from collections import defaultdict
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c = 1
	poss = False
	for bit in range(31):
		ans = []
		cs = 0
		l = 0
		for j in range(n):
			cs += a[j]
			if cs & c != 0:
				ans.append((l, j))
				l = j + 1
				cs = 0
		if l == n and len(ans) >= 2:
			print('YES')
			print(len(ans))
			for (x, y) in ans:
				print(x + 1, y + 1)
			poss = True
			break
		elif len(ans) >= 2:
			(pl, pr) = ans.pop()
			cs = 0
			for j in range(pl, n):
				cs += a[j]
			if cs & c != 0:
				ans.append((pl, n - 1))
			print('YES')
			print(len(ans))
			for (x, y) in ans:
				print(x + 1, y + 1)
			poss = True
			break
		c = c * 2
	if not poss:
		print('NO')


import sys
import math
from collections import defaultdict, Counter, deque
from bisect import *
from string import ascii_lowercase
from heapq import *

def readInts():
	x = list(map(int, sys.stdin.readline().rstrip().split()))
	return x[0] if len(x) == 1 else x

def readList(type=int):
	x = sys.stdin.readline()
	x = list(map(type, x.rstrip('\n\r').split()))
	return x

def readStr():
	x = sys.stdin.readline().rstrip('\r\n')
	return x
write = sys.stdout.write
read = sys.stdin.readline

def dist(x1, x2, y1, y2):
	return math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)

def mergeSort(arr, check=lambda a, b: a < b, reverse=False):
	if len(arr) > 1:
		mid = len(arr) // 2
		L = arr[:mid]
		R = arr[mid:]
		mergeSort(L, check, reverse)
		mergeSort(R, check, reverse)
		i = j = k = 0
		while i < len(L) and j < len(R):
			if check(L[i], R[j]):
				if not reverse:
					arr[k] = L[i]
					i += 1
				else:
					arr[k] = R[j]
					j += 1
			elif not reverse:
				arr[k] = R[j]
				j += 1
			else:
				arr[k] = L[i]
				i += 1
			k += 1
		while i < len(L):
			arr[k] = L[i]
			i += 1
			k += 1
		while j < len(R):
			arr[k] = R[j]
			j += 1
			k += 1

def maxSum(arr, k):
	max_sum = 0
	max_cur = 0
	for (i, num) in enumerate(arr):
		max_cur = max(max_cur + num, num)
		if max_cur > max_sum:
			max_sum = max_cur
	return max_sum

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

def get_power(n, m):
	i = 1
	p = -1
	while i <= n:
		i = i * m
		p += 1
	return p

def fact(n):
	f = 1
	for i in range(2, n + 1):
		f *= i
	return f

def find_closest(num, ar):
	min_d = float('inf')
	for num2 in ar:
		d = abs(num2 - num)
		if d < min_d:
			min_d = d
	return min_d

def check_pal(n):
	s = str(n)
	j = len(s) - 1
	i = 0
	while j > i:
		if s[i] != s[j]:
			return False
		i += 1
		j -= 1
	return True

def solve(t):
	n = readInts()
	ar = readList()
	sar = sorted(ar)
	flag = False
	bcnt = [0 for _ in range(30)]
	anum = -1
	for (i, num) in enumerate(sar):
		k = 0
		while num > 0:
			if num & 1:
				bcnt[k] += 1
			k += 1
			num = num >> 1
	for i in range(30):
		if bcnt[i] > 1:
			flag = True
			anum = 2 ** i
			break
	if not flag:
		print('NO')
		return
	res = []
	j = 0
	while j < n:
		num = ar[j]
		if num & anum:
			res.append([j + 1, j + 1])
		else:
			tmp = j
			while j < n and (not ar[j] & anum):
				j += 1
			if j < n and ar[j] & anum:
				res.append([tmp + 1, j + 1])
			else:
				res[-1][1] = n
		j += 1
	if len(res) < 2:
		print('NO')
	else:
		print('YES')
		print(len(res))
		for pair in res:
			print(*pair)

def main():
	t = 1
	sys.setrecursionlimit(1000)
	t = readInts()
	for i in range(t):
		solve(i + 1)
main()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if n == 2:
		if l[0] & l[1] > 0:
			print('YES')
			print(2)
			print(1, 1)
			print(2, 2)
			continue
		else:
			print('NO')
			continue
	c0 = 0
	c1 = 0
	pos = []
	a = l[0]
	for j in range(n):
		i = l[j]
		if i == 0:
			c0 += 1
		elif i % 2 == 1:
			c1 += 1
			pos.append(j + 1)
		a &= i
	if c0 >= n - 1:
		print('NO')
	elif c1 >= 2:
		print('YES')
		print(c1)
		print(1, pos[0])
		for i in range(len(pos) - 2):
			print(pos[i] + 1, pos[i + 1])
		print(pos[-2] + 1, n)
	elif a > 0:
		print('YES')
		print(n)
		for i in range(0, n):
			print(i + 1, i + 1)
	else:
		pos.clear()
		pos = {}
		for i in range(31):
			pos[i] = []
		for k in range(n):
			i = l[k]
			if i == 0:
				continue
			i = bin(i)
			for j in range(1, len(i) - 1):
				if i[-j] == '1':
					pos[j - 1].append(k + 1)
		for i in pos:
			if len(pos[i]) > 1:
				print('YES')
				print(len(pos[i]))
				pos = pos[i]
				print(1, pos[0])
				for i in range(len(pos) - 2):
					print(pos[i] + 1, pos[i + 1])
				print(pos[-2] + 1, n)
				break
		else:
			print('NO')


for _ in range(int(input())):
	try:
		n = int(input())
		l = list(map(int, input().strip().split()))
		(ind, c) = (-1, 0)
		for i in range(32):
			c1 = 0
			for j in l:
				if j & 1 << i:
					c1 += 1
			if c1 > 1:
				c = c1
				ind = i
				break
		if ind == -1:
			print('NO')
			continue
		print('YES')
		print(c)
		x = 1
		c -= 1
		for i in range(n):
			if c == 0:
				break
			if l[i] & 1 << ind:
				print(x, end=' ')
				print(i + 1)
				x = i + 2
				c -= 1
		print(x, end=' ')
		print(n)
	finally:
		pass


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	output_arr = None
	for i in range(n):
		z = format(arr[i], '032b')
		arr[i] = z[::-1]
	res = False
	for j in range(32):
		result = []
		for i in range(len(arr)):
			if arr[i][j] == '1':
				result.append(i)
		if len(result) > 1:
			output_arr = result.copy()
			res = True
			break
	if res == False:
		print('NO')
	else:
		print('YES')
		if len(output_arr) % 2 == 0:
			print(2)
			print(1, output_arr[0] + 1)
			print(output_arr[0] + 2, n)
		else:
			print(3)
			print(1, output_arr[0] + 1)
			print(output_arr[0] + 2, output_arr[1] + 1)
			print(output_arr[1] + 2, n)


for iota in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	odd = []
	while True:
		if len(odd) >= 2:
			break
		if a == [0] * n:
			break
		odd = []
		for i in range(n):
			if a[i] % 2 == 1:
				odd.append(i)
			a[i] >>= 1
	if len(odd) < 2:
		print('NO')
	else:
		print('YES')
		print(len(odd))
		for i in range(len(odd)):
			if i == 0:
				print(1, odd[i] + 1)
				continue
			if i == len(odd) - 1:
				print(odd[i - 1] + 2, n)
				continue
			print(odd[i - 1] + 2, odd[i] + 1)


import sys
input = lambda : sys.stdin.readline()
T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	L = [0 for i in range(32)]
	for i in a:
		for j in range(32):
			if i & 1 << j:
				L[j] += 1
	f = False
	for i in range(32):
		if L[i] > 1:
			f = True
			print('YES')
			t = L[i]
			print(L[i])
			break
	if not f:
		print('NO')
		continue
	j = 1
	for value in range(n):
		if a[value] & 1 << i:
			if t > 1:
				print(j, value + 1)
				t -= 1
			else:
				print(j, n)
			j = value + 2


def fun(n, a):
	if a == [0] * n:
		print('NO')
		return
	l = []
	for i in range(n):
		if a[i] % 2 == 1:
			l.append(i)
	if len(l) > 1:
		print('YES')
		print(len(l))
		x = 1
		for i in range(len(l) - 1):
			print(x, l[i] + 1)
			x = l[i] + 2
		print(x, n)
		return
	L = [a[i] // 2 for i in range(n)]
	return fun(n, L)
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	fun(n, a)


for s in [*open(0)][2::2]:
	l = [*map(int, s.split())]
	f = 1
	for i in range(30):
		b = 1 << i
		ind = []
		for j in range(len(l)):
			if l[j] & b:
				ind += [j]
		if len(ind) > 1:
			print('YES')
			print(len(ind))
			ind = sorted(ind)
			p = 0
			for x in ind[:-1]:
				print(p + 1, x + 1)
				p = x + 1
			print(p + 1, len(l))
			f = 0
			break
	if f == 1:
		print('NO')


import sys
from math import sqrt, gcd, factorial, ceil, floor, pi
from collections import deque, Counter, OrderedDict
from heapq import heapify, heappush, heappop
input = lambda : sys.stdin.readline()
I = lambda : int(input())
S = lambda : input().strip()
M = lambda : map(int, input().strip().split())
L = lambda : list(map(int, input().strip().split()))
mod = 1000000007
for _ in range(I()):
	n = I()
	a = L()
	arr = [0] * 32
	for i in a:
		for j in range(32):
			if i & 1 << j:
				arr[j] += 1
	ans = 'NO'
	for i in range(32):
		if arr[i] > 1:
			ans = 'YES'
			print(ans)
			c = arr[i]
			print(arr[i])
			break
	if ans == 'NO':
		print(ans)
		continue
	j = 1
	for k in range(n):
		if a[k] & 1 << i:
			if c > 1:
				print(j, k + 1)
				c -= 1
			else:
				print(j, n)
			j = k + 2