nothing is printing in terminal please fix 
class Node:
    def __init__(self, val):
        self.val = val
        self.uid = None
        self.parent = None
        self.child = []
        self.isLocked = False
        self.lockedDescendantCount = 0  # Use 'descendant' consistently


class Tree:
    def __init__(self, m, n, name_list, queries):
        self.node_list = []
        self.node_map = {}

        for name in name_list:
            node = Node(name)
            self.node_list.append(node)
            self.node_map[name] = node

        # Build the tree
        for i in range(n):
            for j in range(m):
                child_index = m * i + j + 1
                if child_index < n:
                    self.node_list[i].child.append(self.node_list[child_index])
                    self.node_list[child_index].parent = self.node_list[i]

        self.root = self.node_list[0]
        self.processed_queries = []
        for query in queries:
            self.processed_queries.append(query.strip().split())

    def lock(self, node, uid):
        # If the node is already locked, return False
        if node.isLocked:
            return False

        # If any ancestors are locked, cannot lock this node
        if self.isAncestorLocked(node):
            return False

        # If any descendants are locked, cannot lock this node
        if node.lockedDescendantCount > 0:
            return False

        # Lock the node
        node.isLocked = True
        node.uid = uid

        # Update the lockedDescendantCount for ancestors
        parent = node.parent
        while parent:
            parent.lockedDescendantCount += 1
            parent = parent.parent

        return True

    def unlock(self, node, uid):
        # The node must be locked and the uid must match
        if not node.isLocked or node.uid != uid:
            return False

        # Unlock the node
        node.isLocked = False
        node.uid = None

        # Update the lockedDescendantCount for ancestors
        parent = node.parent
        while parent:
            parent.lockedDescendantCount -= 1
            parent = parent.parent

        return True

    def upgrade(self, node, uid):
        # The node must not be locked
        if node.isLocked:
            return False

        # If any ancestors are locked, cannot upgrade this node
        if self.isAncestorLocked(node):
            return False

        # The node must have at least one locked descendant
        if node.lockedDescendantCount == 0:
            return False

        locked_descendants = []

        # Collect all locked descendants
        if not self.collectLockedDescendants(node, uid, locked_descendants):
            return False

        # Unlock all locked descendants
        for descendant in locked_descendants:
            descendant.isLocked = False
            descendant.uid = None

            # Update the lockedDescendantCount for ancestors
            parent = descendant.parent
            while parent:
                parent.lockedDescendantCount -= 1
                parent = parent.parent

        # Lock the current node
        node.isLocked = True
        node.uid = uid

        # Update the lockedDescendantCount for ancestors
        parent = node.parent
        while parent:
            parent.lockedDescendantCount += 1
            parent = parent.parent

        return True

    def isAncestorLocked(self, node):
        curr = node.parent
        while curr:
            if curr.isLocked:
                return True
            curr = curr.parent
        return False

    def collectLockedDescendants(self, node, uid, locked_nodes):
        # If the node is locked
        if node.isLocked:
            if node.uid == uid:
                locked_nodes.append(node)
            else:
                return False  # Locked by different uid

        # Recursively check all children
        for child_node in node.child:
            if not self.collectLockedDescendants(child_node, uid, locked_nodes):
                return False
        return True

    def process_queries(self):
        results = []
        for query in self.processed_queries:
            operation, node_name, uid = query
            node = self.node_map[node_name]
            if operation == "1":
                result = self.lock(node, uid)
            elif operation == "2":
                result = self.unlock(node, uid)
            elif operation == "3":
                result = self.upgrade(node, uid)
            else:
                result = False  # Invalid operation
            results.append('true' if result else 'false')
        return results


def main():
    # Test case 1: Basic lock and unlock
    n = 3
    m = 2
    name_list = ["A", "B", "C"]
    queries = [
        "1 A 1",  # Lock A with uid 1
        "2 A 1",  # Unlock A with uid 1
    ]
    tree = Tree(m, n, name_list, queries)
    print(tree.process_queries())  # Expected: ['true', 'true']

    # Test case 2: Locking a node with a locked ancestor
    queries = [
        "1 A 1",  # Lock A with uid 1
        "1 B 2",  # Try to lock B with uid 2 (should fail because A is locked)
    ]
    tree = Tree(m, n, name_list, queries)
    print(tree.process_queries())  # Expected: ['true', 'false']

    # Test case 3: Unlocking a node with wrong uid
    queries = [
        "1 A 1",  # Lock A with uid 1
        "2 A 2",  # Try to unlock A with uid 2 (should fail because uid is wrong)
    ]
    tree = Tree(m, n, name_list, queries)
    print(tree.process_queries())  # Expected: ['true', 'false']

    # Test case 4: Upgrade a node with locked descendants
    queries = [
        "1 B 1",  # Lock B with uid 1
        "1 C 1",  # Lock C with uid 1
        "3 A 1",  # Upgrade A with uid 1 (should succeed and unlock B and C)
    ]
    tree = Tree(m, n, name_list, queries)
    print(tree.process_queries())  # Expected: ['true', 'true', 'true']

    # Test case 5: Upgrade a node with no locked descendants
    queries = [
        "3 A 1",  # Try to upgrade A with uid 1 (should fail because no locked descendants)
    ]
    tree = Tree(m, n, name_list, queries)
    print(tree.process_queries())  # Expected: ['false']

    # Test case 6: Locking a node with locked descendants
    queries = [
        "1 B 1",  # Lock B with uid 1
        "1 A 2",  # Try to lock A with uid 2 (should fail because B is locked)
    ]
    tree = Tree(m, n, name_list, queries)
    print(tree.process_queries())  # Expected: ['true', 'false']

    # Test case 7: Complex scenario
    n = 7
    m = 2
    name_list = ["A", "B", "C", "D", "E", "F", "G"]
    queries = [
        "1 B 1",  # Lock B with uid 1
        "1 D 1",  # Lock D with uid 1
        "1 E 1",  # Lock E with uid 1
        "3 A 1",  # Upgrade A with uid 1 (should succeed and unlock B, D, E)
        "1 A 2",  # Lock A with uid 2
        "2 A 1",  # Try to unlock A with uid 1 (should fail because uid is wrong)
        "2 A 2",  # Unlock A with uid 2
    ]
    tree = Tree(m, n, name_list, queries)
    print(tree.process_queries())  # Expected: ['true', 'true', 'true', 'true', 'true', 'false', 'true']


if __name__ == "main":
    main()