[Python] generate production and then DP
\nclass Solution:\n    def earliestAndLatest(self, n: int, firstPlayer: int, secondPlayer: int) -> List[int]:\n        import functools\n        \n        def w
```\nclass Solution:\n    def earliestAndLatest(self, n: int, firstPlayer: int, secondPlayer: int) -> List[int]:\n        import functools\n        \n        def win(i, j, first, second):\n            if i == j:\n                return [i]\n            if i in (first, second):\n                return [i]\n            if j in (first, second):\n                return [j]\n            return [i, j]\n        \n        @functools.lru_cache(None)\n        def dfs(n, first, second) -> List[int]:\n            if n - first + 1 == second:\n                return [1, 1]\n            \n            res = [[]]\n            l, r = 1, n\n            while l <= r:\n                winner = win(l, r, first, second)\n                \n                prev_len = len(res)\n                for e in res:\n                    e.append(winner[0])\n                if len(winner) > 1:\n                    for i in range(prev_len):\n                        res.append(res[i][:])\n                        res[-1][-1] = winner[1]\n                        \n                l += 1\n                r -= 1\n                \n            ans = [float(\'infinity\'), float(\'-infinity\')]\n            for e in res:\n                e = sorted(e)\n                a = e.index(first) + 1\n                b = e.index(second) + 1\n                small, large = dfs(len(e), a, b)\n                ans[0] = min(ans[0], small + 1)\n                ans[1] = max(ans[1], large + 1)\n                \n            return ans[0], ans[1]\n        \n        return dfs(n, firstPlayer, secondPlayer)\n```
[]