// #includes {{{
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <cmath>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair
//#define PB push_back
#define CLEAR(c,d) memset((c),(d),sizeof(c))
#define TO_STRING(VariableName) # VariableName
//#define DB(c) cout<<TO_STRING(c)<<"="<<(c)<<endl

#define EXIST(e,s) ((s).find(e)!=(s).end())
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

typedef pair<int,int> pii;
//{{{ io
struct IO{ }io;//dummy
#define endl "\n"
IO& operator>>(IO &io,int &n){scanf("%d",&n);return io;}
IO& operator>>(IO &io,unsigned int &n){scanf("%u",&n);return io;}
IO& operator>>(IO &io,long long &n){scanf("%lld",&n);return io;}
IO& operator>>(IO &io,unsigned long long &n){scanf("%llu",&n);return io;}
IO& operator>>(IO &io,double &n){scanf("%lf",&n);return io;}
IO& operator>>(IO &io,long double &n){scanf("%Lf",&n);return io;}
IO& operator>>(IO &io,char *c){scanf("%s",c);return io;}
IO& operator>>(IO &io,string &s){
    char c;s.clear();
    while(isspace(c=getc(stdin))){if(c==-1)return io;}
    do{
        s.push_back(c);
    }while(!isspace(c=getc(stdin)));
    if(c!=-1)ungetc(c,stdin);
    return io;
}
IO& operator<<(IO &io,const int &n){printf("%d",n);return io;}
IO& operator<<(IO &io,const unsigned int &n){printf("%u",n);return io;}
IO& operator<<(IO &io,const long long &n){printf("%lld",n);return io;}
IO& operator<<(IO &io,const unsigned long long &n){printf("%llu",n);return io;}
IO& operator<<(IO &io,const double &n){printf("%lf",n);return io;}
IO& operator<<(IO &io,const long double &n){printf("%Lf",n);return io;}
IO& operator<<(IO &io,const char c[]){printf("%s",c);return io;}
IO& operator<<(IO &io,const string &s){
    REP(i,s.size())putc(s[i],stdout);
}
//}}}
// }}}

const int mod = 1000000007;

int N,M;
string S;
int zero_ct[3005], one_ct[3005];
vector<pair<int,int> > p;

int dp[3005][3005];

int main(){
	cin>>N>>M;
	cin>>S;
	assert(N==S.size());
	int o=0,z=0;
	REP(i,N){
		zero_ct[i] = z;
		one_ct[i] = o;
//		cout<<one_ct[i]<<" ";
		if(S[i]=='1')o++;
		else z++;
	}
	zero_ct[N] = z;
	one_ct[N] = o;
//	cout<<one_ct[N]<<endl;

	int right = 0;
	REP(i,M){
		int l,r;
		cin>>l>>r;
		l--;
		if(r<=right)continue;
		p.push_back(make_pair(l,r));
		right = r;
		//		cout<<l<<" "<<r<<endl;
	}
	memset(dp,0,sizeof(dp));
	REP(j,S.size()+1){
		dp[0][j] = (j==0)?1:0;
	}
	REP(i,N){
		int j=0;
		REP(k,S.size()+1){
			while(1){
				int j2 = j+1;
				if(j2<p.size() and p[j2].first<=i)j=j2;
				else break;
			}
			// decide dp[i+1][k]
			int num_zero = i-k;
			if(num_zero<0){
//				dp[i+1][k] = 0;
				continue;
			}
			bool zero = false, one = false;
			if(i<p[j].first or p[j].second<=i){
				if(S[i]=='0')zero = true;
				else one = true;
			}else{
				if(num_zero<zero_ct[p[j].second])zero = true;
				if(k<one_ct[p[j].second])one = true;
			}
			if(zero){
//				if(i==3)cout<<"zero: "<<i<<" "<<k<<" "<<dp[i][k]<<endl;
				dp[i+1][k] += dp[i][k];
				if(dp[i+1][k]>=mod)dp[i+1][k]-=mod;
			}
			if(one){
//				if(i==3)cout<<"one: "<<i<<" "<<k<<endl;
				dp[i+1][k+1] += dp[i][k];
				if(dp[i+1][k+1]>=mod)dp[i+1][k+1]-=mod;
			}
//			cout<<dp[i+1][k]<<" ";
		}
//		cout<<endl;
	}
	cout<<dp[N][one_ct[N]]<<endl;

	return 0;
}


Measured memory_bytes: 35584