n=int(input())
for i in range(n):
    s=0
    a,b,c=map(int,input().split())
    while b>0 and c>1:
        s+=3
        b-=1
        c-=2
    while a>0 and b>1:
        s+=3
        b-=2
        a-=1
    print(s)