for _ in range(int(input())):
    a,b,c = map(int,input().split())
    ans=0
    while b>0:
        if b>=1 and c>=2:
            c-=2
            b-=1
            ans+=3
            #print('if')
        elif b>=2 and a>=1:
            ans+=3
            b-=2
            a-=1
            #print('elif')
        else:
            break
        #print(ans)
    print(ans)
        