#include <stdio.h>
#include<math.h>
int main(void) {
int T,N;
int S,P,V;
int max = 0;
int temp;
scanf("%d",&T);
for(int i = 0;i<T;i++) {
max = 0;
scanf("%d",&N);
for(int j = 0;j<N;j++) {
scanf("%d %d %d",&S,&P,&V);
if(S>=P)
temp = 0;
else if(P%(S+1) != 0)
temp = floor((float)P/(S+1))*V;
else
temp = (V*P)/(1+S);
if(temp>max)
max = temp;
}
printf("%d\n",max);
}
return 0;
}
//please help in understanding why s+1 i think it should be replaced by s
problem link given in title and solution is submitted one it it is from successful answers