for i in range(int(input())):
    q=0
    x, y, z = [int(i) for i in input().split()]
    if z>=2:
        if z//2>=y:
            q+=3*y
            y=0
            z=0
        else:
            q+=3*(z//2)
            y-=z//2
            z = 0
    if y>=2 and x>=1:
        if y//2>=x:
            q+=3*x
        else:
            q+=3*(y//2)
    print(q)
