def mx(a,b):
    if(a>b):
        return a
    else:
        return b
for _ in range(int(input())):
    l=list(map(int,input().split()))
    count=0
    while (l[0]>0 and l[1]>1) or (l[1]>0 and l[2]>1):
        if(l[2]==mx(l[1],l[2])):
            l[2]-=2
            l[1]-=1
            count+=3
        else:
            l[1]-=2
            l[0]-=2
            count+=3
        print(count)