q = int(input())
w = int(0)
for i in range(q):
    w = 0
    a, b, c = map(int, input().split())
    while b >= 1 and c >= 2:
        b -= 1
        c -= 2
        w += 3
    while  a >= 1 and b >= 2:
        a -= 1
        b -= 2
        w += 3
    print(w)