AC CODE:
#include <iostream>
using namespace std;
int main()
{
int T;
cin>>T;
while(T--)
{
int n300,n100,n50;
cin>>n300>>n100>>n50;
int n=n300+n100+n50;
int i;
int k1=n300;
int k2=n100;
int k3=n50;
int min=0;
int max=0;
for(i=0; i<n; i++)
{
if(k1>0)
{
k1--;
min+=((i<<1)+1)*300;
continue;
}
if(k2)
{
k2--;
min+=((i<<1)+1)*100;
continue;
}
if(k3)
{
k3--;
min+=((i<<1)+1)*50;
continue;
}
}
k1=n50;
k2=n100;
k3=n300;
for(i=0;i<n; i++)
{
if(k1>0)
{
k1--;
max+=((i<<1)+1)*50;
continue;
}
if(k2>0)
{
k2--;
max+=((i<<1)+1)*100;
continue;
}
if(k3>0)
{
k3--;
max+=((i<<1)+1)*300;
continue;
}
}
cout<<min<<" "<<max<<endl;
}
return 0;
}