for _ in range(int(input())):

    a,b,c=map(int,input().split())
    if b==0:
        print(0)
    elif b==1:
        if c>=2:
            print(3)
        else:
            print(0)
    else:
        k=min(b,c//2)
        b-=k
        k+=min(a,b//2)
        print(3*k)
