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