if __name__ == '__main__':
    q = int(input())

    for t in range(q):
        a, b, c = [int(i) for i in input().split(" ")]

        stones = 0

        if b >= c // 2:
            b = b - c // 2
            stones += (c // 2) * 2 + c // 2
        else:
            stones += b + 2 * b
            b = 0

        if b > 1:
            if a >= b // 2:
                stones += (b // 2) * 2 + b // 2
            else:
                stones += a + 2 * a

        print(stones)
