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>
using namespace std;
typedef long long ll;
const ll M = 1e9+7;
inline ll mul(ll a, ll b) {return (a*b)%M;}
const int MN = 3030;
ll dp[MN][MN];
ll pr[MN];
ll lf[MN],rt[MN];
ll bp(ll b, ll p) {
	ll ac = 1;
	while(p) {
		if(p&1) {ac = mul(ac,b);}
		b = mul(b,b);
		p >>= 1;
	}
	return ac;
}
ll cf[MN][MN];
ll ch(ll n, ll k) {
	if(k > n || k < 0) return 0;
	if(k == 0 || k == n) return 1;
	if(cf[n][k] != -1) return cf[n][k];
	return cf[n][k] = (ch(n-1,k-1)+ch(n-1,k))%M;
}
ll ct;
ll ds(ll id, ll x, ll rb) {
	rb = max(rb,lf[id]);
	x += pr[rt[id]]-pr[rb];
	if(id == ct-1) {
		return ch(rt[id]-lf[id],x);
	}
	if(dp[id][x] != -1) {
		return dp[id][x];
	}
	ll tot = 0;
	ll nt = max(rt[id]-lf[id+1],0LL);
	for(int i=0;i<=min(nt,x);i++) {
		tot += mul(ch(min(rt[id],lf[id+1])-lf[id],x-i),ds(id+1,i,rt[id]));
	}
	tot %= M;
	//cout << "dp " << id << " " << x << " = " << tot << '\n';
	return dp[id][x] = tot;
}
int main() {
	ios::sync_with_stdio(0);
	memset(cf,-1,sizeof(cf));
	memset(dp,-1,sizeof(dp));
	int n,m;
	string s;
	cin >> n >> m;
	cin >> s;
	ll ub = -1,id = 0;
	pr[0] = 0;
	for(int i=0;i<n;i++) {
		pr[i+1] = pr[i] + (s[i]-'0');
	}
	for(int i=0;i<m;i++) {
		ll a,b;
		cin >> a >> b;a--;b--;
		if(b <= ub) continue;
		ub = b;
		lf[id] = a;
		rt[id++] = b+1;
	}
	ct = id;
	cout << ds(0,0,0) << '\n';
}