#include <bits/stdc++.h>
using namespace std;

const int mo=int(1e9+7);
int n,m,r[3010],sum[3010],f[3010][3010];
char s[3010];

void work()
{
	scanf("%d %d\n%s",&n,&m,s+1);
	for (int i=1; i<=n; i++)  sum[i]=sum[i-1]+(s[i]=='1'),r[i]=i;
	for (int i=1,x,y; i<=m; i++)  scanf("%d %d",&x,&y),r[x]=max(r[x],y);
	for (int i=1; i<=n; i++)  r[i]=max(r[i],r[i-1]);
	f[0][0]=1;
	for (int i=1; i<=n; i++)
		for (int j=0; j<=sum[r[i-1]]; j++)
			if (f[i-1][j])
				{
					if (sum[r[i]]>j)  f[i][j+1]=(f[i][j+1]+f[i-1][j])%mo;
					if (sum[r[i]]-j<r[i]-i+1)  f[i][j]=(f[i][j]+f[i-1][j])%mo;
				}
	printf("%d",f[n][sum[n]]);
}

int main()
{
	work();
	return 0;
}
