Easy solution
Code
# Code
```java []
class Solution {
    public int countWays(int[][] arr) {
        int mod = 1000000007;
        int n = arr.length;
        Arrays.sort(arr, (a,b)->a[0]-b[0]);
        
        int end = arr[0][1];
        int ct = 1;
        for(int i=1;i<n;i++){
            if(arr[i][0]<=end){
                end = Math.max(end, arr[i][1]);
            }else{
                ct = (ct+1)%mod;
                end = arr[i][1];
            }
        }

        long result = 1;
        long base = 2;

        while (ct > 0) {
            if ((ct & 1) == 1) {
                result = (result * base) % mod;
            }
            base = (base * base) % mod;
            ct >>= 1;
        }

        return (int) result;
    }
}
```
['Array', 'Sorting', 'Java']