def xxx(x, y):
    z = y//2
    a = min(x, z)
    return a
x = int(input())
for i in range(x):
    a, b, c = [int(i) for i in input().split()]
    y = 0
    z = xxx(b, c)
    y += z*3
    z = xxx(a, b-z)
    y += z*3
    print(y)
    
