#define X first
#define Y second
#include<bits/stdc++.h>
using namespace std;
typedef pair <int, int > ii;
using ll = long long;
const int MAX=3005,inf=0x3f3f3f3f,mod=1e9+7;
int a[MAX],b[MAX];
ll f[MAX][MAX];
int n,m;
char s[MAX];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("bao.inp","r",stdin);
    //freopen("ESCAPE.out","w",stdout);
    int T;
    cin>>n>>m;
    cin>>s+1;
    for(int i=1;i<=n;i++) {
            b[i]=i;
        a[i]=a[i-1]+s[i]-'0';
    }


    for(int i=1,x,y;i<=m;i++){
        cin>>x>>y;
        b[x]=max(b[x],y);
    }
    f[0][0]=1;
    for(int i=1,now;i<=n;i++){
        b[i]=max(b[i],b[i-1]);
        if(a[b[i]]-0 < b[i]-i+1 )  f[i][0]=f[i-1][0];
        for(int j=1;j<=i;j++){
            if(a[b[i]]-j < b[i]-i+1 ) f[i][j]=f[i-1][j];
            if(a[b[i]]-j >= 0 ) f[i][j]+=f[i-1][j-1];
            if(f[i][j]>=mod) f[i][j]-=mod;
            //cout<<i<<' '<<j<<' '<<f[i][j]<<'\n';
        }
    }
    ll ans=0;
    for(int i=0;i<=n;i++){
        ans+=f[n][i];if(ans>=mod) ans-=mod;
    }
    cout<<ans;
}
