t = int(input())
for tc in range(t):
    a,b,c = map(int,input().split())
    max1 = 0
    max2 = 0
    a2,b2,c2 = a,b,c
    while a>0 and b>1:
        a-=1
        b-=2
        max1+=3
    while b>0 and c>1:
        b-=1
        c-=2
        max1+=3
    while b2>0 and c2>1:
        b2-=1
        c2-=2
        max2+=3
    while a2>0 and b2>1:
        a2-=1
        b2-=2
        max2+=3
    print(max(max1,max2))
