t=int(input())
for _ in range(t):
    a,b,c=map(int,input().split())
    p=min(a,b)
    d=0
    while(b>0 and c>=2):
        d+=3
        b-=1
        c-=2
    while(a>0 and b>=2):
        d+=3
        a-=1
        b-=2    
    print(d)    