
x = int(input())
ans = []
for i in range(x):
    su = 0
    y = list((map(int, input().split())))
    if y[1] == 0:
        ans.append(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
    ans.append(((min(y[0], y[1])*3)+su))

for i in ans:
    print(i)

