for _ in range(int(input())):
    a,b,c=map(int,input().split())
    k=min(b//1,c//2)
    s=0
    if k!=0:
        s=k*3
        b=b-k
        c=c-k*2
    m=min(a//1,b//2)
    s=s+m*3
    print(s)
    