t = int(input())
for z in range(t):
    a,b,c=map(int, input().split())
    q = 0
    while c > 1 and b > 0:
        b-=1
        c-=2
        q+=3
    while b > 1 and a > 0:
        a-=1
        b-=2
        q+=3
    print(q)