#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';
}