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>
using namespace std;
#define MAXN 3010
#define MO 1000000007
int f[MAXN][MAXN],dp[MAXN][MAXN],n,m,a[MAXN];
struct node
{
	int l,r;
}p[MAXN];
bool cmp(node a,node b)
{
	return a.l<b.l||(a.l==b.l&&a.r<b.r);
}
void Pre()
{
	f[0][0]=1;
	for(int i=1;i<n;i++)
	{
		f[i][0]=1;
		for(int j=1;j<=i;j++)
			f[i][j]=(f[i-1][j]+f[i-1][j-1])%MO;
	}
}
char s[MAXN];
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s",s);
	for(int i=0;i<n;i++)
		a[i+1]=a[i]+s[i]-'0';
	Pre();
	for(int i=1;i<=m;i++)
		scanf("%d%d",&p[i].l,&p[i].r);
	sort(p+1,p+1+m,cmp);
	int mx=0,tmp=m;
	for(int i=1;i<=m;i++)
		if(p[i].l==p[i+1].l||p[i].r<=mx)
			p[i].l=n+1,tmp--;
		else mx=max(p[i].r,mx);
	sort(p+1,p+1+m,cmp);
	m=tmp;
	dp[p[1].l-1][a[p[1].l-1]]=1;
	p[m+1].l=n+1;
	for(int i=1;i<=m;i++)
	{
		int l=p[i].l,r=p[i].r,x=p[i+1].l;
		for(int j=0;j<l;j++)
		{
			if(!dp[l-1][j]) continue;
			int s=a[r]-j,st=max(0,s-(r-x+1)),ed=min(s,x-l);
			if(x>r)
			{
				dp[x-1][a[x-1]]+=1LL*dp[l-1][j]*f[r-l+1][s]%MO;
				dp[x-1][a[x-1]]%=MO;
				continue;
			}
			for(int k=st;k<=ed;k++)
			{
				dp[x-1][j+k]+=1LL*dp[l-1][j]*f[x-l][k]%MO;
				dp[x-1][j+k]%=MO;
			}
		}
	}
	printf("%d\n",dp[n][a[n]]);
}