t = int(input())
for i in range(t):
    a, b, c = map(int, input().split())
    s = s1 = 0
    a1 = a
    b1 = b
    c1 = c
    while b >= 2 and a >= 1:
        b -= 2
        a -= 1
        s += 3
    while b >= 1 and c >= 2:
        c -= 2
        b -= 1
        s += 3

    while b1 >= 1 and c1 >= 2:
        c1 -= 2
        b1 -= 1
        s1 += 3

    while b1 >= 2 and a1 >= 1:
        b1 -= 2
        a1 -= 1
        s1 += 3
    print(max(s, s1))



