t=int(input())
for w in range(t):
    l=[int(i) for i in input().split()]
    c=0
    while(l[1]>=1 and l[2]>=2):
        c+=3
        l[1]-=1
        l[2]-=2
    while(l[1]>=2 and l[0]>=1):
        c+=3
        l[1]-=2
        l[0]-=1
    print(c)