def Stones_2():
    T = int(input())
    for x in range(T):
        A, B, C = map(int, input().split())
        S = 0
        while (B > 0 and C > 1):
            B -= 1
            C -= 2
            S += 3
        while (A > 0 and B > 1):
            A -= 1
            B -= 2
            S += 3
        print(S)

Stones_2()