def I(): return map(int, input().split())


for _ in range(int(input())):
    a, b, c = I()
    tot = 0
    while b > 0 and c > 1:
        c -= 2
        b -= 1
        tot += 3
    while a > 0 and b > 1:
        b -= 2
        a -= 1
        tot += 3
    print(tot)
