for i in range(int(input())):
    a,b,c=map(int,input().split())
    ans=0
    if b*2<=c:
        ans=ans+3*b
        b=0
    else:
        ans=ans+(c//2)*3
        b=b-c//2
    
    if a*2<=b:
        ans=ans+3*a
    else:
        ans=ans+(b//2)*3
    print(ans)
