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