test_cases = int(input())

for each_test_case in range(test_cases):
    a, b, c = map(int, input().split())
    times_c = c // 2
    scd_operation = min(b, times_c)
    b -= scd_operation
    times_b = b // 2
    first_operation = min(a, times_b)
    print((first_operation+scd_operation) * 3)
