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