Wolves 2

Count binary strings of length N in which every given interval contains at most two ones, modulo 1e9+7.

Hard8Dynamic programmingPrefix sumCombinatoricsImplementationInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

Wolves appear on the road where Yeongseon is standing. The road is divided into NN zones, numbered 00 through N1N-1. A single zone holds at most one wolf.

Yeongseon knows MM pieces of information about the wolves. One piece of information names one interval of zones and means that the interval holds at most two wolves.

Write a program that counts the wolf arrangements satisfying all MM pieces of information. An arrangement is decided by whether each zone holds a wolf or not.

Input

The first line contains the number of zones NN and the number of pieces of information MM. (1N,M3001 \le N, M \le 300)

Each of the next MM lines contains one piece of information as two integers, the leftmost zone number LL and the rightmost zone number RR of the interval. (0LRN10 \le L \le R \le N-1) The interval includes both end zones, and the information means that zones LL through RR hold at most two wolves in total. The same interval is given more than once in some inputs.

Output

Print the number of possible wolf arrangements modulo 1,000,000,007 on the first line.