C++ Beats 100% on space and time. O(1), a simple goto , to represent a for
\nclass Solution {\n    int x1, y1, x2, y2;\n    int RectPos;\n    int Reset;\n    vector<vector<int>> *R;\npublic:\n    Solution(vector<vector<int>>& rects) {\
```\nclass Solution {\n    int x1, y1, x2, y2;\n    int RectPos;\n    int Reset;\n    vector<vector<int>> *R;\npublic:\n    Solution(vector<vector<int>>& rects) {\n        RectPos = 0;\n        Reset = rects[0][2];\n        x1 = rects[0][0];\n        y1 = rects[0][1];\n        x2 = rects[0][2];\n        y2 = rects[0][3];\n        R = &rects;\n    }\n    \n    vector<int> pick() {\n        vector<int> ans(2);\n        \n        label:\n        if(y1 <= y2)\n        {\n            if(x1 <= x2)\n                ans[0] = x2, ans[1] = y1, x2--;\n            else\n            {\n                x2 = Reset;\n                y1++;\n                goto label;\n            }\n        }\n        else\n        {\n            RectPos++;\n            if(RectPos == R->size())\n                RectPos = 0;\n            Reset = (*R)[RectPos][2];\n            x1 = (*R)[RectPos][0];\n            y1 = (*R)[RectPos][1];\n            x2 = (*R)[RectPos][2];\n            y2 = (*R)[RectPos][3];\n            goto label;\n        }\n        \n        return ans;\n    }\n};\n\n/**\n * Your Solution object will be instantiated and called as such:\n * Solution* obj = new Solution(rects);\n * vector<int> param_1 = obj->pick();\n */\n```
[]