n=int(input())
for i in range(0,n):
    k=0
    j=0
    x,y,z=[int(a) for a in input().split()]
    while x>=1 and y>=2:
        k=k+3
        x=x-1
        y=y-2
        break
    while y>=1 and z>=2:
        j=j+3
        y=y-1
        z=z-2
    print(j+k)