C. String Traversal Paradigm 1
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given a string $$$s$$$ of size $$$n$$$ consisting of lowercase English alphabets $$$(a \space to \space z)$$$. The cost of moving from a character $$$c_i$$$ at index $$$i$$$ to $$$c_j$$$ at index $$$j$$$ is as follows:

  1. If $$$c_i \neq c_j$$$, then cost to move from $$$c_i$$$ to $$$c_j$$$ is $$$|i - j|$$$.
  2. If $$$c_i == c_j$$$, then cost to move from $$$c_i$$$ at $$$i$$$ to $$$c_j$$$ at $$$j$$$ is $$$0$$$ .

You are given $$$q$$$ queries. Each query is of the form : $$$u \space v$$$

where you need to find minimum cost to move from character $$$u$$$ (i.e any index i such that $$$c_i = u$$$) to character $$$v$$$ (i.e any index j such that $$$c_j = v$$$). Print $$$-1$$$ if it's not possible to reach from $$$u$$$ to $$$v$$$(If any of u or v does not exist in string, then print $$$-1$$$).

Input

First line contains $$$n$$$ and $$$q$$$. $$$(1 \leq n \leq 10^5)$$$ $$$(1 \leq q \leq 26 \times 26)$$$

Next line contains string $$$s$$$.

Next $$$q$$$ lines contain: $$$u \space v$$$ $$$(a \leq u, v \leq z)$$$

Output

For each query output minimum cost to move from character $$$u$$$ to character $$$v$$$.

Examples
Input
9 2
aabbcedba
a c
b d
Output
2
1
Input
11 7
dcdcccedceb
e b
d b
e e
b e
e a
a b
d d
Output
1
2
0
1
-1
-1
0
Note

In test case $$$1$$$, we can move from 'a' at index $$$1$$$ to 'b' at index $$$2$$$ in cost of $$$|2-1|=1$$$. Now we can move from 'b' at index $$$2$$$ to 'b' at index $$$3$$$ in cost of $$$0$$$. Now we can reach 'c' at index $$$4$$$ from 'b' at index $$$3$$$ in cost of $$$|3-2|=1$$$. Thus the minimum cost of moving from 'a' to 'c' comes out to be $$$2$$$.