t=int(input())

def ans(a,b,c):
    tot=a+b+c
    while b > 0 and c > 1:
        b-=1
        c-=2
    while b > 1 and a > 0:
        b-=2
        a-=1
    return tot-a-b-c
l=[]
for i in range(t):
    a,b,c = map(int, input().split(" "))
    l.append(ans(a,b,c))
print("\n".join(str(k) for k in l))