#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define int long long

using namespace std;

typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 6005;

ll inv[MAX_N],fac[MAX_N],finv[MAX_N];

void make()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2;i<MAX_N;i++){
		inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
		fac[i] = fac[i-1] * (ll) i % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
}

ll comb(int a,int b)
{
	if(a<b){
		return 0;
	}
	return fac[a] * (finv[b] * finv[a-b] % MOD) % MOD;
}

ll add(ll x,ll y)
{
    return (x + y)%MOD;
}

ll sub(ll x,ll y)
{
    return (x+MOD-y)%MOD;
}

ll mul(ll x,ll y)
{
    return x*y%MOD;
}

int s0[MAX_N];

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    string s;
    cin >> s;
    make();
    vp vec(m+1);
    rep(i,m){
        cin >> vec[i].fi >> vec[i].se;
        --vec[i].fi,--vec[i].se;
    }
    rep(i,n){
        if(s[i] == '0'){
            s0[i+1] = s0[i] + 1;
        }else{
            s0[i+1] = s0[i];
        }
    }
    int nw=0,l = vec[nw].fi,r = vec[nw].se;
    vp data;
    data.pb(P(s0[r+1]-s0[l],1));
    vec[m] = P(n,n);
    srep(i,1,m+1){
        if(vec[i].se <= r){
            continue;
        }
        if(r < vec[i].fi){
            ll val = 0;
            rep(j,len(data)){
                ll zero = data[j].fi;
                ll al = r-l+1;
                val = add(val,mul(data[j].se,comb(al,zero)));
            }
            nw = i,l = vec[nw].fi,r = vec[nw].se;
            vp hoge;
            hoge.pb(P(s0[r+1]-s0[l],val));
            data = hoge;
            continue;
        }
        //重なり
        int lm = r-vec[i].fi+1;
        //右の覆われていない部分の0の個数
        int sm = s0[vec[i].se+1] - s0[r+1];
        // cout << vec[i].se << " " << r << " " << sm << "\n";
        int mnn = max(data[0].fi-vec[i].fi+l,0LL);
        int mxx = min((data.back().fi),lm);
        vector<int> nx(mxx-mnn+1,0LL);
        rep(j,len(data)){
            int cnt = data[j].fi;
            int leng = vec[i].fi - l;
            int mn = max(cnt-leng,0LL);
            int mx = min(cnt,lm);
            srep(k,mn,mx+1){
                nx[k-mnn] = add(nx[k-mnn],mul(comb(leng,cnt-k),data[j].se));
            }
        }
        vp hoge;
        rep(j,len(nx)){
            if(nx[j]){
                hoge.pb(P(j+mnn+sm,nx[j]));
            }
        }
        data = hoge;
        nw = i,l = vec[nw].fi,r = vec[nw].se;
    }
    cout << data[0].se << "\n";
    return 0;
}


Measured memory_bytes: 512