for _ in range (int(input())):
  a,b,c=map(int,input().split())
  count=0
  ans=0
  if b==0:
    print(0)
  else:
    while((a>=1 and b>=2) or (b>=1 and c>=2)):
      if b<=c:
        while (b>=1 and c>=2):
          ans+=3
          b-=1
          c-=2

      if count%2==0:
        if a>=1 and b>=2:
          ans+=3
          a-=1
          b-=2
      else:
        if b>=1 and c>=2:
          ans+=3
          b-=1
          c-=2
      count+=1
    print(ans)