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

using ll = long long;

const int MAXN = 3010;
int N, M;
char S[MAXN];
int pref[MAXN];

int to[MAXN];
ll dp[MAXN][MAXN];

const ll MOD = 1e9 + 7;

int main() {
	scanf("%d %d", &N, &M);
	scanf("%s", S);
	for (int i = 0; i < N; i++) {
		pref[i+1] = pref[i] + S[i] - '0';
	}

	for (int i = 0; i <= N; i++) {
		to[i] = i;
	}
	for (int i = 0; i < M; i++) {
		int l, r;
		scanf("%d %d", &l, &r);
		to[l] = max(r, to[l]);
	}
	for (int i = 1; i <= N; i++) {
		to[i] = max(to[i], to[i-1]);
	}

	dp[0][0] = 1;
	for (int i = 0; i < N; i++) {
		int add = pref[to[i+1]] - pref[to[i]];
		for (int j = 0; j <= N; j++) {
			int newj = j + add;
			if (newj > 0) {
				dp[i+1][newj-1] = (dp[i+1][newj-1] + dp[i][j]) % MOD;
			}
			if (to[i+1] - i - newj > 0) {
				dp[i+1][newj] = (dp[i+1][newj] + dp[i][j]) % MOD;
			}
		}
	}

	printf("%lld\n", dp[N][0]);
}