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