### A. Stones

for i in range(int(input())):
    a,b,c=map(int, input().split())
    r=c//2
    total=0
    if r >= b:
        total = total + b + (b*2)
        b=0
    elif r<b:
        total = total + r + (r*2)
        b = b-r
    t = b//2
    total = total + (2 * min(a,t)) + min(a,t) 
    print(total)
        