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 ll long long
#define mod 1000000007
#define N 3005
using namespace std;

int n,m,s[N],a[N],b[N],dp[N][N],cbn[N][N]; char ch[N];
int main(){
	scanf("%d%d%s",&n,&m,ch+1);
	int i,j,k;
	for (i=1; i<=n; i++) s[i]=s[i-1]+(ch[i]=='1');
	m++; a[1]=b[1]=1;
	for (i=2; i<=m; i++){
		scanf("%d%d",&a[i],&b[i]);
		if (a[i]==a[i-1]){
			b[i-1]=max(b[i-1],b[i]); i--; m--; continue;
		}
		if (b[i]<=b[i-1]){ i--; m--; continue; }
		while (a[i]>b[i-1]+1){
			a[i+1]=a[i]; b[i+1]=b[i];
			a[i]=b[i]=b[i-1]+1;
			i++; m++;
		}
	}
	for (; b[m]<=n; m++) a[m+1]=b[m+1]=b[m]+1;
	dp[0][0]=1;
	for (i=0; i<=n; i++)
		for (j=cbn[i][0]=1; j<=i; j++) cbn[i][j]=(cbn[i-1][j]+cbn[i-1][j-1])%mod;
	for (i=1; i<m; i++){
		for (j=max(a[i+1]-1-b[i]+s[b[i]],0); j<=s[b[i]]; j++)
			for (k=0; k<=a[i+1]-a[i] && k<=j; k++) dp[i][j]=(dp[i][j]+(ll)dp[i-1][j-k]*cbn[a[i+1]-a[i]][k])%mod;
	}
	printf("%d\n",dp[m-1][s[n]]);
	return 0;
}