t=int(input())
for i in range(0,t):
         a,b,c=list(map(int,input().split()))
         total=0
         while(1):
                  if(c>=2 and b>=1):
                           total+=3
                           c-=2
                           b-=1
                  elif(b>=2 and a>=1):
                           total+=3
                           b-=2
                           a-=1
                  else:
                           break
         print(total)
