n=int(input())
for i in range(n):
    x,y,z=map(int,input().split())
    if y<z//2:
        print(3*y)
    else:
        y=y-z//2
        if x>y//2:
            print(3*(z//2+y//2))
        else:
            print(3*(z//2+x))