#arc065d. [arc065_d]Shuffling

[arc065_d]Shuffling

Problem Statement

There is a string SS of length NN consisting of characters 0 and 1. You will perform the following operation for each i=1,2,...,mi = 1, 2, ..., m:

  • Arbitrarily permute the characters within the substring of SS starting at the lil_i-th character from the left and extending through the rir_i-th character.

Here, the sequence lil_i is non-decreasing.

How many values are possible for SS after the MM operations, modulo 1000000007(=109+7)1000000007(= 10^9+7)?

Constraints

  • 2N30002≦N≦3000
  • 1M30001≦M≦3000
  • SS consists of characters 0 and 1.
  • The length of SS equals NN.
  • 1li<riN1≦l_i < r_i≦N
  • lili+1l_i ≦ l_{i+1}

Input

The input is given from Standard Input in the following format:

NN MM SS l1l_1 r1r_1 : lMl_M rMr_M

Output

Print the number of the possible values for SS after the MM operations, modulo 10000000071000000007.


Sample Input 1

5 2
01001
2 4
3 5

Sample Output 1

6

After the first operation, SS can be one of the following three: 01001, 00101 and 00011.

After the second operation, SS can be one of the following six: 01100, 01010, 01001, 00011, 00101 and 00110.


Sample Input 2

9 3
110111110
1 4
4 6
6 9

Sample Output 2

26

Sample Input 3

11 6
00101000110
2 4
2 3
4 7
5 6
6 10
10 11

Sample Output 3

143