t= int(input())
for i in range(t):
    d=0
    a,b,c=map(int,input().split())
    f,s=True,True
    while s:
        if b>0 and c>1:
            d+=3
            b-=1
            c-=2
        else:
            s=False
    while f:
        if a>0 and b>1:
            d+=3
            a-=1
            b-=2
        else:
            f=False
    print(d)