n=int(input())
c=0
for i in range(n):
    line=[int(x) for x in input().split(' ')]
    while (line[1] >= 1) and (line[2] >= 2):
        line[1]-=1
        line[2]-=2
        c+=3
    print(c+min(line[1]/2,line[0])*3)
    c=0
