#include<stdio.h>
//三家人
int main()
{
int x, y, z, t;
double p, a;
scanf("%d", &t);
while(t--&&t<=20)
{
scanf("%d%d%d", &x, &y, &z);
p=(x+y)/3.0;
if((x-p)<0&&1<=x&& y<=10&&1<=z&&z<=1000)
printf("%d\n", 0);
else if((y-p)<0&&1<=x&& y<=10&&1<=z&&z<=1000)
printf("%d\n", z);
else
printf("%.0lf\n", z*(x-p)/(x+y-2*p));
}
return 0;
}
//三家人
int main()
{
int x, y, z, t;
double p, a;
scanf("%d", &t);
while(t--&&t<=20)
{
scanf("%d%d%d", &x, &y, &z);
p=(x+y)/3.0;
if((x-p)<0&&1<=x&& y<=10&&1<=z&&z<=1000)
printf("%d\n", 0);
else if((y-p)<0&&1<=x&& y<=10&&1<=z&&z<=1000)
printf("%d\n", z);
else
printf("%.0lf\n", z*(x-p)/(x+y-2*p));
}
return 0;
}