t=int(input())
for _ in range(t):
    a,b,c=map(int,input().split())
    if(a==c):
        print(b*2)
    else:
        s=0
        p=c//2
        if(b>=p):
            s=s+(3*p)
            b=b-p
        q=b//2
        if(a>=q):
            s=s+(3*q)
        print(s)