for _ in range(input()):
    a,b,c=map(int, raw_input().split(" "))
    c_inter = int(c/2)
    b_inter = int(b/2)
    if b==0 or (a*b==0 and b*c==0 and c*a==0):
        print(0)
    elif a==0:
        print(c_inter + c_inter*2 if c_inter <= b else b + b*2)
    elif c==0:
        print(b_inter + b_inter*2 if b_inter <= a else a + a*2)
    else:
        if c_inter >= b:
            print(b + b*2)
        else:
            b_temp = (b-c_inter)/2
            if b_temp <= a:
                print(c_inter + c_inter*2 + (b_temp + b_temp*2))
            else:
                print(c_inter + c_inter*2 + (a + a*2))

        
