t=int(input())
for _ in range(t):
       a,b,c=map(int,input().split())
       if 2*b<=c:
              print(3*b)
       else:
              c=c//2
              if (b-c)//2 <=a:
                  print((3*c)+((b-c)//2)*3)

              else:
                  print((3*c)+(a*3))
                
