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