
x = int(input())

for i in range(x):
    su = 0
    y = list((map(int, input().split())))
    if i == 0:
        print("\n")
    if y[1] == 0:
        print("0")
        continue
    if y[2] > 0:
        y[2] = y[2]//2
        su = min(y[1], y[2])*3
        y[1] = y[1]-(su//3)
    y[1] = y[1]//2
    print((min(y[0], y[1])*3)+su)



