def scanf():
    _input = input().split(" ")
    res = []
    for elem in _input:
        res.append(int(elem))
    return res


for _ in range(int(input())):
    Stones = 0
    Vars = scanf()
    while Vars[1] > 0 and Vars[2] > 1:
        Stones += 3
        Vars[1] -= 1
        Vars[2] -= 2
    while Vars[0] > 0 and Vars[1] > 1:
        Stones += 3
        Vars[0] -= 1
        Vars[1] -= 2
    print(Stones)
