t = int(input())
for i in range(t):
    count = 0
    L = list(map(int, input().split()))
    a = L[0]
    b = L[1]
    c = L[2]
    while b >= 1 and c >= 2:
        b = b - 1
        c = c - 2
        count = count + 3
    while a >= 1 and b >= 2:
        a = a - 1
        b = b - 2
        count = count + 3
    print(count)