#include <iostream>
#include <vector>
usingnamespace std;
int main()
{
double k , sum = 0;
vector < int > s;
int ar[1000][30];
int a,b,i,c = 0;
cin >> a;
while ( a > c )
{
cin >> b;
for (int j = 0; j < b; j++)
{
for (i = 0; i < 3; i++)
{
cin >> ar[j][i];
}
k = ar[j][0] / ar[j][1];// k is not giving deciml value
k = k * ar[j][2] * ar[j][1];
cout << k << endl;
sum = sum + k;
}
s.push_back(sum);
c++;
}
for (i = 0; i < a; i++)
{
cout << s[i] << endl;
}
}