for  _ in [0]*int(input()):
    a,b,c=map(int,input().split())
    d=0
    while b:
        if c>1:
            d+=3
            b-=1
            c-=2
        elif a and b>=2:
            d+=3
            a-=1
            b-=2
        else:
            break
    print(d)