t=int(input())
for _ in range(t):
    a,b,c=map(int,input().split())
    ans=0
    for i in range(0,100):
        for j in range(0,100):
            if i<=a and 2*i+j<=b and 2*j<=c:
                ans=max(ans,3*(i+j))
    print(ans)