Mars

For each query substring, find the minimum number of bit flips that make it match no substring of the DNA, or report Impossible.

Hard8String matchingDynamic programmingStringNo attempts yetTime limit2sMemory limit512 MB

Problem

A new form of life was found on Mars. Every alien has a DNA that uses an alphabet of two letters instead of four, so the DNA of a Mars alien is written as a binary string.

Let ss be an alien DNA of length nn. The DNA has qq marked regions called genes. The gene at [a,b][a, b] is the substring of the DNA that runs from position aa to position bb, both included (1abn1 \le a \le b \le n). Genes may overlap, and one gene may sit inside another.

During the life of a Mars alien each gene is copied billions of times. A protein binds to the start of the gene and copies it from start to end. This process is not error free and may produce mutations. In one mutation a 0 in the gene is copied as 1, or a 1 in the gene is copied as 0. A mutated copy no longer matches the gene, but it may still match a substring at another position of the DNA, and that substring may overlap the gene.

For example, let ss be 001011111 with a gene at [3,6][3, 6], so the gene string is 1011. One copy of this gene is 1111, mutated at the second letter. That copy does not match the substring at [3,6][3, 6], but it matches the substring at [5,8][5, 8]. A mutated copy is called degenerate if it occurs at no position of the whole DNA. The copy 1010, which mutates the fourth letter, is degenerate, but 1111 is not.

For each gene, find the smallest number of mutations that can produce a degenerate copy of that gene.

Input

The input has several test cases. The first line of a test case has two integers nn and qq (2n100002 \le n \le 10000, 1q10001 \le q \le 1000). The next line has a binary string ss of length nn. Each of the next qq lines has the location [a,b][a, b] of one gene as two space separated integers aa and bb (1abn1 \le a \le b \le n). The input ends with a line holding 0 0, which you do not process.

Output

For each gene, print the smallest number of mutations that can produce a degenerate copy. If no set of mutations applied to that gene can produce a degenerate copy, print Impossible instead.