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 <cstdio>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
using namespace std;

typedef long long LL;
const int p=1000000007;
int n,m,sum[3010],l[3010],r[3010],f[3010][3010],c[3010][3010];
char a[3010];

int main()
{
    int t;
    scanf("%d%d%s",&n,&t,a+1);
    repu(i,1,n)
        sum[i]=sum[i-1]+(a[i]=='1');
    while (t--)
    {
        scanf("%d%d",&l[m+1],&r[m+1]);
        m+=r[m+1]>r[m];
    }
    sum[l[m+1]=r[m+1]=n+1]=sum[n],f[0][0]=1;
    repu(i,0,n)
    {
        c[i][0]=1;
        repu(j,1,i)
            c[i][j]=(c[i-1][j]+c[i-1][j-1])%p;
    }
    repu(i,0,m)
        repu(j,0,r[i]-l[i]+1)
            if (f[i][j])
            {
                int cnt=sum[r[i+1]]-sum[max(l[i+1]-1,r[i])];
                if (l[i+1]>r[i])
                    f[i+1][cnt]=(f[i+1][cnt]+LL(f[i][j])*c[r[i]-l[i]+1][j])%p;
                else
                {
                    int x=max(j-(l[i+1]-l[i]),0);
                    int y=min(j,r[i]-l[i+1]+1);
                    repu(k,x,y)
                        f[i+1][cnt+k]=(f[i+1][cnt+k]+LL(f[i][j])*c[l[i+1]-l[i]][j-k])%p;
                }
            }
    printf("%d\n",f[m+1][0]);
    return 0;
}