t = int(input())
for i in range(t):
    a,b,c = map(int,input().split())
    if a == 0 or b == 0 or c == 0:
        print(0)
    else:
        if c%2 == 0:
            c = c
        else:
            c = c - 1
        p = 0

        if c/2 == b:
            print(int(b + c))

        elif c/2 < b:
            p = c/2 + c
            b = b - c/2
            if b < 2:
                print(int(p))
            else:
                print(int(p + b + b/2))

        elif c/2 > b:
            print(int(b + b * 2))