human
Can you solve the below in PYTHON3?
Let's call the string beautiful if it does not contain a substring of length at least 2, which is a palindrome. Recall that a palindrome is a string that reads the same way from the first character to the last and from the last character to the first. For example, the strings a, bab, acca, bcabcbacb are palindromes, but the strings ab, abbbaa, cccb are not.

Let's define cost of a string as the minimum number of operations so that the string becomes beautiful, if in one operation it is allowed to change any character of the string to one of the first 3 letters of the Latin alphabet (in lowercase).

You are given a string s of length n, each character of the string is one of the first 3 letters of the Latin alphabet (in lowercase).

You have to answer m queries — calculate the cost of the substring of the string s from l_i-th to r_i-th position, inclusive.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 2 ⋅ 10^5) — the length of the string s and the number of queries.

The second line contains the string s, it consists of n characters, each character one of the first 3 Latin letters.

The following m lines contain two integers l_i and r_i (1 ≤ l_i ≤ r_i ≤ n) — parameters of the i-th query.

Output

For each query, print a single integer — the cost of the substring of the string s from l_i-th to r_i-th position, inclusive.

Example

Input

5 4
baacb
1 3
1 5
4 5
2 3

Output

1
2
0
1

Note

Consider the queries of the example test.

  * in the first query, the substring is baa, which can be changed to bac in one operation.

  * in the second query, the substring is baacb, which can be changed to cbacb in two operations.

  * in the third query, the substring is cb, which can be left unchanged.

  * in the fourth query, the substring is aa, which can be changed to ba in one operation. 
 ... Write me a Python code to print a single integer — the cost of the substring of the string s from l_i-th to r_i-th position, inclusive?
assistant
#Here is Python code to print a single integer — the cost of the substring of the string s from l_i-th to r_i-th position, inclusive.

import os, sys, math
from io import BytesIO, IOBase
ip = lambda: input()
it = lambda: int(input())
ma = lambda: map(int, input().split(" "))
li = lambda: list(map(int,input().split(" ")))
mod=10**9+7
#?????
def prime(n):
    if n==1:
        return False
    elif n==2 or n==3:
        return True
    else:
        l=int(n**0.5)
        i=2
        f=True
        while i<=l:
            if n%i==0:
                f=False
                break
            i+=1
        return f
def presum(s,a,n):
    arr=[0]*n
    count=0
    for i in range(n):
        if s[i]!=a[i%3]:
            count+=1
        arr[i]=count
    return arr

def main():
    n,m=ma()
    s=ip()
    a=["abc","acb","bac","bca","cab","cba"]
    prefixsum=[]
    for i in range(6):
        prefixsum.append(presum(s,a[i],n))
    for q in range(m):
        l,r=ma()
        res=mod
        if l==1:
            for i in range(6):
                x=prefixsum[i][r-1]
                if x<res:
                    res=x
        else:
            for i in range(6):
                x=prefixsum[i][r-1]-prefixsum[i][l-2]
                if x<res:
                    res=x
        print(res)

# Fast IO Region
BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
           ...