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