using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Baekjoon
{
class Program
{
static void Main(string[] args)
{
int t = int.Parse(Console.ReadLine());
for (int i=0; i<t; i++)
{
int c = 0;
float g = 0;
int n = int.Parse(Console.ReadLine());
for (int j=0; j<n; j++)
{
string[] s = Console.ReadLine().Split();
c += int.Parse(s[0]);
g += int.Parse(s[0]) * float.Parse(s[1]);
}
Console.WriteLine($"{c} {Math.Round(g/c, 1)}");
}
}
}
}