read = lambda: [int(i) for i in input().split()]

t = int(input())
for _ in range(t):
    a, b, c, = read()
    
    k = min(a, b // 2)
    a -= k
    b -= 2 * k
    l = min(b, c // 2)
    ans1 = 3 * k + 3 * l
    a += k
    b += 2 * k
    k = min(b, c // 2)
    b -= k
    c -= 2 * k
    l = min(a, b // 2)
    ans2 = 3 * k + 3 * l
    print(max(ans1, ans2))
