q=int(input())
for i in range(q):
    a,b,c=map(int,input().split())
    count=0
    if(b>=c//2):
        count+=3*(c//2)
        b=b-(c//2)
    else:
        count+=3*b
        b=0
    
    if(a>=b//2):
        count+=3*(b//2)
        a=a-(b//2)
    else:
        count+=3*a
        a=0
    print(count)