Chef has  $N$ boxes arranged in a line.Each box has some candies in it,say $C[i]$. Chef wants to distribute all the candies between of his friends: $A$ and $B$, in the following way:
$A$ starts eating candies kept in the leftmost box(box at $1$st place) and $B$ starts eating candies kept in the rightmost box(box at $N$th place). $A$ eats  candies $X$ times faster than $B$ i.e. $A$ eats $X$ candies when $B$ eats only $1$. Candies in each box can be eaten by only the person who reaches that box first. If both reach a box at the same time, then the one who has eaten from more number of BOXES till now will eat the candies in that box. If both have eaten from the same number of boxes till now ,then $A$ will eat the candies in that box.
Find the number of boxes finished by both $A$ and $B$.
NOTE:- We assume that it does not take any time to switch from one box to another.

-----Input:-----
- First line will contain $T$, number of testcases. Then the testcases follow. 
- Each testcase contains three lines of input.
The first line of each test case contains $N$, the number of boxes.
- The second line of each test case contains a sequence,$C_1$ ,$C_2$ ,$C_3$ . . . $C_N$ where $C_i$ denotes the number of candies in the i-th box.  
- The third line of each test case contains an integer $X$ .

-----Output:-----
For each testcase, print two space separated integers in a new line - the number of boxes eaten by $A$  and  $B$ respectively. 

-----Constraints-----
- $1 \leq T \leq 100$
- $1 \leq N \leq 200000$
- $1 \leq C_i \leq 1000000$
- $1 \leq X \leq 10$
- Sum of $N$ over all test cases does not exceed $300000$

-----Subtasks-----
Subtask 1(24 points):
- $1 \leq T \leq 10$
- $1 \leq N \leq 1000$
- $1 \leq C_i \leq 1000$
- $1 \leq X \leq 10$
Subtask 2(51 points): original constraints

-----Sample Input:-----
1
5
2 8 8 2 9
2

-----Sample Output:-----
4 1

-----EXPLANATION:-----
$A$ will start eating candies in the 1st box(leftmost box having 2 candies) . $B$ will start eating candies in the  5th box(rightmost box having 9 candies) .As $A's$ speed is 2 times as that of $B's$, $A$ will start eating candies in the  2nd box while $B$ would still be eating candies in the 5th box.$A$ will now start eating candies from the 3rd box while $B$ would still be eating candies in the 5th box.Now both $A$ and $B$ will finish candies in their respective boxes at the same time($A$ from the 3rd box and $B$ from 5th box). Since $A$ has eaten more number of boxes($A$ has eaten 3 boxes while $B$ has eaten 1 box) till now,so $A$ will be eating candies in the 4th box.
Hence $A$ has eaten 4 boxes and $B$ has eaten 1 box.

Difficulty: HARD
Tags: Amortized analysis

Ad-hoc
Skill types: Amortized analysis

Starter code:

Solutions:
t = int(input())
while t:
	t -= 1
	n = int(input())
	arr = list(map(int, input().split()))
	x = int(input())
	if n == 1:
		print('1 0')
	else:
		currentIndexOfA = 0
		currentIndexOfB = n - 1
		carry = 0
		while currentIndexOfA + 1 < currentIndexOfB:
			if (arr[currentIndexOfA] + carry) // x < arr[currentIndexOfB]:
				arr[currentIndexOfB] -= (arr[currentIndexOfA] + carry) // x
				carry = (arr[currentIndexOfA] + carry) % x
				arr[currentIndexOfA] = 0
				currentIndexOfA += 1
			elif (arr[currentIndexOfA] + carry) // x > arr[currentIndexOfB]:
				s = (arr[currentIndexOfA] + carry) // x
				carry = (arr[currentIndexOfA] + carry) % x
				flag = False
				while s > 0:
					if s >= arr[currentIndexOfB]:
						s -= arr[currentIndexOfB]
						arr[currentIndexOfB] = 0
						currentIndexOfB -= 1
					else:
						arr[currentIndexOfB] -= s
						s = 0
					if currentIndexOfB - 1 == currentIndexOfA:
						flag = True
						break
				if flag:
					break
				currentIndexOfA += 1
			elif (arr[currentIndexOfA] + carry) // x == arr[currentIndexOfB]:
				carry = (arr[currentIndexOfA] + carry) % x
				arr[currentIndexOfA] = 0
				arr[currentIndexOfB] = 0
				currentIndexOfA += 1
				currentIndexOfB -= 1
			if currentIndexOfB == currentIndexOfA and carry == 0:
				if n - 1 - currentIndexOfA == currentIndexOfA or currentIndexOfA > n - 1 - currentIndexOfA:
					currentIndexOfB += 1
				else:
					currentIndexOfA -= 1
				break
			elif currentIndexOfA == currentIndexOfB:
				currentIndexOfA -= 1
				break
		print(f'{currentIndexOfA + 1} {n - currentIndexOfB}')


def candy(n, C, x):
	if n == 1:
		return (1, 0)
	(b1, b2) = (1, 1)
	(a, b) = (C[0], C[-1])
	while b1 + b2 < n:
		if a < b * x:
			a += C[b1]
			b1 += 1
		elif a > b * x:
			b2 += 1
			b += C[n - b2]
		elif b1 >= b2:
			a += C[b1]
			b1 += 1
		else:
			b2 += 1
			b += C[b2]
	return (b1, b2)
T = int(input())
for i in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	x = int(input())
	ans = candy(N, A, x)
	print(ans[0], ans[1])


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	x = int(input())
	cnt_arr = [0] * n
	i = 0
	j = n - 1
	box_a = 1
	box_b = 1
	y = x * arr[j]
	z = arr[i]
	while i != j and box_a + box_b < n:
		while y != 0:
			if y > z:
				y -= z
				i += 1
				box_a += 1
				z = arr[i]
			elif y == z:
				i += 1
				j -= 1
				if i != j:
					box_a += 1
					box_b += 1
					y = x * arr[j]
					z = arr[i]
				else:
					if box_a >= box_b:
						box_a += 1
					else:
						box_b += 1
					break
			else:
				z -= y
				j -= 1
				if i != j:
					box_b += 1
					y = x * arr[j]
					break
				else:
					break
			if i == j or box_a + box_b == n:
				break
	print(box_a, box_b)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(y) for y in input().split()]
	x = int(input())
	ca = [0] * n
	cb = [0] * n
	(psum, psumr, aeats, beats) = (0, 0, 0, 0)
	tie = False
	for i in range(n):
		psum = psum + a[i]
		psumr = psumr + a[n - i - 1]
		if i < n - 1:
			ca[i + 1] = psum / x
			cb[n - i - 2] = psumr
	for i in range(n):
		if cb[i] > ca[i]:
			aeats += 1
		elif cb[i] < ca[i]:
			beats += 1
		else:
			tie = True
	if tie:
		if beats > aeats:
			beats += 1
		else:
			aeats += 1
	print('{} {}'.format(aeats, beats))


t = int(input())
mod = pow(10, 9) + 7
for y in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	x = int(input())
	ca = 0
	cb = 0
	aflag = bflag = 0
	while ca < n - 1 - cb:
		t = a[ca] // x
		if a[ca] % x != 0:
			aflag = 1
		else:
			aflag = 0
		a[ca + 1] += a[ca] % x
		ca += 1
		s = a[n - 1 - cb] - t
		if s == 0:
			cb += 1
			bflag = 0
		elif s > 0:
			a[n - 1 - cb] -= t
			bflag = 1
		else:
			bflag = 1
			while s < 0 and ca < n - 1 - cb:
				cb += 1
				prev = s
				s = s + a[n - 1 - cb]
				a[n - 1 - cb] += prev
			if s == 0:
				cb += 1
				bflag = 0
	if ca + cb == n - 1:
		if cb > ca or aflag == 1 or bflag == 1:
			cb += 1
		else:
			ca += 1
	print(ca, cb)


import math
import bisect
t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	candies = [int(x) for x in input().split()]
	rate = int(input())
	a_start_time = [0 for x in range(n)]
	b_start_time = [0 for x in range(n)]
	a_start_time[0] = 0
	b_start_time[-1] = 0
	sum_candies = candies[0]
	for i in range(1, n):
		a_start_time[i] = sum_candies / rate
		sum_candies += candies[i]
	for i in range(n - 2, -1, -1):
		b_start_time[i] = b_start_time[i + 1] + candies[i + 1]
	a_count = 0
	b_count = 0
	if n == 1:
		print(1, 0)
		continue
	elif n == 2:
		print(1, 1)
		continue
	for i in range(n):
		if a_start_time[i] < b_start_time[i]:
			a_count += 1
		elif b_start_time[i] == a_start_time[i]:
			if a_count >= n - a_count - 1:
				a_count += 1
	print(a_count, n - a_count)


T = int(input())
for _ in range(T):
	N = int(input())
	l = list(map(int, input().split()))
	X = int(input())
	A = l[:]
	B = l[:]
	for i in range(1, N):
		A[i] = A[i - 1] + A[i]
		B[N - 1 - i] = B[N - 1 - i] + B[N - i]
	i = 0
	j = N - 1
	while i < j and j - i > 1:
		if A[i] / X < B[j]:
			i += 1
		elif A[i] / X > B[j]:
			j -= 1
		elif i + 1 < N - j:
			j -= 1
		else:
			i += 1
	print(i + 1, N - j)


t = int(input())
while t != 0:
	n = int(input())
	cost = [int(_) for _ in input().split()]
	x = int(input())
	boxes = [0, 0]
	j = 0
	for i in range(n - 1, -1, -1):
		if i == j:
			c = cost[j]
			if c != 0:
				if boxes[0] >= boxes[1]:
					boxes[0] += 1
				else:
					boxes[1] += 1
			break
		c = cost[i]
		eff = c * x
		cost[i] -= c
		boxes[1] += 1
		while eff != 0 and i != j:
			if eff >= cost[j]:
				eff -= cost[j]
				cost[j] = 0
				j += 1
				boxes[0] += 1
			else:
				cost[j] -= eff
				eff = 0
				if j == i - 1:
					boxes[0] += 1
					j = i
		if i == j:
			break
	print(boxes[0], boxes[1])
	t -= 1


for _ in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	x = int(input())
	i = 0
	j = n - 1
	a = 0
	b = 0
	f = 0
	while 1:
		temp = l[j] * x
		while i < j and temp:
			f = 0
			temp2 = min(l[i], temp)
			l[i] -= temp2
			temp -= temp2
			if not l[i]:
				f = 1
				a += 1
				i += 1
		if i == j:
			b += 1
			break
		j -= 1
		b += 1
		if i == j:
			if f:
				if b > a:
					b += 1
				else:
					a += 1
			else:
				a += 1
			break
	print(a, b)


for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	x = int(input())
	(A, B) = (0, 0)
	(i, j) = (0, n - 1)
	while i < j:
		B += 1
		chocsA = x * lst[j]
		while i < j and chocsA >= lst[i]:
			chocsA -= lst[i]
			i += 1
			A += 1
		lst[i] -= chocsA
		j -= 1
	if i == j:
		if chocsA > 0:
			A += 1
		elif A >= B:
			A += 1
		else:
			B += 1
	print(A, B)


t = int(input())
for tt in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	x = int(input())
	sum = []
	count = 0
	low = -1
	high = n
	if n == 1:
		print('1 0')
		continue
	counta = 0
	countb = 0
	timea = 0
	timeb = 0
	while 1:
		if low >= high - 1:
			break
		if timea < timeb:
			low += 1
			timea += s[low] / x
			counta += 1
		elif timea > timeb:
			high -= 1
			timeb += s[high]
			countb += 1
		elif counta >= countb:
			low += 1
			timea += s[low] / x
			counta += 1
		else:
			high -= 1
			timeb += s[high]
			countb += 1
	print(counta, countb)


import sys
from heapq import heappop
from heapq import heappush
from heapq import heapify
from bisect import insort
from bisect import bisect_right
from bisect import bisect_left
from sys import stdin, stdout
from collections import defaultdict
inp = lambda : int(stdin.readline())
sip = lambda : input()
mulip = lambda : map(int, input().split())
lst = lambda : list(map(int, stdin.readline().split()))
slst = lambda : list(sip())
arr2d = lambda x: [[int(j) for j in input().split()] for i in range(x)]
odds = lambda l: len(list(filter(lambda x: x % 2 != 0, l)))
evens = lambda l: len(list(filter(lambda x: x % 2 == 0, l)))
mod = pow(10, 9) + 7
for _ in range(inp()):
	n = inp()
	B = lst()
	x = inp()
	if n == 1:
		print(1, 0)
	else:
		A = []
		for i in range(n):
			A.append(B[i] / x)
		(a, b) = (0, n - 1)
		(s1, s2) = (0, B[n - 1])
		while b > a:
			if s1 > s2:
				s2 += B[b - 1]
				b -= 1
			elif s1 == s2:
				if a >= n - b:
					s1 += A[a]
					a += 1
				else:
					s2 += B[b - 1]
					b -= 1
			else:
				s1 += A[a]
				a += 1
		print(a, n - b)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	x = int(input())
	b = x * l[n - 1]
	a = l[0]
	(boxa, boxb) = (1, 1)
	(i, j) = (1, n - 2)
	if n == 1:
		print(1, 0)
	elif n == 2:
		print(1, 1)
	else:
		while i < j:
			while a <= b and i < j:
				boxa += 1
				a += l[i]
				i += 1
			else:
				if i < j:
					boxb += 1
					b += l[j] * x
					j -= 1
		if a < b:
			boxa += 1
		elif b < a:
			boxb += 1
		elif boxa < boxb:
			boxb += 1
		else:
			boxa += 1
		print(boxa, boxb)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	x = int(input())
	j = n - 1
	i = 0
	a = 0
	b = 0
	remain = 0
	while True:
		if i > j:
			break
		if i == j:
			if remain:
				a += 1
			elif b > a:
				b += 1
			else:
				a += 1
			break
		b += 1
		d = x * l[j] + remain
		while i < j:
			d -= l[i]
			if d == 0:
				remain = 0
				a += 1
				i += 1
				break
			if d < 0:
				remain = d + l[i]
				break
			a += 1
			i += 1
		j -= 1
	print(a, b)


for _ in range(int(input())):
	n = int(input())
	c = [0] + list(map(int, input().split()))
	x = int(input())
	for i in range(1, n + 1):
		c[i] += c[i - 1]
	boxa = 0
	boxb = 0
	maxx = x * (c[n] / (x + 1))
	for i in range(1, len(c)):
		if c[i] > maxx:
			boxa = i - 1
			break
	if c[boxa] == x * (c[n] - c[boxa]):
		print('{} {}'.format(boxa, n - boxa))
	elif c[boxa] == x * (c[n] - c[boxa + 1]):
		if boxa < n - boxa - 1:
			print('{} {}'.format(boxa, n - boxa))
		else:
			print('{} {}'.format(boxa + 1, n - boxa - 1))
	elif c[boxa] > x * (c[n] - c[boxa + 1]):
		print('{} {}'.format(boxa, n - boxa))
	else:
		print('{} {}'.format(boxa + 1, n - boxa - 1))


import sys
ip = sys.stdin

def solve(C, n, x):
	if n == 1:
		return (1, 0)
	(b1, b2) = (1, 1)
	(a, b) = (C[0], C[-1])
	while b1 + b2 < n:
		if a < b * x:
			a += C[b1]
			b1 += 1
		elif a > b * x:
			b2 += 1
			b += C[n - b2]
		elif b1 >= b2:
			a += C[b1]
			b1 += 1
		else:
			b2 += 1
			b += C[b2]
	return (b1, b2)
t = int(ip.readline())
for _ in range(t):
	n = int(ip.readline())
	C = list(map(int, ip.readline().split()))
	x = int(ip.readline())
	ans = solve(C, n, x)
	print(*ans)


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = [int(x) for x in input().split()]
	tempa = a.copy()
	x = int(input())
	b = [k / x for k in a]
	tempb = b.copy()
	lhs = 0
	rhs = n - 1
	(cl, cr) = (0, 0)
	case = -1
	while cl + cr < n - 1:
		if b[lhs] < a[rhs]:
			a[rhs] -= b[lhs]
			cl += 1
			lhs += 1
			case = 0
		elif b[lhs] > a[rhs]:
			b[lhs] -= a[rhs]
			cr += 1
			rhs -= 1
			case = 1
		else:
			cr += 1
			rhs -= 1
			cl += 1
			lhs += 1
			case = 2
	if case == 2:
		if cl >= cr:
			cl += 1
		else:
			cr += 1
	elif case == 1:
		cl += 1
	else:
		cr += 1
	print(cl, end=' ')
	print(cr)


for _ in range(int(input())):
	N = int(input())
	candies = list(map(int, input().split()))
	x = int(input())
	sum = 0
	for a in range(N):
		sum += candies[a]
	lftSum = candies[0]
	rgtSum = sum - lftSum
	lftans = 1
	rgtans = N - 1
	for a in range(1, N):
		if rgtSum - candies[a] == lftSum / x:
			if lftans >= rgtans - 1:
				lftans += 1
				rgtans -= 1
				break
			else:
				break
		elif rgtSum - candies[a] < lftSum / x:
			break
		else:
			lftans += 1
			rgtans -= 1
		lftSum += candies[a]
		rgtSum -= candies[a]
	print(lftans, rgtans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	X = int(input())
	if n == 1:
		print(1, 0)
		continue
	(l, r) = (0, n - 1)
	(a, b) = (0, 0)
	(sumA, sumB) = (0, 0)
	while l < r:
		if sumA <= sumB * X:
			sumA += arr[l]
			l += 1
			a += 1
		else:
			sumB += arr[r]
			r -= 1
			b += 1
	if l == r:
		if sumA - sumB * X == 0:
			if a >= b:
				a += 1
			else:
				b += 1
		elif sumA - sumB * X < 0:
			a += 1
		else:
			b += 1
	print(a, b)


try:
	for i in range(int(input())):
		n = int(input())
		l = list(map(int, input().split()))
		x = int(input())
		i = 0
		j = n - 1
		bi = 0
		bj = 1
		count1 = l[j] * x
		while i < j:
			if count1 > 0 and i != j:
				if l[i] <= count1:
					count1 = count1 - l[i]
					i = i + 1
					bi = bi + 1
				else:
					l[i] = l[i] - count1
					count1 = 0
			if count1 <= 0:
				j = j - 1
				count1 = count1 + l[j] * x
				if i != j:
					bj = bj + 1
				elif bi > bj:
					bi = bi + 1
				elif bi < bj:
					bj = bj + 1
				else:
					bi = bi + 1
		print(bi, bj)
except:
	pass


for _ in range(int(input())):
	number = int(input())
	inA = list(map(int, input().split()))
	X = int(input())
	sum = 0
	for i in range(number):
		sum += inA[i]
	leftSum = inA[0]
	rightSum = sum - leftSum
	lAns = 1
	rAns = number - 1
	for i in range(1, number):
		if rightSum - inA[i] == leftSum / X:
			if lAns >= rAns - 1:
				lAns += 1
				rAns -= 1
				break
			else:
				break
		elif rightSum - inA[i] < leftSum / X:
			break
		else:
			lAns += 1
			rAns -= 1
		leftSum += inA[i]
		rightSum -= inA[i]
	print(lAns, rAns)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	x = int(input())
	if n == 1:
		print(1, 0)
		continue
	else:
		sum1 = sum(a)
		lim = x * int(sum1 / (x + 1))
		sumt = 0
		f = -1
		c1 = 0
		while lim > sumt:
			f += 1
			sumt += a[f]
			c1 += 1
		c1 = c1 - 1
		for i in range(f, n - 1):
			t1 = sum(a[:i]) / x
			t2 = sum(a[i + 1:])
			if t1 < t2:
				c1 += 1
			elif t1 == t2:
				if i >= n - i - 1:
					c1 += 1
				break
			else:
				break
		print(c1, n - c1)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	x = int(input())
	abox = 0
	bbox = 0
	i = 0
	j = n - 1
	while n > 0:
		if j != i:
			v = x * arr[j]
			n -= 1
			summ = 0
			for f in range(i, j):
				if summ + arr[f] <= v:
					summ += arr[f]
					abox += 1
					n -= 1
				else:
					arr[f] = summ + arr[f] - v
					i = f
					break
			bbox += 1
			j -= 1
		elif j == i:
			if abox >= bbox:
				abox += 1
				n -= 1
			else:
				bbox += 1
				n -= 1
	print(abox, bbox)


import math
import bisect

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

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

def inl():
	return list(map(int, input().split()))
MOD = 10 ** 9 + 7
INF = inf = 10 ** 18 + 5
for t in range(int(input())):
	n = inn()
	c = inl()
	x = inn()
	if n == 1:
		print(1, 0)
		continue
	elif n == 2:
		print(1, 1)
		continue
	pres = [0] * n
	pres[0] = c[0]
	for i in range(1, n):
		pres[i] = pres[i - 1] + c[i]
	ans = 1
	for i in range(1, n - 1):
		ta = pres[i - 1] / x
		tb = pres[n - 1] - pres[i]
		if ta < tb:
			ans += 1
		elif ta == tb and ans >= n - ans - 1:
			ans += 1
		else:
			break
	print(ans, n - ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	x = int(input())
	(left, right) = (0, n - 1)
	(c1, c2) = (0, 0)
	(b1, b2) = (0, 0)
	while left <= right:
		if c1 < x * c2:
			c1 += arr[left]
			left += 1
			b1 += 1
		elif c1 > x * c2:
			c2 += arr[right]
			right -= 1
			b2 += 1
		elif left != right:
			c1 += arr[left]
			left += 1
			b1 += 1
		elif b1 < b2:
			c2 += arr[right]
			right -= 1
			b2 += 1
		else:
			c1 += arr[left]
			left += 1
			b1 += 1
	print(b1, b2)


try:
	for _ in range(int(input())):
		n = int(input())
		arr = list(map(int, input().split()))
		x = int(input())
		left = 0
		right = n - 1
		count1 = count2 = 0
		sum1 = sum2 = 0
		while left <= right:
			if sum1 < x * sum2:
				sum1 = sum1 + arr[left]
				left += 1
				count1 += 1
			elif sum1 > x * sum2:
				sum2 = sum2 + arr[right]
				right -= 1
				count2 += 1
			elif left != right:
				sum1 = sum1 + arr[left]
				left += 1
				count1 += 1
			elif count1 < count2:
				sum2 = sum2 + arr[right]
				right -= 1
				count2 = count2 + 1
			else:
				sum1 = sum1 + arr[left]
				left += 1
				count1 += 1
		print(count1, count2)
except:
	pass


t = int(input())
for w in range(t):

	def myanswer(number, iter, j, ba, bb, my_array, y, z):
		while iter != j and ba + bb < number:
			while y != 0:
				if y > z:
					y -= z
					iter += 1
					ba += 1
					z = my_array[iter]
				elif y == z:
					iter += 1
					j -= 1
					if iter != j:
						ba += 1
						bb += 1
						y = x * my_array[j]
						z = my_array[iter]
					else:
						if ba >= bb:
							ba += 1
						else:
							bb += 1
						break
				else:
					z -= y
					j -= 1
					if iter != j:
						bb += 1
						y = x * my_array[j]
						break
					else:
						break
				if iter == j or ba + bb == number:
					break
		print(ba, bb)
	number = int(input())
	my_array = list(map(int, input().split()))
	x = int(input())
	c = [0] * number
	iter = 0
	j = number - 1
	ba = 1
	bb = 1
	y = x * my_array[j]
	z = my_array[iter]
	myanswer(number, iter, j, ba, bb, my_array, y, z)


import sys

def main():
	t = int(sys.stdin.readline())
	for _ in range(t):
		n = int(sys.stdin.readline())
		c = list(map(int, sys.stdin.readline().split()))
		x = int(sys.stdin.readline())
		if n == 1:
			print(1, 0)
			continue
		(e1, e2, b1, b2, i) = (c[0], c[n - 1], 1, 1, 1)
		while b1 + b2 < n:
			if e1 < x * e2:
				e1 += c[i]
				b1 += 1
				i += 1
			elif e1 > x * e2:
				b2 += 1
				e2 += c[n - b2]
			elif b1 >= b2:
				e1 += c[i]
				i += 1
				b1 += 1
			else:
				b2 += 1
				e2 += c[n - b2]
		print(b1, b2)
main()


for _ in range(int(input())):
	n = int(input())
	c = list(map(int, input().split()))
	(rsm, lsm) = (0, 0)
	x = int(input())
	k = 0
	a = [0 for i in range(n)]
	b = [0 for i in range(n)]
	a[0] = c[0]
	b[n - 1] = c[n - 1]
	for i in range(1, n):
		a[i] = c[i] + a[i - 1]
		b[n - 1 - i] = b[n - i] + c[n - 1 - i]
	(i, j) = (0, n - 1)
	for i in range(n):
		b[i] = b[i] * x
	(i, j) = (0, n - 1)
	while i != j:
		k = i
		while a[i] < b[j]:
			i += 1
			if i == j:
				i -= 1
				break
		if a[i] == b[j] and i + 1 >= n - j and (i + 1 < j):
			i += 1
		k = i
		if i == j:
			break
		j -= 1
	k += 1
	if n == 1:
		k = 1
	print(k, n - k)


def candies(n, x, boxes):
	B = n - 1
	A = 0
	Aeat = boxes[0]
	Beat = boxes[n - 1]
	while B - A > 1:
		para = Aeat - Beat * x
		if para == 0:
			if A + 1 >= n - B:
				A += 1
				Aeat += boxes[A]
			else:
				B -= 1
				Beat += boxes[B]
		elif para < 0:
			A += 1
			Aeat += boxes[A]
		else:
			B -= 1
			Beat += boxes[B]
	return str(A + 1) + ' ' + str(n - B)
t = int(input())
for z in range(t):
	n = int(input())
	boxes = [int(w) for w in input().split()]
	x = int(input())
	print(candies(n, x, boxes))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = int(input())
	s = 0
	for i in range(n):
		s += a[i]
	ans = []
	l = a[0]
	r = s - l
	l1 = 1
	r1 = n - 1
	for i in range(1, n):
		if r - a[i] == l / x:
			if l1 >= r1 - 1:
				l1 += 1
				r1 -= 1
				break
			else:
				break
		elif r - a[i] < l / x:
			break
		else:
			l1 += 1
			r1 -= 1
		l += a[i]
		r -= a[i]
	print(l1, r1)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	x = int(input())
	c1 = 1
	if n == 1:
		print(1, 0)
		continue
	else:
		for i in range(1, n - 1):
			t1 = sum(a[:i]) / x
			t2 = sum(a[i + 1:])
			if t1 < t2:
				c1 += 1
			elif t1 == t2:
				if i >= n - i - 1:
					c1 += 1
				break
			else:
				break
		print(c1, n - c1)


import math
t = int(input())
for q in range(t):
	n = int(input())
	c = list(map(int, input().split()))
	x = int(input())
	a = [0 for i in range(n)]
	b = [0 for i in range(n)]
	leftSum = [0 for i in range(n)]
	rightSum = [0 for i in range(n)]
	leftSum[0] = c[0]
	rightSum[-1] = c[-1]
	count = 0
	for i in range(1, n):
		leftSum[i] = leftSum[i - 1] + c[i]
	for i in range(n - 2, -1, -1):
		rightSum[i] = rightSum[i + 1] + c[i]
	for i in range(n):
		if i > 0:
			a = math.ceil((leftSum[i - 1] + 1) / x)
		else:
			a = 1
		if i < n - 1:
			b = rightSum[i + 1] + 1
		else:
			b = 1
		if a < b:
			count += 1
		elif a == b and i >= n - i - 1:
			count += 1
	print(count, n - count)


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		c = list(map(int, input().split()))
		x = int(input())
		if n == 1:
			print(1, 0)
			continue
		(e1, e2, b1, b2, i) = (c[0], c[n - 1], 1, 1, 1)
		while b1 + b2 < n:
			if e1 < x * e2:
				e1 += c[i]
				b1 += 1
				i += 1
			elif e1 > x * e2:
				b2 += 1
				e2 += c[n - b2]
			elif b1 >= b2:
				e1 += c[i]
				i += 1
				b1 += 1
			else:
				b2 += 1
				e2 += c[n - b2]
		print(b1, b2)
main()


t = int(input().strip())
for _ in range(t):
	n = int(input().strip())
	arr = list(map(int, input().strip().split()))
	x = int(input().strip())
	candies_left = []
	sm = 0
	for i in arr:
		sm += i
		candies_left.append(sm)
	candies_left.append(0)
	candies = 0
	ans = False
	for i in range(n - 1, 0, -1):
		if candies + x * arr[i] > candies_left[i - 2]:
			print(str(i) + ' ' + str(n - i))
			ans = True
			break
		elif candies + x * arr[i] == candies_left[i - 2]:
			if i - 1 >= n - i:
				print(str(i) + ' ' + str(n - i))
				ans = True
				break
			else:
				print(str(i - 1) + ' ' + str(n - i + 1))
				ans = True
				break
		else:
			candies += x * arr[i]
	if not ans:
		print(str(1) + ' ' + str(n - 1))


import sys
sys.setrecursionlimit(200000)

def processor(input_list, a, b, x):
	if a == b:
		number_of_boxes_eaten_by_a = a - 0
		number_of_boxes_eaten_by_b = len(input_list) - 1 - b
		if number_of_boxes_eaten_by_a >= number_of_boxes_eaten_by_b:
			return a
		else:
			return a - 1
	elif a + 1 == b:
		return a
	elif input_list[a] == input_list[b] * x:
		return processor(input_list, a + 1, b - 1, x)
	elif input_list[a] > input_list[b] * x:
		input_list[a] = input_list[a] - input_list[b] * x
		return processor(input_list, a, b - 1, x)
	else:
		input_list[b] = input_list[b] - input_list[a] / x
		return processor(input_list, a + 1, b, x)

def ans(input_list, x):
	pos_a = processor(input_list, 0, len(input_list) - 1, x) + 1
	return (pos_a, len(input_list) - pos_a)
for _ in range(int(input())):
	N = int(input())
	C = list(map(int, input().split()))
	X = int(input())
	for i in C:
		i *= X
	Ans = ans(C, X)
	print(*Ans, sep=' ')