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