n=input()
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]
for _ in range(n):
    a,b,c=map(int,raw_input().split())
    ans=[0]
    print sol(a,b,c,0)
    
