t = int(input())
#t = 1
for _ in range(t):
    a, b, c = map(int, input().split())

    summa = 0

    while 1:
        if b > c and a > 0 and b > 1:
            a -= 1
            b -= 2
            summa += 3
        elif (b <= c or a == 0) and b > 0 and c > 1:
            b -= 1
            c -= 2
            summa += 3
        else:
            print(summa)
            break
