#include <iostream>
using namespace std;
double g,b;
int a,s,t, n;
int main() {
cin >> t;
for(int i = 0; i<t; i++)
{
s = 0;
g = 0;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> a >> b;
s += a;
g += a * b;
}
printf("%d %.1f\n", s, g / s);
}
}