/* -------------------------------- Template -------------------------------- */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }

// template<typename T> constexpr T inf = [](){ assert(false); };
// template<> constexpr int inf<int> = 1e9;
// template<> constexpr ll inf<ll> = 1e18;
// template<> constexpr ld inf<ld> = 1e30;

struct yes_no : std::numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};

void solve();

int main() {
  std::locale loc(std::locale(), new yes_no);
  std::cout << std::boolalpha << std::setprecision(12) << std::fixed;
  std::cout.imbue(loc);
  solve();
  return 0;
}

using namespace std;

/* -------------------------------- Library -------------------------------- */

template<int M, bool IsPrime = false>
class Modulo {
  using ll = long long;
  int n;
  static enable_if_t<IsPrime, ll> inv(ll a, ll p) {
    return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
  }
public:
  Modulo () : n(0) {;}
  Modulo (int m) : n(m) {
    if (n >= M) n %= M;
    else if (n < 0) n = (n % M + M) % M;
  }
  Modulo (ll m) {
    if (m >= M) m %= M;
    else if (m < 0) m = (m % M + M) % M;
    n = m;
  }
  explicit operator int() const { return n; }
  explicit operator ll() const { return n; }
  bool operator==(const Modulo &a) const { return n == a.n; }
  Modulo operator+=(const Modulo &a) { n += a.n; if (n >= M) n -= M; return *this; }
  Modulo operator-=(const Modulo &a) { n -= a.n; if (n < 0) n += M; return *this; }
  Modulo operator*=(const Modulo &a) { n = (ll(n) * a.n) % M; return *this; }
  Modulo operator+(const Modulo &a) const { Modulo res = *this; return res += a; }
  Modulo operator-(const Modulo &a) const { Modulo res = *this; return res -= a; }
  Modulo operator*(const Modulo &a) const { Modulo res = *this; return res *= a; }
  Modulo operator^(int n) const {
    if (n == 0) return Modulo(1);
    const Modulo a = *this;
    Modulo res = (a * a) ^ (n / 2);
    return n % 2 ? res * a : res;
  }
  enable_if_t<IsPrime, Modulo> operator/(const Modulo &a) const {
    return *this * inv(ll(a), M);
  }
};

template<int M> Modulo<M, true> fact(int n, bool sw = true) {
  static vector<Modulo<M, true>> v1 = {1}, v2 = {1};
  if (n >= (int)v1.size()) {
    const int from = v1.size(), to = n + 1024;
    v1.reserve(to);
    v2.reserve(to);
    for (int i = from; i < to; ++i) {
      v1.push_back(v1.back() * Modulo<M, true>(i));
      v2.push_back(v2.back() / Modulo<M, true>(i));
    }
  }
  return sw ? v1[n] : v2[n];
}

template<int M> Modulo<M, true> comb(int a, int b) {
  if (b < 0 || b > a) return fact<M>(0);
  return fact<M>(a, true) * fact<M>(b, false) * fact<M>(a-b, false);
}

const int mod = 1000000007;
using Mod = Modulo<mod, true>;

/* ---------------------------------- Main ---------------------------------- */

int l[4000], r[4000];
int le[4000], ri[4000];
int le2[4000], ri2[4000];

Mod dp[3010][3010];

void solve() {
  int N, M;
  string s;
  cin >> N >> M;
  cin >> s;
  REP(i,M) { cin >> l[i] >> r[i]; --l[i]; }
  int P = 0, Q = 0;
  REP(i,N) {
    if (s[i] == '1') {
      le[P] = i;
      ri[P] = i + 1;
      ++P;
    }
    else {
      le2[Q] = i;
      ri2[Q] = i + 1;
      ++Q;
    }
  }
  // cout << P << endl;
  // REP(i,P) cout << le[i] << " " << ri[i] << endl;
  REP(i,P) REP(j,M) {
    if (l[j] < ri[i] && le[i] < r[j]) {
      chmin(le[i], l[j]);
      chmax(ri[i], r[j]);
    }
  }
  REP(i,Q) REP(j,M) {
    if (l[j] < ri2[i] && le2[i] < r[j]) {
      chmin(le2[i], l[j]);
      chmax(ri2[i], r[j]);
    }
  }
  // cout << P << endl;
  // REP(i,P) cout << le[i] << " " << ri[i] << endl;
  // cout << Q << endl;
  // REP(i,Q) cout << le2[i] << " " << ri2[i] << endl;
  dp[0][0] = 1;
  REP(i,N) REP(j,P+1) {
    int k = i - j;
    if (k < 0) continue;
    if (k > Q) continue;
    if (j < P && le[j] <= i && i < ri[j])
      dp[i+1][j+1] += dp[i][j];
    if (k < Q && le2[k] <= i && i < ri2[k])
      dp[i+1][j] += dp[i][j];
    // if (j == 0) cout << endl;
    // cout << int(dp[i][j]) << " ";
    // cout << i << " " << j << " " << k << " " << int(dp[i][j]) << endl;
  }
  // cout << endl;
  cout << int(dp[N][P]) << endl;
  return;
}


Measured memory_bytes: 35712