t = int(input())

for _ in range(t):
    ans = 0
    ai, bi, ci = map(int, input().split())
    
    for x in range(101):
        for y in range(101):
            if ai >= x and bi >= 2*x+y and ci >= 2*y:
                ans = max(ans, 3*x+3*y)

    print(ans)