Easiest Approach
\n# Code\n\nclass Solution {\npublic:\nint m=1000000007;\nint power(int a,int n){\n    if(n==0) return 1;\n    if(n%2==1) return (1ll*(a%m)*(power(a,n/2)%m)*(po
\n# Code\n```\nclass Solution {\npublic:\nint m=1000000007;\nint power(int a,int n){\n    if(n==0) return 1;\n    if(n%2==1) return (1ll*(a%m)*(power(a,n/2)%m)*(power(a,n/2))%m)%m;\n    return (1ll*(power(a,n/2)%m)*(power(a,n/2))%m)%m;\n}\n    vector<vector<int>> merge(vector<vector<int>>& ranges){\n        vector<vector<int>>ans;\n        vector<pair<int,int>>p;\n        for(int i=0;i<ranges.size();i++){\n            p.push_back({ranges[i][0],ranges[i][1]});\n        }\n        sort(p.begin(),p.end());\n        int n=p.size();\n        //vector<int>temp;\n        int p1=p[0].first;\n        int p2=p[0].second;\n        for(int i=0;i<n-1;i++){\n           if(p2>=p[i+1].first){\n            p2=max(p[i+1].second,p2);\n           \n           }\n           /*{11,48},{12,16},{22,55},{28,29},{28,41},{28,54},{34,56},{41,44}*/\n           else{\n                vector<int>temp;\n                temp.push_back(p1);\n                temp.push_back(p2);\n                ans.push_back(temp);\n                p1=p[i+1].first;\n                p2=p[i+1].second;      \n        }\n        }\n                vector<int>temp;\n                temp.push_back(p1);\n                temp.push_back(p2);\n                ans.push_back(temp);\n        return ans;\n    }\n    int countWays(vector<vector<int>>& ranges) {\n        vector<vector<int>>ans=merge(ranges);\n        int n=ans.size();\n        return power(2,n)%m;\n    }\n};\n```
['C++']