def sol(a,b,c,s):
    if a>0 and b>1:
        sol(a-1,b-2,c,s+3)
    if b>0 and c>1:
        sol(a,b-1,c-2,s+3)
    ans[0]=max(ans[0],s)
    return ans[0]
ans=[0]
#print sol(9,7,13,0)
def ax(a,b,c):
    s=0
    t=min(b/2,a)
    s+=t*3
    a-=t
    b-=2*t
    t=min(c/2,b)
    s+=t*3
    b-=t
    c-=2*t
    return s
def bx(a,b,c):
    s=0
    t=min(c/2,b)
    s+=t*3
    b-=t
    c-=2*t
    t=min(b/2,a)
    s+=t*3
    a-=t
    b-=2*t
    return s
for _ in range(input()):
    a,b,c=map(int,raw_input().split())
    print max(ax(a,b,c),bx(a,b,c))
