n = int(input())
for i in range(n):
    a, b, c = map(int, input().split())
    x = c//2
    if b<=x:
        print(b*3)
    else:
        y = (b-x)//2
        if a<=y:
            print(a*3 + x*3)
        else:
            print(y*3 + x*3)