// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1001001001;
const ll LONGINF = 1001001001001001LL;
const ll MOD = 1000000007LL;

// ModInt begin

using ll = long long;
template<ll mod>
struct ModInt {
    ll v;
    ll mod_pow(ll x, ll n) const {
        return (!n) ? 1 : (mod_pow((x*x)%mod,n/2) * ((n&1)?x:1)) % mod;
    }
    ModInt(ll a = 0) : v((a %= mod) < 0 ? a + mod : a) {}
    ModInt operator+ ( const ModInt& b ) const {
        return (v + b.v >= mod ? ModInt(v + b.v - mod) : ModInt(v + b.v));
    }
    ModInt operator- () const {
        return ModInt(-v);
    }
    ModInt operator- ( const ModInt& b ) const {
        return (v - b.v < 0 ? ModInt(v - b.v + mod) : ModInt(v - b.v));
    }
    ModInt operator* ( const ModInt& b ) const {return (v * b.v) % mod;}
    ModInt operator/ ( const ModInt& b ) const {return (v * mod_pow(b.v, mod-2)) % mod;}
    
    bool operator== ( const ModInt &b ) const {return v == b.v;}
    bool operator!= ( const ModInt &b ) const {return !(*this == b); }
    ModInt& operator+= ( const ModInt &b ) {
        v += b.v;
        if(v >= mod) v -= mod;
        return *this;
    }
    ModInt& operator-= ( const ModInt &b ) {
        v -= b.v;
        if(v < 0) v += mod;
        return *this;
    }
    ModInt& operator*= ( const ModInt &b ) {
        (v *= b.v) %= mod;
        return *this;
    }
    ModInt& operator/= ( const ModInt &b ) {
        (v *= mod_pow(b.v, mod-2)) %= mod;
        return *this;
    }
    ModInt pow(ll x) { return ModInt(mod_pow(v, x)); }
    // operator int() const { return int(v); }
    // operator long long int() const { return v; }
};

template<ll mod>
ostream& operator<< (ostream& out, ModInt<mod> a) {return out << a.v;}
template<ll mod>
istream& operator>> (istream& in, ModInt<mod>& a) {
    in >> a.v;
    return in;
}

// ModInt end

using mint = ModInt<MOD>;
mint dp[3010][3010];

int main() {
    int N, M; cin >> N >> M;
    string s; cin >> s;

    vector<int> acc(N+1);
    for(int i=0; i<N; i++) {
        acc[i+1] = acc[i] + (s[i] == '1');
    }

    vector<int> query(N, -1);
    for(int i=0; i<M; i++) {
        int l, r; cin >> l >> r; l--;
        chmax(query[l], r);
    }

    int acc_max = 0;
    dp[0][0] = mint(1);
    for(int i=0; i<=N; i++) {
        for(int j=0; j<=i; j++) {
            if(dp[i][j].v == 0) continue;
            // fprintf(stderr, "dp[%d][%d] = %lld\n", i, j, dp[i][j].v);
        }
        if(i >= N) continue;
        
        chmax(acc_max, query[i]);
        
        // 今までのクエリの累積 max が i を含んでない
        // i 番目に関係するクエリは存在しないのでのばすだけ
        if(acc_max <= i) {
            for(int j=0; j<=i; j++) {
                int nj = j + (s[i] == '1');
                if(acc[i+1] >= nj) dp[i+1][nj] += dp[i][j];
            }
        }
        else {
            // 使用可能な 1 (cnt1) は acc[acc_max] - j 個
            // 使用可能な 0 (cnt0) は acc_max - i - cnt1 個
            for(int j=0; j<=i; j++) {
                int cnt1 = acc[acc_max] - j;
                int cnt0 = acc_max - i - cnt1;
                if(cnt1 < 0 or cnt0 < 0) continue;

                if(cnt1) dp[i+1][j+1] += dp[i][j];
                if(cnt0) dp[i+1][j  ] += dp[i][j];
            }
        }
    }

    cout << dp[N][ acc[N] ] << endl;
    return 0;
}


Measured memory_bytes: 71040