t = int(input())

for _ in range(t):
    a, b, c = [int(x) for x in input().split()]

    total = 0
    c1 = min(b, c // 2)
    total += c1
    b -= c1
    c -= c1 * 2
    c2 = min(a, b // 2)
    total += c2

    print(total * 3)