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<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)

using namespace std;
const int N=3005,mod=1000000007;
typedef long long LL;
char S[N];
int n,m,s[N],x[N],y[N],c[N][N],tot,l[N],r[N],maxn;
LL f[N][N];
struct data{int x,y;} dat[N];

int getint()
{
	char ch;
	int f=1;
	while(!isdigit(ch=getchar())) if(ch=='-') f=-1;
	int x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x*f;
}

bool cmp(data a,data b)
{
	return a.x==b.x?a.y>b.y:a.x<b.x;
}

int main()
{
	n=getint(),m=getint(),scanf("%s",S+1);
	rep(i,0,n) c[i][0]=c[i][i]=1;
	rep(i,1,n) rep(j,1,i-1) c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
	rep(i,1,n) s[i]=s[i-1]+S[i]-48;
	rep(i,1,m) dat[i].x=getint(),dat[i].y=getint();
	sort(dat+1,dat+1+m,cmp);
	rep(i,1,m) if(dat[i].y>maxn) ++tot,x[tot]=dat[i].x,y[tot]=dat[i].y,maxn=dat[i].y;
	f[0][0]=1,x[tot+1]=y[tot+1]=n+1;
	rep(i,1,tot)
	{
		int w=min(y[i]-x[i]+1,x[i+1]-x[i]),a=s[y[i]]-s[max(x[i]-1,y[i-1])];
		l[i]=max(0,l[i-1]+a-w),r[i]=min(max(y[i]-x[i+1]+1,0),r[i-1]+a);
		rep(j,l[i],r[i])
			rep(k,l[i-1],r[i-1])
				f[i][j]=(f[i][j]+f[i-1][k]*c[w][k+a-j])%mod;
	}
	printf("%lld\n",f[tot][0]);
	return 0;
}