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

    
