t = int(input())
for i in range(t):
    a, b, c = map(int, input().split())
    x_max = min(a, b // 2)

    max_value = 0
    for x in range(x_max + 1):
        y = min(b - 2 * x, c // 2)
        sum_value = 3 * x + 3 * y
        max_value = max(max_value, sum_value)
    print(max_value)
