for i in range(int(input())):
    a,b,c=map(int,input().split())
    sum=0
    p=min(b,c)//2
    if p<=c:
        sum+=p+p*2
        b=max(0,b-p//2)
    p=min(a,b)//2
    if p*2<=b:
        sum+=p+p*2
    print(sum)