for _ in range(int(input())):
    a,b,c=input().split()
    a,b,c=int(a),int(b),int(c)
    count=0
    if b==0:
        print(0)
    else:
        k1=c//2
        count+=3*min(k1,b)
        b-=count//3
        if b>1:
            k2=b//2
            count+=3*min(k2,a)
        print(count)