#include <bits/stdc++.h>

#define For(i, j, k) for(int i = j; i <= k; i++)

using namespace std;

const int N = 3010;
const int Mod = 1e9 + 7;

void add(int &x, int y){
	x += y;
	if(x >= Mod) x -= Mod;
}

int dp[N][N];
int n, m;
int L[N], sum[N], R[N];
char S[N];

int main(){
	scanf("%d%d", &n, &m);
	scanf("%s", S + 1);
	For(i, 1, n) sum[i] = sum[i - 1] + (S[i] == '1');
	For(i, 1, m) scanf("%d%d", &L[i], &R[i]);

	dp[0][0] = 1;
	int p = 1, mx = 0;
	For(i, 1, n){
		mx = max(mx, i);
		while(p <= m && L[p] == i){
			mx = max(mx, R[p]);
			++p;
		}

		For(j, 0, i - 1){
			int v = dp[i - 1][j];
			if(!v) continue;
			if(j + 1 <= sum[mx]) add(dp[i][j + 1], v);
			if(i - j <= mx - sum[mx]) add(dp[i][j], v);
		}
	}
	printf("%d\n", dp[n][sum[n]]);
	return 0;
}