Python solution || Easy to understand || Very Easy || With Explianation
\nclass Solution:\n    def countWays(self, intervals: List[List[int]]) -> int:\n\t\t\n\t\t# we can move a interval to either grp 1 or grp  2 so  ans will be mul
```\nclass Solution:\n    def countWays(self, intervals: List[List[int]]) -> int:\n\t\t\n\t\t# we can move a interval to either grp 1 or grp  2 so  ans will be multiple of two\n        ans=2\n\t\t\n\t\t# sort the intervals based on first element\n        intervals.sort(key=lambda x: x[0])\n\t\t\n\t\t# stores the merged intervals\n        mer = []\n\t\t\n\t\t# traverse intervals one by one and merging them\n        for interval in intervals:\n            if not mer or mer[-1][1] < interval[0]:\n                mer.append(interval)\n            else:\n                mer[-1][1] = max(mer[-1][1], interval[1])\n\t\t\t\t\n\t\t# finally our ans will be 2**total_merge_intervals because ans may be large it\'ll take time to\n\t\t# compute modulo so for avoid it pass it to pow and return the ans\n        return pow(ans,len(mer),1000_000_007)\n```
['Math', 'Sorting', 'Python', 'Python3']