class Node:
    next_node: "None | Node" = None
    prev_node: "None | Node" = None

    def __init__(self, value):
        self.value = value

class Queue:
    front: "Node | None" = None
    back: "Node | None" = None

    def append(self, value):
        if self.back is None:
            self.front = Node(value)
            self.back = self.front
        else:
            new_node = Node(value)
            self.back.prev_node = new_node
            new_node.next_node = self.back
            self.back = new_node
    
    def popleft(self):
        if self.front is not None:
            prev_front = self.front

            prev_node_in_queue = self.front.prev_node
            self.front.next_node = None
            self.front.prev_node = None
            if prev_node_in_queue is not None:
                prev_node_in_queue.next_node = None

            self.front = prev_node_in_queue
            
            return prev_front
        else:
            return None

    def print_queue(self):
        current_node = self.front
        while current_node is not None:
            print(current_node.value)
            current_node = current_node.prev_node


queue = Queue()
queue.append("first")
queue.append("second")
queue.append("third")
queue.popleft()
queue.popleft()
queue.print_queue()
