q=int(input())
for i in range(q):
    k=0
    w=list(map(int,input().split()))
    if w[2]//2<=w[1]:
        k+=3*(w[2]//2)
        w[1]=w[1]-(w[2]//2)
    else:
        k+=3*w[1]
        w[1]=0
    if w[1]//2<=w[0]:
        k+=3*(w[1]//2)
    else:
        k+=3*w[0]
    print(k)