#include<cstdio>
const int N=3005,mo=1e9+7;
int n,m,i,j,sum[N],r[N],f[N][N];char s[N];
void add(int &x,int k){x=(x+k)%mo;}
int main(){
	scanf("%d%d%s",&n,&m,s+1);s[n+1]='0';
	for (i=1;i<=n+1;i++)
		r[i]=i,sum[i]=sum[i-1]+s[i]-48;
	for (;m--;){
		int x,y;scanf("%d%d",&x,&y);
		if (y>r[x]) r[x]=y;
	}
	for (i=2;i<=n+1;i++)
		if (r[i-1]>r[i]) r[i]=r[i-1];
	f[1][sum[r[1]]]=1;
	for (i=1;i<=n;i++) for (j=0;j<=n;j++) if (f[i][j]){
		int k=sum[r[i+1]]-sum[r[i]];
		if (r[i]-i+1-j) add(f[i+1][j+k],f[i][j]);
		if (j) add(f[i+1][j+k-1],f[i][j]);
	}
	printf("%d",f[n+1][0]);
}