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