t = int(input())
for i in range(t):
    a, b, c = map(int, input().split())
    ans = 0
    for x in range(100):
        for y in range(100):
            if x <= a and x * 2 <= b and y <= b - 2 * x and 2 * y <= c:
                ans = max(ans, 3 * (x + y))
    
    print(ans)
        
