t = int(input())
for i in range(t):
    a, b, c = map(int, input().split())
    d = b
    while b * 2 > c:
        b -= 1
    d = d - b
    while a * 2 > d:
        a -= 1
    print((a + b) * 3)
    
