def op1(stone,alice):
    stone[0]-=1
    stone[1]-=2
    alice+=3
    return stone,alice

def op2(stone,alice):
    stone[1]-=1
    stone[2]-=2
    alice+=3
    return stone,alice

for _ in range(int(input())):
    alice=0
    stones=list(map(int,input().split()))
    while(stones[1]>0 and stones[2]>1):
        stones,alice=op2(stones,alice)
    while(stones[0]>0 and stones[1]>1):
        stones,alice=op1(stones,alice)
    print(alice)