Solution
C++ []\nclass RLEIterator {\npublic:\n    RLEIterator(const std::vector<int>& encoding)\n    {\n        m_encodings.reserve(encoding.size() / 2);\n        for (
```C++ []\nclass RLEIterator {\npublic:\n    RLEIterator(const std::vector<int>& encoding)\n    {\n        m_encodings.reserve(encoding.size() / 2);\n        for (int i = 0; i < encoding.size(); i += 2) {\n            const int count = encoding[i];\n            const int number = encoding[i + 1];\n            m_encodings.emplace_back(count, number);\n        }\n    }\n    int next(int n)\n    {\n        while (m_current_idx < m_encodings.size() && m_encodings[m_current_idx].first < n) {\n            n -= m_encodings[m_current_idx].first;\n            m_encodings[m_current_idx].first = 0;\n            ++m_current_idx;\n        }\n        if (m_current_idx >= m_encodings.size())\n            return -1;\n        m_encodings[m_current_idx].first -= n;\n        return m_encodings[m_current_idx].second;\n    }\nprivate:\n    int m_current_idx = 0;\n    std::vector<std::pair<int, int>> m_encodings;\n};\n```\n\n```Python3 []\nclass RLEIterator:\n\n    def __init__(self, encoding: List[int]):\n        self.lst=encoding\n\n    def next(self, n: int) -> int:\n        num=-1\n        while self.lst and n>0:\n            if n<=self.lst[0]:\n                self.lst[0]-=n  \n                n=0\n                num=self.lst[1]\n            else:\n                n-=self.lst[0]\n                self.lst[0]=0\n            if self.lst[0]==0:\n                self.lst.pop(0)\n                self.lst.pop(0)\n        if n>0:\n            return -1\n        return num\n```\n\n```Java []\nclass RLEIterator {\n    public int[] encoding;\n    public int index;\n    public RLEIterator(int[] encoding) {\n        this.encoding = encoding;\n        this.index = 0;\n    }\n    public int next(int n) {   \n        while (n > 0 && index < encoding.length) {\n            if (encoding[index] < n) {\n                n -= encoding[index];\n                encoding[index] = 0;\n                index += 2;\n            } else {\n                encoding[index] -= n;\n                n = 0;\n            }\n        }\n        if (index >= encoding.length) return -1;\n        return encoding[index + 1];\n    }\n}\n```\n
['C++', 'Java', 'Python3']