#include <bits/stdc++.h>

using namespace std;

const int N = 3030;
const int mod = 1e9 + 7;

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

int n, m;
char s[N];
int go[N];
int f[N][N];

int main() {
   scanf("%d %d %s", &n, &m, s + 1);
   for (int i = 1; i <= n; ++i) {
      go[i] = i;
   }
   for (int i = 0; i < m; ++i) {
      int l, r;
      scanf("%d %d", &l, &r);
      go[l] = max(go[l], r);
   }
   for (int i = 1; i <= n; ++i) {
      go[i] = max(go[i], go[i - 1]);
   }
   f[0][0] = 1;
   for (int i = 1; i <= n; ++i) {
      int ad = 0;
      for (int j = go[i - 1] + 1; j <= go[i]; ++j) {
         ad += (s[j] - '0');
      }
      for (int j = 0; j <= n; ++j) {
         if (!f[i - 1][j]) continue;
         if ((j + ad)) {
            add(f[i][j + ad - 1], f[i - 1][j]);
         }
         if (go[i] - i + 1 - (j + ad)) {
            add(f[i][j + ad], f[i - 1][j]);
         }
      }
   }
   printf("%d\n", f[n][0]);
}
