t = int(input())
for i in range(t):
    a, b, c = [int(i) for i in input().split()]
    s = 0
    while b >= 2 and a >= 1 or b > 0 and c >= 2:
        if c >= 2:
            c -= 2
            b -= 1
            s += 3
        elif a >= 1 and b >= 2:
            a -= 1
            b -= 2
            s += 3
    print(s)
