n = int(input())
for i in range(n):
    sum = 0
    a, b, c = map(int, input().split())
    b_needed = c // 2
    while (b > b_needed and a > 0):
        sum += 2 + 1
        b -= 2
        a -= 1
    while (b > 0 and c > 1):
        sum += 2 + 1
        b -= 1
        c -= 2
    print(sum)