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