Double Linked list Java solution
\nclass DoubleLinkedNode{\n    int val;\n    DoubleLinkedNode prev;\n    DoubleLinkedNode next;\n    public DoubleLinkedNode(int val){\n        this.val = val;\
```\nclass DoubleLinkedNode{\n    int val;\n    DoubleLinkedNode prev;\n    DoubleLinkedNode next;\n    public DoubleLinkedNode(int val){\n        this.val = val;\n    }\n}\nclass FrontMiddleBackQueue {\n    DoubleLinkedNode head;\n    DoubleLinkedNode tail;\n    DoubleLinkedNode mid;\n    int size;\n    public FrontMiddleBackQueue() {\n        head = new DoubleLinkedNode(-1);\n        tail = new DoubleLinkedNode(-1);\n        head.next = tail;\n        tail.prev = head;\n        size = 0;\n    }\n    \n    public void pushFront(int val) {\n        DoubleLinkedNode node = new DoubleLinkedNode(val);\n        node.next = head.next;\n        head.next.prev = node;\n        node.prev = head;\n        head.next = node;\n        size++;\n        if(size == 1){\n            mid = node;\n        }else if(size % 2 == 0){\n            mid = mid.prev;\n        }\n    }\n    \n    public void pushMiddle(int val) {\n        DoubleLinkedNode newMid = new DoubleLinkedNode(val);\n        if(size == 0){ \n            newMid.prev = head;\n            newMid.next = tail;            \n            head.next = newMid;\n            tail.prev = newMid;\n            mid = newMid;\n            size++;\n            return;\n        }\n        if(size % 2 == 0){\n            newMid.next = mid.next;\n            newMid.prev = mid;\n            mid.next.prev = newMid;\n            mid.next = newMid;\n            mid = newMid;\n        }else{\n            newMid.next = mid;\n            newMid.prev = mid.prev;\n            mid.prev.next = newMid;\n            mid.prev = newMid;\n            mid = newMid;\n        }\n        size++; \n        return;\n    }\n    \n    public void pushBack(int val) {\n        DoubleLinkedNode newEnd = new DoubleLinkedNode(val);\n        newEnd.prev = tail.prev;\n        newEnd.next = tail;\n        tail.prev.next = newEnd;\n        tail.prev = newEnd;\n        size++;\n        if(size == 1){\n            mid = newEnd;\n        }else if(size % 2 == 1){\n            mid = mid.next;\n        }\n    }\n    \n    public int popFront() {\n        if(size > 0){\n            DoubleLinkedNode removedNode = head.next;\n            removedNode.next.prev = head;\n            head.next = removedNode.next;\n            size--;\n            if(size % 2 == 1) mid = mid.next;\n            return removedNode.val;\n        }\n        return -1;\n    }\n    \n    public int popMiddle() {\n        if(size > 0){\n            int removedVal = mid.val;\n            mid.prev.next = mid.next;\n            mid.next.prev = mid.prev;\n            size--;\n            if(size % 2 == 0){\n                mid = mid.prev;\n            }else{\n                mid = mid.next;\n            }\n            return removedVal;\n        }\n        return -1;\n    }\n    \n    public int popBack() {\n        if(size > 0){\n            DoubleLinkedNode removedNode = tail.prev;\n            removedNode.next.prev = removedNode.prev;\n            removedNode.prev.next = removedNode.next;            \n            size--;\n            if(size % 2 == 0){\n                mid = mid.prev;\n            }\n            return removedNode.val;\n        }\n        return -1;\n    }\n}\n```
['Linked List', 'Java']