def check(a,b):
    if( b>=2 and a>=1):
        
        b=b-2
        a=a-1
        
        return 3+check(a,b)
    else:
        return 0
n=int(input())
result=0
for i in range(n):
    a,b,c=map(int,input().split())
    if(b==0):
        print(0)
    elif(a==0 and c==0 ):
        print(0)
    else:
        result=result+check(b,c)
        rb=b-(int(check(b,c)/3))
        result=result+check(a,rb)
        print(result)
        result=0


