{"raw_statement":[{"iden":"problem statement","content":"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$:\n\n*   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.\n\nHere, the sequence $l_i$ is non-decreasing.\nHow many values are possible for $S$ after the $M$ operations, modulo $1000000007(= 10^9+7)$?"},{"iden":"constraints","content":"*   $2≦N≦3000$\n*   $1≦M≦3000$\n*   $S$ consists of characters `0` and `1`.\n*   The length of $S$ equals $N$.\n*   $1≦l_i < r_i≦N$\n*   $l_i ≦ l_{i+1}$"},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$N$ $M$\n$S$\n$l_1$ $r_1$\n:\n$l_M$ $r_M$"},{"iden":"sample input 1","content":"5 2\n01001\n2 4\n3 5"},{"iden":"sample output 1","content":"6\n\nAfter the first operation, $S$ can be one of the following three: `01001`, `00101` and `00011`.\nAfter the second operation, $S$ can be one of the following six: `01100`, `01010`, `01001`, `00011`, `00101` and `00110`."},{"iden":"sample input 2","content":"9 3\n110111110\n1 4\n4 6\n6 9"},{"iden":"sample output 2","content":"26"},{"iden":"sample input 3","content":"11 6\n00101000110\n2 4\n2 3\n4 7\n5 6\n6 10\n10 11"},{"iden":"sample output 3","content":"143"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}