program shuffling
  implicit none
  integer(8), parameter :: md = 1000000007_8
  integer :: n, m, i, j, k, l, r, x(0:3001) = 0, c(0:3001) = 0
  character(3001) :: s
  integer(8) :: dp(0:3001,0:3001) = 0_8
  read(*,*) n, m
  read(*,*) s
  s(n+1:n+1) = "0"
  do i = 1, m
    read(*,*) l, r
    x(l) = max(x(l),r)
  end do
  do i = 1, n+1
    x(i) = max(x(i-1),x(i),i)
    c(i) = c(i-1)+ichar(s(i:i))-48
  end do
  dp(1,c(x(1))) = 1_8
  do i = 1, n
    k = c(x(i+1))-c(x(i))
    dp(i+1,k) = mod(dp(i+1,k)+dp(i,0),md)
    do j = 1, n-k
      dp(i+1,k+j-1) = mod(dp(i+1,k+j-1)+dp(i,j),md)
      if (x(i)-i >= j) dp(i+1,k+j) = mod(dp(i+1,k+j)+dp(i,j),md)
    end do
  end do
  write(*,'(i0)') dp(n+1,0)
end program shuffling