Wolves

Count subsets of N sections, each holding at most one wolf, such that every given interval contains at least one chosen section, modulo 1e9+7.

Medium7Dynamic programmingCombinatoricsIntervalsPrefix sumNo attempts yetTime limit2sMemory limit512 MB

Problem

Wolves appear on the road where Yeongseon is standing, so she is working out carefully where they can be.

The road is divided into NN sections numbered 00 through N1N-1. A section holds at most one wolf.

Yeongseon knows MM pieces of information about the wolves. Each piece is a single interval, and it means that at least one section inside that interval holds a wolf.

Write a program that counts the wolf placements satisfying all MM pieces of information. Two placements are different when the set of sections holding a wolf is different.

Input

The first line contains the number of sections 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: the left end section number LL and the right end section number RR of an interval. (0LRN10 \le L \le R \le N-1) The interval includes both end sections. The same interval can be given more than once.

Output

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