module modulo_util
  implicit none
  integer(8), parameter :: md = 1000000007_8
  integer(8), allocatable :: f(:), invf(:)
contains
  subroutine init(n)
    integer, intent(in) :: n
    integer :: i
    if (allocated(f)) deallocate(f)
    if (allocated(invf)) deallocate(invf)
    allocate(f(0:n),invf(0:n))
    f = 0_8
    invf = 0_8
    f(0) = 1_8
    do i = 1, n
      f(i) = mod(f(i-1)*int(i,8),md)
    end do
    invf(n) = inv(f(n))
    do i = n, 1, -1
      invf(i-1) = mod(invf(i)*int(i,8),md)
    end do
  end
  integer(8) function perm(n,k)
    integer, intent(in) :: n, k
    perm = 0_8
    if (k > n .or. n < 0 .or. k < 0) return
    perm = mod(f(n)*invf(n-k),md)
  end
  integer(8) function comb(n,k)
    integer, intent(in) :: n, k
    comb = mod(perm(n,k)*invf(k),md)
  end
  integer(8) function homo(n,k)
    integer, intent(in) :: n, k
    homo = 1_8
    if (n == 0 .and. k == 0) return
    homo = comb(n+k-1,k)
  end
  function inv(n) result(y)
    integer(8), intent(in) :: n
    integer(8) :: a, b, x, y, t, q
    a = mod(n,md)
    b = md
    x = 0_8
    y = 1_8
    do while (b /= 0_8)
      q = a/b
      t = b
      b = mod(a,b)
      a = t
      t = y
      y = x
      x = t-q*x
    end do
    y = mod(mod(y,md)+md,md)
  end
  function pow(a,b) result(r)
    integer(8), intent(in) :: a
    integer, intent(in) :: b
    integer :: i
    integer(8) :: r, p
    r = 1_8
    p = a
    do i = 0, 32
      if (btest(b,i)) r = mod(r*p,md)
      p = mod(p*p,md)
    end do
  end
end module modulo_util
program shuffling
  use modulo_util
  implicit none
  integer :: n, m, u = 0, ll, rr, i, j
  integer, dimension(0:3000) :: l = 0, r = 0, c = 0
  character(3000) :: s
  integer(8) :: ans = 1_8
  read(*,*) n, m
  call init(n)
  read(*,*) s
  do i = 1, n
    c(i) = c(i-1)+ichar(s(i:i))-48
  end do
  do i = 1, m
    read(*,*) ll, rr
    if (rr <= r(u)) cycle
    u = u+1
    l(u) = ll
    r(u) = rr
  end do
  i = 1
  do while (i <= u)
    j = i
    do while (j < u .and. l(j+1) <= r(j))
      j = j+1
    end do
    ans = mod(ans*solve(l(i:j),r(i:j),1,0),md)
    i = j+1
  end do
  write(*,'(i0)') ans+1_8
contains
  recursive function solve(l,r,i,d) result(ret)
    implicit none
    integer, intent(in) :: l(:), r(:), i, d
    integer :: j, x
    integer(8) :: ret
    if (i == 1) then
      x = c(r(i))-c(l(i)-1)
    else
      x = d+c(r(i))-c(r(i-1))
    end if
    if (i == size(l)) then
      ret = comb(r(i)-l(i)+1,x)
      return
    end if
    ret = 0_8
    do j = max(0,x-(r(i+1)-l(i)+1)), min(x,r(i)-l(i+1)+1)
      ret = ret+mod(solve(l,r,i+1,j)*comb(l(i+1)-l(i),x-j),md)
    end do
    ret = mod(ret,md)
  end
end program shuffling