
x=lambda: map(int,input().split())
n=int(input())

for __ in range(n):
    k=0
    a=list(x())
    while a[1]>0 and a[2]>1:
        a[1]-=1
        a[2]-=2
        k+=3
    while a[0]>0 and a[1]>1:
        a[0]-=1
        a[1]-=2
        k+=3
    
        
    print(k)

        