n = int(input())

for _ in range(n):
    tot =0
    x = list(map(int,input().split()))
    while (x[2]>=2 and x[1]>=1):
        x[2]-=2
        x[1]-=1
        tot+=3
        # print(x)
    while(x[0]>=1 and x[1]>=2):
        x[0]-=1
        x[1]-=2
        tot+=3
    print(tot)