Problem: There is a string S of length N consisting of characters `0` and `1`. You will perform the following operation for each i = 1, 2, ..., m:

* Arbitrarily permute the characters within the substring of S starting at the l_i-th character from the left and extending through the r_i-th character.



Here, the sequence l_i is non-decreasing.

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

Constraints

* 2≦N≦3000
* 1≦M≦3000
* S consists of characters `0` and `1`.
* The length of S equals N.
* 1≦l_i < r_i≦N
* l_i ≦ l_{i+1}

Input

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


N M
S
l_1 r_1
:
l_M r_M


Output

Print the number of the possible values for S after the M operations, modulo 1000000007.

Examples

Input

5 2
01001
2 4
3 5


Output

6


Input

9 3
110111110
1 4
4 6
6 9


Output

26


Input

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


Output

143

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
#define x first
#define y second

using namespace std;

int N, M, mod, s[3009], rgt[3009], dp[3009][3009];
char sir[3009];

void ad (int &i, int j)
{
    i += j;
    if (i >= mod) i -= mod;
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d\n", &N, &M), mod = 1e9 + 7;
scanf ("%s", sir + 1);
for (int i=1; i<=N; i++)
    s[i] = s[i - 1] + (sir[i] == '1');
for (int i=1; i<=N; i++)
    rgt[i] = i;
while (M --)
{
    int x, y;
    scanf ("%d %d", &x, &y);
    if (y > rgt[x]) rgt[x] = y;
}
dp[0][0] = 1;
int R = 0;
for (int i=0; i<N; i++)
{
    for (int j=0; j<=R - i; j++)
    if (dp[i][j])
    {
        //printf ("primele %d si pe [%d, %d] inca %d de 1 -> %d\n", i, i + 1, R, j, dp[i][j]);
        int k1 = j, k0 = (R - i) - j, mk0 = 0, mk1 = 0;
        if (rgt[i + 1] > R) mk1 = s[rgt[i + 1]] - s[R], mk0 = rgt[i + 1] - R - mk1;
        k0 += mk0, k1 += mk1;
        if (k1 >= 1) ad (dp[i + 1][k1 - 1], dp[i][j]);
        if (k0 >= 1) ad (dp[i + 1][k1], dp[i][j]);
    }
    if (rgt[i + 1] > R) R = rgt[i + 1];
}
printf ("%d\n", dp[N][0]);
return 0;
}