#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=3030;

const int32_t M=1e9+7;
int32_t rev(int32_t x,int32_t m){
    if(x==1)return 1;
    return (1-(ll)rev(m%x,x)*m)/x+m;
}
struct mint{
    int32_t x;
    mint():x(0){}
    mint(int32_t xx):x(xx%M){if(x<0)x+=M;}
    mint(ll xx):x(xx%M){if(x<0)x+=M;}
    mint& operator+=(mint b){if((x+=b.x)>=M)x-=M;return *this;}
    mint operator+(mint b){mint res=*this;res+=b;return res;}
    mint& operator-=(mint b){if((x-=b.x)<0)x+=M;return *this;}
    mint operator-(mint b){mint res=*this;res-=b;return res;}
    mint& operator*=(mint b){x=(ll)x*b.x%M;return *this;}
    mint operator*(mint b){mint res=*this;res*=b;return res;}
    mint inverse(){return rev(x,M);}
    mint& operator/=(mint b){x=(ll)x*rev(b.x,M)%M;return *this;}
    mint operator/(mint b){mint res=*this;res/=b;return res;}
    mint operator^(ll w) {mint r=1,a=*this;while(w){if(w&1)r*=a;a*=a;w/=2;}return r;}
    mint operator^=(ll w){return *this=(*this)^w;}
    mint operator^(mint w){return *this^w.x;}
    mint operator^=(mint w){return *this=(*this)^w;}
    mint operator-()const{return mint()-*this;}
    explicit operator bool()const{return x;}
};
istream&operator>>(istream&is,mint&p){istream&res=is>>p.x;p.x%=M;return res;}
ostream&operator<<(ostream&os,mint p){return os<<p.x;}
template<typename T>mint operator+(T x,mint y){return mint(x)+y;}
template<typename T>mint operator-(T x,mint y){return mint(x)-y;}
template<typename T>mint operator*(T x,mint y){return mint(x)*y;}
template<typename T>mint operator/(T x,mint y){return mint(x)/y;}
template<typename T>mint operator^(T x,mint y){return mint(x)^y;}
mint abs(mint x){return x;}
mint fc[N],ifc[N];
struct pc{pc(){
        fc[0]=1;
        for(int i=1;i<N;++i)fc[i]=fc[i-1]*i;
        ifc[N-1]=1/fc[N-1];
        for(int i=N-2;i>=0;--i)ifc[i]=ifc[i+1]*(i+1);
}}pc;
mint bin(int n,int k){
    if(k<0||k>n)return 0;
    return fc[n]*ifc[k]*ifc[n-k];
}
mint dp[N],ndp[N];
int p0[N]/*,p1[N]*/;
int get0(int l,int r){return p0[r]-p0[l-1];}
// int get1(int l,int r){return p1[r]-p1[l-1];}
int32_t main(){
    int n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    s="#"+s;
    for(int i=1;i<=n;++i)p0[i]=p0[i-1]+(s[i]=='0');
    int pl=-1,pm=-1,pr=-1,pmna=-1,pmxa=-1;
    forn(t,q){
        int l,r;
        cin>>l>>r;
        if(r<=pr)continue;
        forn(i,n+1)ndp[i]=0;
        // memset(ndp,0,sizeof ndp);
        if(l>pr){
            if(pl!=-1){
                int len=pr-pl+1;
                int b0=get0(pm+1,pr);
                mint cur=0;
                for(int a0=pmna;a0<=pmxa;++a0){
                    cur+=bin(len,b0+a0)*dp[a0];
                }
                ndp[0]=cur;
            }else{
                ndp[0]=1;
            }
            pl=l,pm=l-1,pr=r,pmna=pmxa=0;
        }else{
            int m=pr;
            int b0=get0(pm+1,pr);
            for(int c0=0;c0<=m-l+1;++c0){
                // dbg(c0,b0,l-pl);
                for(int a0=pmna;a0<=pmxa;++a0){
                    ndp[c0]+=bin(l-pl,a0+b0-c0)*dp[a0];
                }
            }
            pl=l,pm=m,pr=r,pmna=0,pmxa=m-l+1;
        }
        memcpy(dp,ndp,sizeof dp);
        // for(int i=pmna;i<=pmxa;++i){
        //     dbg(dp[i]);
        // }
        // dbg("====");
    }
    mint cur=0;
    int len=pr-pl+1;
    int b0=get0(pm+1,pr);
    for(int a0=pmna;a0<=pmxa;++a0){
        cur+=bin(len,b0+a0)*dp[a0];
    }
    cout<<cur<<'\n';

    return 0;
}

Measured memory_bytes: 3708