num = int(input())

while(num):
    arr = list(map(int,input().split()))

    total=0
    while(arr[1]>=1 and arr[2] >=2):
        total+=3
        arr[1]=arr[1]-1
        arr[2]=arr[2]-2

    while(arr[0]>=1 and arr[1] >=2):
        total+=3
        arr[0]-=1
        arr[1]=arr[1]-2

    print(total)
    num-=1
