Problem: There is a string S of length N consisting of characters `0` and `1`. You will perform the following operation for each i = 1, 2, ..., m:

* Arbitrarily permute the characters within the substring of S starting at the l_i-th character from the left and extending through the r_i-th character.



Here, the sequence l_i is non-decreasing.

How many values are possible for S after the M operations, modulo 1000000007(= 10^9+7)?

Constraints

* 2≦N≦3000
* 1≦M≦3000
* S consists of characters `0` and `1`.
* The length of S equals N.
* 1≦l_i < r_i≦N
* l_i ≦ l_{i+1}

Input

The input is given from Standard Input in the following format:


N M
S
l_1 r_1
:
l_M r_M


Output

Print the number of the possible values for S after the M operations, modulo 1000000007.

Examples

Input

5 2
01001
2 4
3 5


Output

6


Input

9 3
110111110
1 4
4 6
6 9


Output

26


Input

11 6
00101000110
2 4
2 3
4 7
5 6
6 10
10 11


Output

143

Solution (in JAVA):

Solution:
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by zzt on 17-1-26.
 */
public class Main {

    private static int n, m;
    private static char[] chars;
    private static int[] l, r, newR, sum;
    private static long[][] dp;
    private static final int MOD = (int) (1e9 + 7);

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        m = scanner.nextInt();
        chars = scanner.next().toCharArray();

        l = new int[m];
        r = new int[m];

        for (int i = 0; i < m; i++) {
            l[i] = scanner.nextInt() - 1;
            r[i] = scanner.nextInt() - 1;
        }
        newR = new int[n + 1];
        for (int i = 0; i < n; i++) {
            newR[i] = i;
        }
        for (int i = 0; i < m; i++) {
            newR[l[i]] = Math.max(newR[l[i]], r[i]);
        }
        for (int i = 1; i < n; i++) {
            newR[i] = Math.max(newR[i], newR[i - 1]);
        }
        sum = new int[n];
        for (int i = 0; i < n; i++) {
            sum[i] = chars[i] - '0';
        }
        for (int i = 0; i < n - 1; i++) {
            sum[i + 1] += sum[i];
        }
        dp = new long[n + 1][n + 1];
        for (int i = 0; i < n + 1; i++) {
            Arrays.fill(dp[i], -1);
        }
        System.out.println(dfs(0, newR[0], sum[newR[0]]));
    }

    static long dfs(int L, int R, int c) {
        if (L == n)
            return 1;
        if (dp[L][c] != -1)
            return dp[L][c];
        long ret = 0;
        int add = 0;
        if (R < newR[L + 1])
            add = sum[newR[L + 1]] - sum[R];
        if (c > 0)
            ret += dfs(L + 1, newR[L + 1], c - 1 + add) % MOD;
        if (c < R - L + 1) {
            ret += dfs(L + 1, newR[L + 1], c + add) % MOD;
        }
        ret %= MOD;
        return dp[L][c] = ret;
    }
}