#include<bits/stdc++.h>
using namespace std;
int maximum(int a, int b)
{
return (a>b) ? a : b;
}
struct restaurant
{
int shops;
int people;
int price;
};
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int test;
cin>>test;
while(test--)
{
int N;
cin>>N;
struct restaurant rest[N];
for(int i=0;i<N;i++)
{
cin>>rest[i].shops>>rest[i].people>>rest[i].price;
}
int arr[N];
int max=0;
for(int i=0;i<N;i++)
{
if((rest[i].people)%((rest[i].shops)+1)==0)
{
arr[i]=(rest[i].people)/((rest[i].shops)+1)*(rest[i].price);
max= maximum(arr[i],max);
}
else
{
arr[i]=(rest[i].people)/((rest[i].shops)+1)*(rest[i].price);
max=maximum(arr[i],max);
}
}
cout<<max<<"\n";
}
return 0;
}