Word $s$ of length $n$ is called $k$-complete if   $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$;  $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. 

For example, "abaaba" is a $3$-complete word, while "abccba" is not.

Bob is given a word $s$ of length $n$ consisting of only lowercase Latin letters and an integer $k$, such that $n$ is divisible by $k$. He wants to convert $s$ to any $k$-complete word.

To do this Bob can choose some $i$ ($1 \le i \le n$) and replace the letter at position $i$ with some other lowercase Latin letter.

So now Bob wants to know the minimum number of letters he has to replace to convert $s$ to any $k$-complete word.

Note that Bob can do zero changes if the word $s$ is already $k$-complete.

You are required to answer $t$ test cases independently.


-----Input-----

The first line contains a single integer $t$ ($1 \le t\le 10^5$) — the number of test cases.

The first line of each test case contains two integers $n$ and $k$ ($1 \le k < n \le 2 \cdot 10^5$, $n$ is divisible by $k$).

The second line of each test case contains a word $s$ of length $n$.

It is guaranteed that word $s$ only contains lowercase Latin letters. And it is guaranteed that the sum of $n$ over all test cases will not exceed $2 \cdot 10^5$.


-----Output-----

For each test case, output one integer, representing the minimum number of characters he has to replace to convert $s$ to any $k$-complete word.


-----Example-----
Input
4
6 2
abaaba
6 3
abaaba
36 9
hippopotomonstrosesquippedaliophobia
21 7
wudixiaoxingxingheclp

Output
2
0
23
16



-----Note-----

In the first test case, one optimal solution is aaaaaa.

In the second test case, the given word itself is $k$-complete.

Difficulty: interview

Starter code:

Solutions:
import sys
input = sys.stdin.readline
from collections import defaultdict

class Unionfind:
    def __init__(self, n):
        self.par = [-1]*n
        self.rank = [1]*n
    
    def root(self, x):
        r = x
        
        while not self.par[r]<0:
            r = self.par[r]
        
        t = x
        
        while t!=r:
            tmp = t
            t = self.par[t]
            self.par[tmp] = r
        
        return r
    
    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        
        if rx==ry:
            return
        
        if self.rank[rx]<=self.rank[ry]:
            self.par[ry] += self.par[rx]
            self.par[rx] = ry
            
            if self.rank[rx]==self.rank[ry]:
                self.rank[ry] += 1
        else:
            self.par[rx] += self.par[ry]
            self.par[ry] = rx
    
    def is_same(self, x, y):
        return self.root(x)==self.root(y)
    
    def count(self, x):
        return -self.par[self.root(x)]

t = int(input())

for _ in range(t):
    n, k = map(int, input().split())
    s = input()[:-1]
    uf = Unionfind(n)
    
    for i in range(n//2):
        uf.unite(i, n-1-i)
    
    for i in range(n-k):
        uf.unite(i, i+k)
    
    d = defaultdict(dict)
    
    for i in range(n):
        if s[i] not in d[uf.root(i)]:
            d[uf.root(i)][s[i]] = 1
        else:
            d[uf.root(i)][s[i]] += 1
    
    rs = set(uf.root(i) for i in range(n))
    ans = 0
    
    for r in rs:
        ans += uf.count(r)-max(list(d[r].values()))
    
    print(ans)

def main():
    import sys
    input = sys.stdin.readline

    for _ in range(int(input())):
        N, K = list(map(int, input().split()))
        S = input().rstrip('\n')

        cnt = [[0] * K for _ in range(26)]
        for i, s in enumerate(S):
            j = ord(s) - 97
            cnt[j][i%K] += 1
        ans = 0
        L = (N//K) * 2
        for i in range(K//2):
            tmp = N+1
            for j in range(26):
                tmp = min(tmp, L - (cnt[j][i] + cnt[j][K-i-1]))
            ans += tmp
        if K&1:
            tmp = N+1
            for j in range(26):
                tmp = min(tmp, N//K - cnt[j][K//2])
            ans += tmp
        print(ans)


def __starting_point():
    main()

__starting_point()

import sys
input = lambda: sys.stdin.readline().rstrip()
def calc(n, k, A):
    X = [[0] * 26 for _ in range((k+1)//2)]
    for i, a in enumerate(A):
        j = i % k
        j = min(j, k-1-j)
        X[j][a] += 1
    return sum([sum(x) - max(x) for x in X])

T = int(input())
for _ in range(T):
    N, K = list(map(int, input().split()))
    S = [ord(a) - 97 for a in input()]
    print(calc(N, K, S))



import sys
input=sys.stdin.readline
t=int(input())
def find(no):
    nonlocal par
    if par[no]==no:
        return no
    par[no]=find(par[no])
    return par[no]
for _ in range(t):
    n,k=list(map(int,input().split()))
    s=[ord(i)-97 for i in input()]
    
    par=[i for i in range(n)]
    vis=[0 for i in range(n)]
    for i in range(k):
        for j in range(i,n,k):
        
            vis[j]=1
            x=n-j-1
            aa=find(x)
            bb=find(j)
            par[bb]=aa
            if(j>i):
                aa=find(j-k)
                bb=find(j)
                par[bb]=aa
    tot=n
    aa=set(par)
    co=[[0 for i in range(26)] for j in range(n)]
   # print(par)
    for i in range(n):
        co[par[i]][s[i]]+=1
    tot-=sum([max(i) for i in co])
    print(tot)