t=int(input())
for i in range(t):
  sum=0
  a=list(map(int,input().split()))
  while (a[1]>=1 and a[2]>=2):
    sum=sum+3
    a[1]=a[1]-1
    a[2]=a[2]-2
  while (a[0]>=1 and a[1]>=2):    
    sum=sum+3
    a[0]=a[0]-1
    a[1]=a[1]-2 
  print(sum)     