t=int(input())
while(t>0):
    x,y,z=map(int,input().split())
    while(1):
        if z%2==0 and z//2<=y:
            B=z//2
            J=z+B
            break
        elif z<y:
            Y=0
            J=Y
            break
        else:
            z-=1
    y=y-B
    while(1):
        if y%2==0 and y//2<=x:
            B=y//2
            I=y+B
            break
        elif y<x:
            Y=0
            J=Y
            break
        else:
            y-=1
    U=I+J
    print(U)
    t-=1