#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>

using namespace std;
typedef long long ll;
typedef pair<int,int> Pi;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) x.begin(), x.end()

const int MOD = 1e9 + 7;
int D[4040][4040];

void solve(){
	int n, m; scanf("%d%d", &n, &m);
	char S[2][3030];
	scanf("%s", S[0]+1);
	for(int i=1;i<=n;i++)S[1][i] = S[0][i];
	rep(i, m){
		int x, y; scanf("%d%d", &x, &y);
		sort(S[0]+x, S[0]+y+1);
		sort(S[1]+x, S[1]+y+1, [](int x,int y){return x > y;});
	}
	int s[2][4040] = {};
	rep(u, 2)for(int i=1;i<=n;i++)s[u][i] = s[u][i-1] + (S[u][i] == '1');
	D[0][0] = 1;
	for(int i=1;i<=n;i++){
		for(int j=s[0][i];j<=s[1][i];j++)D[i][j] = ((j?D[i-1][j-1]:0) + D[i-1][j]) % MOD;
	}
	printf("%d", D[n][s[0][n]]);
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}