def mn(a,b):
    if(a<b):
        return a
    else:
        return b
t=int(input())
if(t>=1 and t<=100):
    for _ in range(t):
        l=list(map(int,input().split()))
        if min(l)>=0 and max(l)<=100:
            count=0
            count+=3*mn(l[2]//2,l[1])
            count+=3*mn((l[1]-count//3)//2,l[0])
            print(count)
