#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<set>
#define SF scanf
#define PF printf
#define MAXN 3010
#define MOD 1000000007
using namespace std;
typedef long long ll;
ll dp[MAXN][MAXN];
int n,m;
char s[MAXN];
int endx[MAXN],pre[MAXN];
int main(){
	SF("%d%d",&n,&m);
	SF("%s",s+1);
	for(int i=1;i<=n+1;i++)
		pre[i]=pre[i-1]+(s[i]=='1');
	int las=1;
	int u,v;
	for(int i=1;i<=n+1;i++)
		endx[i]=max(endx[i],i);
	for(int i=1;i<=m;i++){
		SF("%d%d",&u,&v);	
		endx[u]=max(endx[u],v);
	}
	for(int i=1;i<=n+1;i++)
		endx[i]=max(endx[i],endx[i-1]);
	dp[1][pre[endx[1]]]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=n;j++)
			if(dp[i][j]){
				int l=endx[i];
				int r=endx[i+1];
				int one=j;
				int zero=endx[i]-i+1-j;
				if(zero)
					(dp[i+1][j+pre[r]-pre[l]]+=dp[i][j])%=MOD;
				if(one)
					(dp[i+1][j-1+pre[r]-pre[l]]+=dp[i][j])%=MOD;
			}
	PF("%lld",dp[n+1][0]);
}