n = int(input())

while n != 0:
    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 a >= 1 and b >= 2:
        a -= 1
        b -= 2
        stones += 3

    print(stones)

    n -= 1
