n = int(input())
for i in range(n):
    a, b , c = [int(i) for i in input().split()]
    cost = 0
    while( a >= 1 and b >=2) or (b >= 1 and c >= 2):
        if b > c and a >= 1:
            cost += 3
            b -= 2
            a -= 1
        else:
            cost += 3
            c -= 2
            b -= 1
    print(cost)