for _ in range(int(input())):
    s=0
    l=list(map(int,input().split()))
    while l[1]<int(l[2]/2):
        l[2]-=2
    s=int(l[2]/2)*3
    l[1]=l[1]-int(l[2]/2)
    while l[0]<int(l[1]/2):
        l[1]-=2
    s+=int(l[1]/2)*3
    print(int(s))
