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