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