t=int(input())
m1=[0]*t
m2=[0]*t
m3=[0]*t
a=[0]*t
for i in range(t):
  m1[i],m2[i],m3[i]=map(int,input().split())
for i in range(t):
  while m3[i]>=2 and m2[i]>=1: a[i]+=3; m3[i]-=2; m2[i]-=1;
  while m2[i]>=2 and m1[i]>=1: a[i]+=3; m2[i]-=2; m1[i]-=1;
for x in a:print(x)