#ARC065D. [ARC065F] シャッフル

[ARC065F] シャッフル

Score : 900900 points

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 \leq N \leq 3000
  • 1M30001 \leq M \leq 3000
  • SS consists of characters 0 and 1.
  • The length of SS equals NN.
  • 1li<riN1 \leq l_i < r_i \leq N
  • lili+1l_i \leq 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.

5 2
01001
2 4
3 5
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.

9 3
110111110
1 4
4 6
6 9
26
11 6
00101000110
2 4
2 3
4 7
5 6
6 10
10 11
143