Python simple deque solution
\nclass RLEIterator:\n\n    def __init__(self, encoding: List[int]):\n        self.dq = deque(encoding)\n\n    def next(self, n: int) -> int:\n        ans = -1\
```\nclass RLEIterator:\n\n    def __init__(self, encoding: List[int]):\n        self.dq = deque(encoding)\n\n    def next(self, n: int) -> int:\n        ans = -1\n        while(n>0):\n            if not self.dq:\n                return -1\n            if self.dq[0]>n:\n                self.dq[0] -= n\n                n = 0\n                ans = self.dq[1]\n            else:\n                n -= self.dq.popleft()\n                ans = self.dq.popleft()\n                \n        return ans\n```
[]