9 line answer easy to understand  c++ solution
\n# Code\n\n\nconst int MOD = 1e9 + 7;\n\nclass Solution {\npublic:\n    int countWays(vector<vector<int>>& a) {\n        int n = a.size();\n        sort(a.begi
\n# Code\n```\n\nconst int MOD = 1e9 + 7;\n\nclass Solution {\npublic:\n    int countWays(vector<vector<int>>& a) {\n        int n = a.size();\n        sort(a.begin(), a.end());\n        \n        int ret = 1;\n        for (int i = 0, j; i < n; i = j) {\n            int R = a[i][1];\n            for (j = i + 1; j < n && a[j][0] <= R; ++j) R = max(R, a[j][1]);\n            ret = ret * 2LL % MOD;\n        }\n        return ret;\n        \n    }\n};\n```
['C++', 'Java', 'Python3']