t=int(input())

for k in range(t):
    a,b,c = map(int, input().split())
    ti=t
    result=0
    while True:
        if c>=2 and b>=1:
            result+=3
            c-=2
            b-=1
        elif b>=2 and a>=1:
            result += 3
            b -= 2
            a -= 1
        else:
            break
    print(result)