q=int(input())
for _ in range(q):
    a, b, c =map(int, input().split())
    bb=b
    ans=0
    kc=c//2
    if kc>b: kc=b
    b-=kc
    ans+=kc 
    ans+=(kc*2)
    if bb!=b and b%2==1 and a!=0: ans-=3; b+=1
    kb=b//2
    if kb>a: kb=a
    ans+=kb
    ans+=(kb*2)
    print(ans)