#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<map>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const int mod=1000000007;
const llint big=1e18+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-9;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}//a>b
template <uint64_t MOD_ = 1000000007>
class mint_base
{
public:
	static constexpr auto MOD = MOD_;
	constexpr mint_base<MOD> operator+(const mint_base<MOD> &other)const noexcept
	{auto v = *this;return v += other;}
	constexpr mint_base<MOD> operator-(const mint_base<MOD> &other)const noexcept
	{auto v = *this;return v -= other;}
	constexpr mint_base<MOD> operator*(const mint_base<MOD> &other)const noexcept
	{auto v = *this;return v *= other;}
	constexpr mint_base<MOD>& operator+=(const mint_base<MOD> &other) noexcept
	{a += other.a;if (MOD <= a) { a -= MOD; };return *this;}
	constexpr mint_base<MOD>& operator-=(const mint_base<MOD> &other) noexcept
	{if (a >= other.a) {a -= other.a;}else {a = (a + MOD) - other.a;}return *this;}
	constexpr mint_base<MOD>& operator*=(const mint_base<MOD> &other) noexcept
	{a *= other.a;a %= MOD;return *this;}
	constexpr mint_base<MOD> operator+()const noexcept { return *this; }
	constexpr mint_base<MOD> operator-()const noexcept
	{return{ MOD - a, mod_value_tag{} };}
	constexpr mint_base<MOD>& operator++() noexcept
	{if (MOD <= ++a) { a = 0; };return *this;}
	constexpr mint_base<MOD>& operator--() noexcept
	{if (a <= 0) { a = MOD; };--a;return *this;}
	constexpr mint_base<MOD> operator++(int) noexcept
	{auto tmp = *this;++*this;return tmp;}
	constexpr mint_base<MOD> operator--(int) noexcept
	{auto tmp = *this;--*this;return tmp;}
	constexpr mint_base<MOD>& operator=(const mint_base<MOD> &other) noexcept
	{a = other.a;return *this;}
	constexpr operator uint64_t()const noexcept
	{return a;}
	constexpr explicit operator unsigned()const noexcept
	{return (unsigned)a;}
	static constexpr uint64_t getmod() noexcept
	{return MOD;}
	constexpr mint_base(uint64_t a_) noexcept :a(a_ % MOD) {}
	constexpr mint_base()noexcept : a(0) {}
	struct mod_value_tag {};
	constexpr mint_base(uint64_t a_, mod_value_tag) :a(a_) {}
private:
	uint64_t a;
};
//mint_base型のstreamへの出力
template<uint64_t MOD> std::ostream& operator<<(std::ostream& os, mint_base<MOD> i)
{os << (uint64_t)i;return os;}
//mint_base型のstreamからの入力
template<uint64_t MOD> std::istream& operator >> (std::istream& is, mint_base<MOD>& i)
{uint64_t tmp;is >> tmp;i = tmp;return is;}

int main(void){
	int i,j,k,n,m;cin>>n>>m;
	string str;cin>>str;
	vector<mint_base<mod>>ans(n+1);//1を持つ数
	ans[0]=1;
	vector<int>doco(n);//どこまでのものをとれるか
	vector<int>ika(n);//1の数
	vector<int>oka(n);//0の数
	for(i=0;i<m;i++){
		int l,r;cin>>l>>r;l--;r--;
		maxeq(doco[l],r);
	}
	for(i=1;i<n;i++){
		maxeq(doco[i],doco[i-1]);
		maxeq(doco[i],i);
	}
	int iwa=0,owa=0;
	for(i=0;i<n;i++){
		if(str[i]=='1'){iwa++;}else{owa++;}
		ika[i]=iwa;
		oka[i]=owa;
	}
	for(i=0;i<n;i++){ika[i]=ika[doco[i]],oka[i]=oka[doco[i]];}
	vector<mint_base<mod>>dp(n+1);
	for(i=0;i<n;i++){
		for(j=0;j<n+1;j++){dp[j]=0;}
		for(j=max(0,i+1-oka[i]);j<=min(n,ika[i]);j++){
			if(j!=0){dp[j]=ans[j-1]+ans[j];}
			else{dp[j]=ans[j];}
		}
		swap(dp,ans);
	}
	cout<<ans[ika[n-1]]<<endl;
	return 0;
}

Measured memory_bytes: 384