def numOfStones(a,b,c):
    stones = 0
    while(b>=1 and c>=2):
        stones+=3
        b-=1
        c-=2
    while(a>=1 and b>=2):
        stones+=3
        a-=1
        b-=2
    return stones
t = int(input())
for i in range(t):
    a, b, c = input().split()
    a = int(a)
    b = int(b)
    c = int(c)
    stones = numOfStones(a,b,c)
    print(stones)
