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