

length=int(input())



for i in range(0, length): 
    stones=0
    splice = input().split(" ");
    
    a=int(splice[0])
    b=int(splice[1])
    c=int(splice[2])

    aa=min(b,(int)(c/2))
    #print(aa)
    b -= aa
    c -= aa * 2
    stones+= aa * 3

    aa=min(a,(int)(b/2))
    stones+= aa * 3
    print(stones)

    #print(str(b/2))

    