rr= lambda: input().strip()
rri= lambda: int(rr())
rrm= lambda: [int(x) for x in rr().split()]

def sol(a,b,c):
    res=0
    if c//2<b:
        res+=3*(c//2)
        b-=c//2
    else:
        return 3*b
    if b//2<a:
        res+=3*(b//2)
        return res
    else:
        res+=3*a
        return res

t=rri()
for _ in range(t):
    a,b,c=rrm()
    ans=sol(a,b,c)
    print(ans)