Python all operations O(1) -> DLL
\nclass Node:\n    def __init__(self, val):\n        self.val = val\n        self.next = None\n        self.prev = None\n    \nclass FrontMiddleBackQueue:\n\n  
```\nclass Node:\n    def __init__(self, val):\n        self.val = val\n        self.next = None\n        self.prev = None\n    \nclass FrontMiddleBackQueue:\n\n    def __init__(self):\n        self.head = Node(float(\'-inf\'))\n        self.tail = self.head\n        self.middle = self.head\n        self.size = 0\n\n    def pushFront(self, val: int) -> None:\n        newNode = Node(val)\n        if not self.head.next:\n            self.head.next = newNode\n            newNode.prev = self.head\n            self.tail = newNode\n            self.middle = newNode\n            self.size += 1\n            return\n        nextNode = self.head.next\n        nextNode.prev = None\n        self.head.next = newNode\n        newNode.prev = self.head\n        newNode.next = nextNode\n        nextNode.prev = newNode\n        self.size += 1\n        if self.size % 2 == 0:\n            self.middle = self.middle.prev \n        return\n\n    def pushMiddle(self, val: int) -> None:\n        if self.head == self.tail:\n            newNode = Node(val)\n            self.head.next = newNode\n            newNode.prev = self.head\n            self.tail = newNode\n            self.middle = newNode\n            self.size += 1\n            return\n        newNode = Node(val)\n        if self.size % 2 == 0:\n            nextNode = self.middle.next\n            nextNode.prev = None\n            self.middle.next = newNode\n            newNode.prev = self.middle\n            newNode.next = nextNode\n            nextNode.prev = newNode\n            self.middle = newNode\n            self.size += 1\n            return\n        else:\n            if self.size == 1:\n                self.pushFront(val)\n                return\n            else:\n                prevNode = self.middle.prev\n                self.middle.prev = None\n                prevNode.next = newNode\n                newNode.prev = prevNode\n                newNode.next = self.middle\n                self.middle.prev = newNode\n                self.middle = newNode\n                self.size += 1\n                return \n            \n\n    def pushBack(self, val: int) -> None:\n        newNode = Node(val)\n        self.tail.next = newNode\n        newNode.prev = self.tail\n        self.tail = newNode\n        self.size += 1\n        if self.size % 2 != 0:\n            self.middle = self.middle.next\n        return\n        \n\n    def popFront(self) -> int:\n        if not self.head.next:\n            return -1\n        val = self.head.next.val\n        nextNode = self.head.next\n        nextNextNode = self.head.next.next\n        if nextNextNode:\n            nextNode.prev = None\n            nextNode.next = None\n            self.head.next = nextNextNode\n            nextNextNode.prev = self.head\n        else:\n            nextNode.prev = None\n            self.head.next = None\n        self.size -= 1\n        if self.size < 2:\n            if self.size == 1:\n                self.middle = self.head.next\n            else:\n                self.tail = self.middle = self.head\n        else:\n            if self.size % 2 != 0:\n                self.middle = self.middle.next\n        return val\n\n    def popMiddle(self) -> int:\n        if self.size == 0:\n            return -1\n        val = self.middle.val\n        if self.size == 1:\n            self.head.next = None\n            self.tail = self.middle = self.head\n            self.size -= 1\n            return val\n        else:\n            prevNode = self.middle.prev\n            nextNode = self.middle.next\n            self.middle.prev = None\n            self.middle.next = None\n            if self.size % 2 == 0:\n                self.middle = nextNode\n                prevNode.next = nextNode\n                nextNode.prev = prevNode\n                self.size -= 1\n                return val\n            else:\n                self.middle = prevNode\n                prevNode.next = nextNode\n                nextNode.prev = prevNode\n                self.size -= 1\n                return val\n        \n    def popBack(self) -> int:\n        if self.head == self.tail:\n            return -1\n        prevNode = self.tail.prev\n        val = self.tail.val\n        self.tail.prev = None\n        prevNode.next = None\n        self.tail = prevNode\n        self.size -= 1\n        if self.size < 2:\n            if self.size == 1:\n                self.middle = self.head.next\n            else:\n                self.middle = self.head\n        else:\n            if self.size % 2 == 0:\n                self.middle = self.middle.prev\n        return val\n            \n        \n\n\n# Your FrontMiddleBackQueue object will be instantiated and called as such:\n# obj = FrontMiddleBackQueue()\n# obj.pushFront(val)\n# obj.pushMiddle(val)\n# obj.pushBack(val)\n# param_4 = obj.popFront()\n# param_5 = obj.popMiddle()\n# param_6 = obj.popBack()\n```
['Linked List', 'Python', 'Python3']