
n = int(input())

while(n):
    n -= 1
    a, b, c = input().split()
    a, b, c = int(a), int(b), int(c)
    stones = 0

    while(b >= 1 and c >= 2):
        b -= 1
        c -= 2
        stones += 3
    while(b >= 2 and a >= 1):
        a -= 1
        b -= 2
        stones += 3


    print(stones)
