t=int(input())
while t!=0:
  a,b,c=input().split()
  a=int(a)
  b=int(b)
  c=int(c)
  sum=0;
  
  while b>=1 and c>=2:
    sum+=3
    b=b-1
    c=c-2
  while a>=1 and b>=2:
    sum+=3
    b=b-2
    a=a-1
  print(sum)
  t-=1
    
    

