for _ in range(int(input())):
    l=list(map(int,input().split()))
    #l.sort()
    a,b,c=l

    s=0
    
    while b>0 and c>1:
        #print(b,c)
        s+=3
        b-=1
        c-=2
    while a>0 and b>1:
        s+=3
        a-=1
        b-=2
    print(s)
