t=int(input())
while t:
    t-=1
    ans=0
    x,y,z=[int(x) for x in input().split()]
    temp=z//2
    temp=min(y,temp)
    ans=3*temp
    y-=temp
    temp=y//2
    temp=min(temp,x)
    ans=ans+3*temp
    print(ans)