#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 3030;
typedef long long ll;
const int mod = 1e9 + 7;
inline void reduce(int & x) {
	x += x >> 31 & mod;
}
int n, m;
char c[maxn];
int max[maxn], s[maxn];
int f[maxn][maxn];
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	rep(i, 1, n) {
		cin >> c[i];
		s[i] = s[i - 1] + c[i] % 2;
		max[i] = i;
	}
	rep(i, 1, m) {
		int l, r;
		cin >> l >> r;
		max[l] = std::max(max[l], r);
	}
	f[1][s[max[1]]] = 1;
	rep(i, 1, n) {
		max[i + 1] = std::max(max[i + 1], max[i]);
		int lol = s[max[i + 1]] - s[max[i]];
		rep(j, 0, n) {
			if(j != 0) { 
				reduce(f[i + 1][j + lol - 1] += f[i][j] - mod);
			}
			if(i + j - 1 != max[i]) {
				reduce(f[i + 1][j + lol] += f[i][j] - mod);
			}
		}
	}
	cout << f[n + 1][0] << '\n';
}
