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
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

const int N=3005,P=1e9+7;

int fac[N],ifac[N];
int fpow(int a,int t){static int r;for(r=1;t;t>>=1,a=(ll)a*a%P)if(t&1)r=(ll)r*a%P;return r;}
int C(int n,int m){if(n<m)return 0;return (ll)fac[n]*ifac[m]%P*ifac[n-m]%P;}

int n,m,f[N],L,R,sum[N];
char str[N];

int main(){
	scanf("%d%d",&n,&m);
	scanf("%s",str+1);
	for(int i=1;i<=n;i++)sum[i]=sum[i-1]+(str[i]&1);
	fac[0]=1;
	for(int i=1;i<=n;i++)fac[i]=(ll)fac[i-1]*i%P;
	ifac[n]=fpow(fac[n],P-2);
	for(int i=n;i>=1;i--)ifac[i-1]=(ll)ifac[i]*i%P;
	f[0]=1;
	for(int i=1,l,r;i<=m;i++){
		scanf("%d%d",&l,&r);
		if(r<=R)continue;
		if(R<l){
			int t=0;
			for(int i=0;i<=n;i++)if(f[i])t=(t+(ll)C(R-L+1,i)*f[i])%P,f[i]=0;
			L=l,R=r,f[sum[R]-sum[L-1]]=t;
		}else{
			while(L<l){
				for(int i=1;i<=n;i++)if(f[i])(f[i-1]+=f[i])%=P;
				L++;
			}
			for(int i=R-L+2;i<=n;i++)f[i]=0;
			int t=sum[r]-sum[R];
			for(int i=n,x;i>=0;i--)if(f[i])x=f[i],f[i]=0,f[i+t]=x;
			R=r;
		}
	}
	int t=0;
	for(int i=0;i<=n;i++)if(f[i])t=(t+(ll)f[i]*C(R-L+1,i))%P;
	printf("%d\n",t);
	return 0;
}