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