for t in range(int(input())):
    l=list(map(int,input().split()))
    c=0
    if l[1]==0:
         print(0)
    else:
        while l[1]>0 and l[2]>=2:
            l[2] = l[2] - 2
            l[1] = l[1] - 1
            c+=3
        while l[1]>=2 and l[0]>0:
            l[1]=l[1]-2
            l[0]=l[0]-1
            c+=3
        print(c)