t=int(input())
for i in range(t):
    a,b,c=map(int,input().split())
    n=min(a,b//2)
    s=n*3
    bn=b-n*2
    n=min(bn,c//2)
    s+=n*3
    n=min(b,c//2)
    sn=n*3
    bn=b-n
    n=min(a,bn//2)
    sn+=n*3
    print(max(n,sn))