[Python] 1 line Solution and O(1) Solution
Solutino 1: All 1 line\nPython\npy\nclass FrontMiddleBackQueue(object):\n\n    def __init__(self):\n        self.A = []\n\n    def pushFront(self, val):\n      
# Solutino 1: All 1 line\n**Python**\n```py\nclass FrontMiddleBackQueue(object):\n\n    def __init__(self):\n        self.A = []\n\n    def pushFront(self, val):\n        self.A.insert(0, val)\n\n    def pushMiddle(self, val):\n        self.A.insert(len(self.A) / 2, val)\n\n    def pushBack(self, val):\n        self.A.append(val)\n\n    def popFront(self):\n        return (self.A or [-1]).pop(0)\n\n    def popMiddle(self):\n        return (self.A or [-1]).pop((len(self.A) - 1) / 2)\n\n    def popBack(self):\n        return (self.A or [-1]).pop()\n\n```\n\n# Solution 2: All O(1) time\n**Python**\n```py\nclass FrontMiddleBackQueue(object):\n\n    def __init__(self):\n        self.A, self.B = collections.deque(), collections.deque()\n\n    def pushFront(self, val):\n        self.A.appendleft(val)\n        self.balance()\n\n    def pushMiddle(self, val):\n        if len(self.A) > len(self.B):\n            self.B.appendleft(self.A.pop())\n        self.A.append(val)\n\n    def pushBack(self, val):\n        self.B.append(val)\n        self.balance()\n\n    def popFront(self):\n        val = self.A.popleft() if self.A else -1\n        self.balance()\n        return val\n\n    def popMiddle(self):\n        val = (self.A or [-1]).pop()\n        self.balance()\n        return val\n\n    def popBack(self):\n        val = (self.B or self.A or [-1]).pop()\n        self.balance()\n        return val\n\n    # keep A.size() >= B.size()\n    def balance(self):\n        if len(self.A) > len(self.B) + 1:\n            self.B.appendleft(self.A.pop())\n        if len(self.A) < len(self.B):\n            self.A.append(self.B.popleft())\n```\n
[]