t=int(input())
while(t):
    t=t-1
    ar=list(map(int,input().split()))
    a=ar[0]
    b=ar[1]
    c=ar[2]
    s=0
    while b>=1 and c>=2:
        s=s+3
        b=b-1
        c=c-2
    while a>=1 and b>=2:
        s=s+3
        a=a-1
        b=b-2
    print(s)


