{"problem":{"name":"Shuffling","description":{"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$: *   Arbitrarily permute the characters within the subst","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc065_d"},"statements":[{"statement_type":"Markdown","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)$?\n\n## Constraints\n\n*   $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}$\n\n## Input\n\nThe 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$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc065_d","tags":[],"sample_group":[["5 2\n01001\n2 4\n3 5","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`."],["9 3\n110111110\n1 4\n4 6\n6 9","26"],["11 6\n00101000110\n2 4\n2 3\n4 7\n5 6\n6 10\n10 11","143"]],"created_at":"2026-03-03 11:01:14"}}