#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
const ll fact_table = 800008;
double Pi = 3.1415926535897932384626;
 
//vector<ll> G[550010];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
//ll mod = 998244353;
ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k;
ll ans;
vector <ll> x;
vector <ll> y;
ll fix[500005], append[500005];
char s[500005], t[500005], u[500005];
ll dp[4004][4004];
bool ban[5005][5005];
vector<P> problem[500005];
// zero one

void init(){
	for(ll i=0;i<=3000;i++){
		for(ll j=0;j<=3000;j++){
			ban[i][j] = false;
			dp[i][j] = 0;
		}
	}
}
void bind(ll n, ll zero, ll one){
	//pe(zero);pe(one);p(n);
	//assert(zero + one >= n);
	
	for(ll i=0;i<=n;i++){
		ll j = n - i;
		if(zero < i || one < j){
			ban[i][j] = true;
		}
	}
	
	
	for(ll i=0;i<=n;i++){
		if(i + one + 1 <= n){
			ban[i][one + 1] = true;
		}
	}
	for(ll j=0;j<=n;j++){
		if(zero + 1 + j <= n){
			ban[zero + 1][j] = true;
		}
	}
	
	return;
}

ll solve(ll id){
	vector<P> table = problem[id];
	ll idx = table[0].first;
	m = table.size();
	ll leftmost = table[0].first;
	ll rightmost = table[0].first - 1;
	table.pb(P(y.back() + 1, INF));
	for(ll i=0;i<m;i++){
		append[i] = table[i].second - rightmost;
		fix[i] = table[i+1].first - table[i].first;
		//pe(append[i]);
		//p(fix[i]);

		rightmost = max(table[i].second, rightmost);
	}
	ll zero = 0, one = 0;
	ll fixsum = 0;
	init();
	for(ll i=0;i<m;i++){
		ll myappend = append[i];
		while(myappend--){
			if(s[idx] == '1'){
				one++;
			}else{
				zero++;
			}
			idx ++;
		}
		fixsum += fix[i];
		bind(fixsum, zero, one);
	}
	one = 0, zero = 0;
	for(ll i=leftmost;i<=rightmost;i++){
		if(s[i] == '1'){
			one ++;
		}else{
			zero ++;
		}
	}
	for(ll i=0;i<=zero;i++){
		for(ll j=0;j<=one;j++){
			if(ban[i][j]){
				dp[i][j] = 0;
				continue;
			}else if(i == 0 && j == 0){
				dp[i][j] = 1;
			}else if (i == 0){
				dp[i][j] = dp[i][j-1];
			}else if (j == 0){
				dp[i][j] = dp[i-1][j];
			}else{
				dp[i][j] = dp[i-1][j] + dp[i][j-1];
				dp[i][j] %= mod;
			}
		}
	}
	//p(rightmost);
	//pe(leftmost);p(rightmost);
	
	//pe(one);p(zero);
	return dp[zero][one];
}
int main(){
	cin >> n >> m;
	cin >> s;
	ll leftmost = INF;
	ll rightmost = -1;
	for(ll i=0;i<m;i++){
		cin >> a >> b;
		a --;
		b --;
		if(b <= rightmost)continue;
		rightmost = max(b, rightmost);
		leftmost = min(a, leftmost);
		x.pb(a);
		y.pb(b);
	}

	ll problemid = 0;
	m = x.size();

	for(ll i=0;i<m-1;i++){
		problem[problemid].pb(P(x[i], y[i]));
		if(x[i+1] > y[i]){
			problemid ++;
		}
	}
	problem[problemid].pb(P(x[m-1], y[m-1]));
	ans = 1;
	//assert(problemid == 0);
	for(ll i=0;i<=problemid;i++){
		ans *= solve(i);
		//p(ans);
		ans %= mod;
	}
	p(ans);

	
	/*
	for(ll i=0;i<=n;i++){
		for(ll j=0;j<=n;j++){
			pe(ban[i][j]);
		}
		el;
	}
	for(ll i=0;i<=n;i++){
		for(ll j=0;j<=n;j++){
			pe(dp[i][j]);
		}
		el;
	}
	*/
	



    return 0;
}






Measured memory_bytes: 139776