Solution
C++ []\nclass Solution {\npublic:\n    Solution(int m, int n) : rows(m), cols(n), total(m * n) {\n    }\n    vector<int> flip() {\n        if (used.size() == to
```C++ []\nclass Solution {\npublic:\n    Solution(int m, int n) : rows(m), cols(n), total(m * n) {\n    }\n    vector<int> flip() {\n        if (used.size() == total) return {};\n        int index = rand() % total;\n        while (used.count(index))\n        index = ++index % total;\n        used.insert(index);\n        return {index / cols, index % cols};\n    }\n    void reset() {\n        used.clear();\n    }\n private:\n    unordered_set<int> used;\n    int rows;\n    int cols;\n    int total;\n};\n```\n\n```Python3 []\nclass Solution:\n\n    def __init__(self, n_rows: int, n_cols: int):\n        self.c = n_cols\n        self.start = 0\n        self.end = n_rows * n_cols - 1\n        self.d = {}\n        \n    def flip(self):\n        rand = random.randint(self.start, self.end)\n        res = self.d.get(rand, rand)\n        self.d[rand] = self.d.get(self.start, self.start)\n        self.start += 1\n        return divmod(res, self.c)\n    \n    def reset(self):\n        self.d = {}\n        self.start = 0\n```\n\n```Java []\nclass Solution {\n    int i=0,j=0;\n     int m=0;int n=0;\n    public Solution(int m, int n) {\n        this.m=m;\n        this.n=n;\n    }\n    public int[] flip() {\n        j++;\n        if(j==n){\n            j=0;\n            i++;\n        }\n        if(i==m){\n            i=0;\n            j=0;\n        }\n        return new int[]{i,j};   \n    }\n    public void reset() {       \n    }\n}\n```\n
['C++', 'Java', 'Python3']