Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.

Chef and Chefu are working as gold miners. There are a total of $N$ gold mines, numbered $1$ through $N$. For each valid $i$, the $i$-th gold mine contains $G_{i}$ gold in total; if only Chef worked in it, it would take him $A_{i}$ days to completely mine it, while if only Chefu worked in it, it would take him $B_{i}$ days.

Each of our miners may only work in one mine at a time, but they may decide to start working in another mine at any time (even in the middle of some day), any number of times. They also choose the mines to work in independently from each other and they may work in the same mine at the same time. Mining gold is a continuous process, i.e. if a miner works for $t$ days (where $t$ is a real number) in a mine where this miner has mining speed $g$ gold per day, then he will mine $g \cdot t$ gold. Obviously, it is impossible to work in a mine after no gold remains in it. For example, if a gold mine contains $30$ gold and Chef needs $2$ days to completely mine it, but he spends $1$ day in it, then he will mine $15$ gold; if Chefu needs $1$ day to completely mine the same gold mine, and both Chef and Chefu start working in this mine at the same time, it will be empty after $2/3$ days ― Chefu will mine $20$ gold, while Chef will mine $10$ gold.

At each point of time, both Chef and Chefu know the gold mine in which the other miner is working. Each of them wants to gather the maximum amount of gold for himself. Find the amounts of gold the miners will have if they both act optimally.

------  Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first line of each test case contains a single integer $N$.
$N$ lines follow. For each valid $i$, the $i$-th of these lines contains three space-separated integers $G_{i}$, $A_{i}$ and $B_{i}$.

------  Output ------
For each test case, print a single line containing two space-separated real numbers ― the amount of gold mined by Chef and the amount of gold mined by Chefu. Your answer will be considered correct if the absolute or relative error of each amount of gold does not exceed $10^{-6}$.

------  Constraints ------
$1 ≤ T ≤ 1,000$
$1 ≤ N ≤ 10^{5}$
$1 ≤ G_{i} ≤ 10^{5}$ for each valid $i$
$1 ≤ A_{i} ≤ 10^{5}$ for each valid $i$
$1 ≤ B_{i} ≤ 10^{5}$ for each valid $i$
the sum of $N$ over all test cases does not exceed $10^{6}$

------  Subtasks ------
Subtask #1 (50 points): $N ≤ 2$

Subtask #2 (50 points): original constraints

----- Sample Input 1 ------ 
2

1

30 2 1

3

10 1 1

20 2 2

30 3 3
----- Sample Output 1 ------ 
10.00000 20.00000

30.00000 30.00000

Difficulty: HARD

Solutions:
a = int(input())
for i in range(a):
	b1 = 0
	c1 = 0
	n = int(input())
	for j in range(n):
		(g, b, c) = map(int, input().split())
		d = g / (b + c)
		b1 = b1 + d * c
		c1 = c1 + d * b
	print('%.5f' % b1, '%.5f' % c1)


T = int(input())
for i in range(T):
	(a1, b1) = (0, 0)
	for i in range(int(input())):
		(g, a, b) = map(int, input().split())
		p = g / (a + b)
		a1 += p * a
		b1 += p * b
	ans1 = '{0:.5f}'.format(a1)
	ans2 = '{0:.5f}'.format(b1)
	print(ans2, ans1)


for i in range(int(input())):
	n = int(input())
	l = 0
	m = 0
	s = 0
	for j in range(n):
		(g, a, b) = map(int, input().split())
		d = 0
		if a > b:
			l += g - max(a, b) / (a + b) * g
			m += max(a, b) / (a + b) * g
		elif b > a:
			l += max(a, b) / (a + b) * g
			m += g - max(a, b) / (a + b) * g
		else:
			l += max(a, b) / (a + b) * g
			m += max(a, b) / (a + b) * g
	print('{0:.5f}'.format(l), '{0:.5f}'.format(m))


t = int(input())
while t:
	n = int(input())
	(c1, c2) = (0, 0)
	while n:
		(g, a, b) = map(int, input().split())
		c1 += g * (a / (a + b))
		c2 += g * (b / (a + b))
		n -= 1
	c1 = '{0:.5f}'.format(c1)
	c2 = '{0:.5f}'.format(c2)
	print(c2, c1)
	t -= 1


t = int(input())
while t != 0:
	t = t - 1
	b = int(input())
	c = 0
	d = 0
	for i in range(0, b):
		(g, a, b) = map(int, input().split())
		c += g * a / (a + b)
		d += g * b / (a + b)
	print('%.5f' % d, '%.5f' % c)


for _ in range(int(input())):
	n = int(input())
	(ch, cf) = (0, 0)
	for i in range(n):
		(g, a, b) = list(map(int, input().split()))
		t = a + b
		ch += g * b / t
		cf += g * a / t
	ch = '%.5f' % round(ch, 5)
	cf = '%.5f' % round(cf, 5)
	print(ch, cf)


t = int(input())
while t:
	p = int(input())
	g1 = 0
	g2 = 0
	while p:
		(x, y, z) = list(map(int, input().split(' ')))
		g1 = x * (y / (y + z)) + g1
		g2 = x * (z / (y + z)) + g2
		p = p - 1
	print('%.5f' % g2, '%.5f' % g1)
	t = t - 1


t = int(input())
for _ in range(t):
	n = int(input())
	cg = 0
	cug = 0
	for i in range(n):
		(g, c, cu) = map(int, input().split())
		cg += g * (cu / (c + cu))
		cug += g * (c / (c + cu))
	print('{:.5f}'.format(cg), '{:.5f}'.format(cug), sep=' ')


t = int(input())
while t > 0:
	n = int(input())
	(chef, chefu) = (0, 0)
	for i in range(n):
		(g, a, b) = map(int, input().split())
		(a, b) = (g / a, g / b)
		chef += g * a / (a + b)
		chefu += g * b / (a + b)
	print('%.5f %.5f' % (chef, chefu))
	t -= 1


for t in range(int(input())):
	n = int(input())
	data = [[int(x) for x in input().split()] for _ in range(n)]
	(chef, chefu) = (0.0, 0.0)
	for ele in data:
		(g, a, b) = (ele[0], ele[0] / ele[1], ele[0] / ele[2])
		chef += g * a / (a + b)
		chefu += g * b / (a + b)
	print('%.5f %.5f' % (chef, chefu))


for _ in range(int(input())):
	n = int(input())
	chef = 0
	chefu = 0
	for i in range(n):
		(g, a, b) = [int(x) for x in input().split()]
		chef += g * (b / (a + b))
		chefu += g * (a / (a + b))
	print('%.5f %.5f' % (chef, chefu))


import sys

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

def fop(s):
	return sys.stdout.write(str(s) + '\n')

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

def flistintinp():
	return list(map(int, finp().split()))

def op(s):
	return s

def inp():
	return input()

def intop(s):
	return int(s)

def intinp():
	return int(input())

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

def listinp():
	return list(map(str, inp().split()))
import math
primelists = []
maxprecomprimeval = 100001
from math import ceil, sqrt
mysievelists = [i for i in range(maxprecomprimeval)]

def primeprecomputer():
	for i in range(2, math.ceil(math.sqrt(maxprecomprimeval))):
		if mysievelists[i] == i:
			for j in range(i * i, maxprecomprimeval, i):
				if mysievelists[j] == j:
					mysievelists[j] = i
	for i in range(2, maxprecomprimeval):
		if mysievelists[i] == i:
			primelists.append(mysievelists[i])
	return primelists
from bisect import bisect_right, bisect_left

def bisectright(lists, nbr):
	return bisect_right(lists, nbr)

def bisectleft(lists, nbr):
	return bisect_left(lists, nbr)
MOD = 100000007
mpflists = []

def mpf(n):
	k = 0
	primeprecomputer()
	while n != 1:
		print(mysievelists[n])
		mpflists.append(mysievelists[n])
		n //= mysievelists[n]
		k += 1
	return mpflists
for __ in range(intinp()):
	n = intinp()
	(chef, chefu) = (0, 0)
	for i in range(n):
		(g, a, b) = map(int, inp().split())
		c = g / (a + b)
		chef += c * a
		chefu += c * b
	print('%.5f' % chefu, '%.5f' % chef)


t = int(input())
for i in range(t):
	n = int(input())
	share_a = 0
	share_b = 0
	for j in range(n):
		(tot, a, b) = map(int, input().split())
		share_a += b / (b + a) * tot
		share_b += a / (b + a) * tot
	share_a = format(share_a, '.5f')
	share_b = format(share_b, '.5f')
	print(str(share_a) + ' ' + str(share_b))


for i in range(int(input())):
	n = int(input())
	c = ch = 0
	for i in range(n):
		a = list(map(int, input().split()))
		s = a[1] + a[2]
		c += a[1] * (a[0] / (a[2] + a[1]))
		ch += a[2] * (a[0] / (a[2] + a[1]))
	print('%.5f %.5f' % (ch, c))


class GOLD:

	def __init__(self, G, A, B):
		self.ga = G / A
		self.gb = G / B
		self.res = G / (self.ga + self.gb)

	def amgA(self):
		return self.ga * self.res

	def amgB(self):
		return self.gb * self.res
T = int(input())
for i in range(T):
	N = int(input())
	L = []
	for i in range(N):
		res = list(map(int, input().split()))
		L.append(res)
	sga = 0
	sgb = 0
	for i in range(N):
		amntofgold = GOLD(L[i][0], L[i][1], L[i][2])
		sga += amntofgold.amgA()
		sgb += amntofgold.amgB()
	print('{:.5f}'.format(sga), end=' ')
	print('{:.5f}'.format(sgb))


for _ in range(int(input())):
	N = int(input())
	chef = 0
	chefu = 0
	for i in range(0, N):
		(G, A, B) = map(int, input().split())
		chef += G * A / (A + B)
		chefu += G * B / (A + B)
	print('{0:.5f}'.format(chefu), '{0:.5f}'.format(chef))


for _ in range(int(input())):
	n = int(input())
	ans1 = 0
	ans2 = 0
	for i in range(n):
		(g, a, b) = map(int, input().split())
		ans1 += g * a / (a + b)
		ans2 += g * b / (a + b)
	print('{0:.5f}'.format(ans2), '{0:.5f}'.format(ans1))


try:
	t = int(input())
	for _ in range(t):
		n = int(input())
		ans_a = 0
		ans_b = 0
		for _ in range(n):
			(g, a, b) = map(int, input().split())
			ans_a += g * b / (a + b)
			ans_b += g * a / (a + b)
		print(f'{ans_a:.5f}', end=' ')
		print(f'{ans_b:.5f}')
except:
	pass


for _ in range(int(input())):
	n = int(input())
	(x, y) = (0, 0)
	for i in range(n):
		(g, a, b) = map(int, input().split())
		t = a + b
		t = g / t
		(x, y) = (x + b * t, y + a * t)
	print('{:.5f}'.format(x), '{:.5f}'.format(y))


for i in range(int(input())):
	A = 0
	B = 0
	for j in range(int(input())):
		x = input().split()
		for k in range(int(len(x))):
			x[k] = int(x[k])
		c = x[1] + x[2]
		d = x[0] / c
		A += float('%.9f' % d) * x[2]
		B += float('%.9f' % d) * x[1]
	H = ['%.5f' % A, '%.5f' % B]
	print(*H)


try:
	for _ in range(int(input())):
		n = int(input())
		x = y = 0
		while n:
			(m, a, b) = map(int, input().split())
			x = x + a * m / (a + b)
			y = y + b * m / (a + b)
			n = n - 1
		x = '{0:.5f}'.format(x)
		y = '{0:.5f}'.format(y)
		print(y, x)
except Exception as e:
	pass