for u in range(int(input())):
    x,y,z=map(int,input().split())
    c=0
    while(z>=2 and y>=1):
        y=y-1
        z=z-2
        c=c+3
    while(y>=2 and x>=1):
        y=y-2
        x=x-1
        c=c+3
    print(c)
