Devu loves to play with binary strings a lot. One day he borrowed a binary string s of size n from his friend Churu. Before starting to play with it, he wants to make sure that string does not contain more than  k consecutive equal characters. For achieving that, only kind of operation he is allowed to perform is to flip any ith character of the string. 

As Devu is always in hurry to meet his girlfriend, he wants you to help him in finding out the minimum number of operations he will need. Also he wants you to print one of the possible modified string too.

-----Input-----
- First line of input contains an integer T denoting the number of test cases. 
- For each test case, there are two lines. 
- First line contains two space separated integers n, k as defined in the problem. 
- Next line contains string s of size n.

-----Output-----
- For each test case, print two lines.
- First line should contain an integer corresponding to minimum number of operations Devu needs.
- In second line, print one of the possible modified strings.

-----Constraints-----
Subtask #1: 20 points
- 1 ≤ T ≤ 100, 1 ≤ n ≤ 20, 1 ≤ k ≤ n

Subtask #2: 35 points
- 1 ≤ T ≤ 102, 1 ≤ n ≤ 103, 1 ≤ k ≤ n

Subtask #3: 45 points
- 1 ≤ T ≤ 105, 1 ≤ n ≤ 105, 1 ≤ k ≤ n
- Sum of n over all the test cases is ≤ 106 

-----Example-----
Input:
3
2 1
11
2 2
11
4 1
1001

Output:
1
10
0
11
2
1010

-----Explanation-----
Example case 1: As 1 is occurring twice consecutively, we can convert 11 to 10 in a single operation.
Example case 2: You don't need to modify the string as it does not have more than 2 equal consecutive character.
Example case 3: As 0 is occurring twice consecutively, we can convert 1001 to 1010 in a two operations (Flip third and fourth character).

Difficulty: interview

Starter code:

Solutions:
T= int(input());

for i in range(T):
 n,k = list(map(int,input().split()));
 s=list(map(int,input()));

 if k==1:
  s_0 ={};
  s_1={};
  c0=0;
  c1=0;
  for j in range(n):
   if(j%2==0):
    s_1[j]=1;
    s_0[j]=0;
   else:
    s_1[j]=0;
    s_0[j]=1;
  for j in range(n):
   if(s_0[j]-s[j]!=0):
    c0+=1;
   if(s_1[j]-s[j]!=0):
    c1+=1;

  if c0<c1:
   print(c0);
   p_s="";
   for j in range(n):
    p_s+=str(s_0[j]);
   print(p_s);
  else:
   print(c1);
   p_s="";
   for j in range(n):
    p_s+=str(s_1[j]);
   print(p_s);

 else:
  count=1;
  c=s[0];
  flips=0
  for j in range(1,n):
   if(s[j]==c):
    count+=1;
    #print count;
    if count > k:
     if(j+1<n and s[j]==s[j+1]):
      if(s[j]==1):
       s[j]=0;
      else:
       s[j]=1;
     else:
      if(s[j-1]==1):
       s[j-1]=0;
      else:
       s[j-1]=1;
     flips+=1;
     count=1;


   elif(s[j]!=c):
    count=1;
   c=s[j];

  print(flips);
  p_s="";
  for j in range(n):
   p_s+=str(s[j]);
  print(p_s);

def r():
 return list(map(int,input().split()))
def process(stack):
 if len(stack)<k+1:
  ans.extend(stack)
  return
 # print stack,
 # nonlocal count
 if len(stack)%(k+1)==0:
  # print "as"
  for i in range(k,len(stack)-1,k+1):
   stack[i]=(stack[i]+1)%2
  stack[-2]=(stack[-2]+1)%2
 else:
  for i in range(k,len(stack),k+1):
   # print i
   stack[i]=(stack[i]+1)%2
 # count+=((len(stack)+k)/(k+1))
 # print stack
 ans.extend(stack)
for i in range(eval(input())):
 n,k = r()
 arr = list(map(int,list(input())))
 if k==1:
  s=[]
  c=0
  for i in range(n):
   s.append((c+1)%2)
   c+=1
  s1=[]
  c=1
  for i in range(n):
   s1.append((c+1)%2)
   c+=1
  ans1,ans2=0,0
  for i in range(n):
   if arr[i]!=s1[i]:
    ans2+=1
   if arr[i]!=s[i]:
    ans1+=1
  s1=list(map(str,s1))
  s=list(map(str,s))
  if ans1<ans2:
   print(ans1)
   print(''.join(s))
  else:
   print(ans2)
   print(''.join(s1))
 else:
  # print japasas
  ans=[]
  c=1
  count=0
  stack=[arr[0]]
  for i in range(1,n):
   if arr[i]==arr[i-1]:
    stack.append(arr[i])
   else:
    process(stack)
    stack=[arr[i]]
  # ans.extend(stack)
  process(stack)
  count=0
  for i in range(n):
   if ans[i]!=arr[i]:
    count+=1
  print(count)
  ans=list(map(str,ans))
  print(''.join(ans))

def r():
 return list(map(int,input().split()))
def process(stack):
 if len(stack)<k+1:
  ans.extend(stack)
  return
 # print stack,
 # nonlocal count
 if len(stack)%(k+1)==0:
  # print "as"
  for i in range(k,len(stack)-1,k+1):
   stack[i]=(stack[i]+1)%2
  stack[-2]=(stack[-2]+1)%2
 else:
  for i in range(k,len(stack),k+1):
   # print i
   stack[i]=(stack[i]+1)%2
 # count+=((len(stack)+k)/(k+1))
 # print stack
 ans.extend(stack)
for i in range(eval(input())):
 n,k = r()
 arr = list(map(int,list(input())))
 if k==1:
  s=[]
  c=0
  for i in range(n):
   s.append((c+1)%2)
   c+=1
  s1=[]
  c=1
  for i in range(n):
   s1.append((c+1)%2)
   c+=1
  ans1,ans2=0,0
  for i in range(n):
   if arr[i]!=s1[i]:
    ans2+=1
   if arr[i]!=s[i]:
    ans1+=1
  s1=list(map(str,s1))
  s=list(map(str,s))
  if ans1<ans2:
   print(ans1)
   print(''.join(s))
  else:
   print(ans2)
   print(''.join(s1))
 else:
  # print japasas
  ans=[]
  c=1
  count=0
  stack=[arr[0]]
  for i in range(1,n):
   if arr[i]==arr[i-1]:
    stack.append(arr[i])
   else:
    process(stack)
    stack=[arr[i]]
  # ans.extend(stack)
  process(stack)
  count=0
  for i in range(n):
   if ans[i]!=arr[i]:
    count+=1
  print(count)
  ans=list(map(str,ans))
  print(''.join(ans))

def r():
 return list(map(int,input().split()))
def process(stack):
 if len(stack)<k+1:
  ans.extend(stack)
  return
 # print stack,
 # nonlocal count
 if len(stack)%(k+1)==0:
  # print "as"
  for i in range(k,len(stack)-1,k+1):
   stack[i]=(stack[i]+1)%2
  stack[-2]=(stack[-2]+1)%2
 else:
  for i in range(k,len(stack),k+1):
   # print i
   stack[i]=(stack[i]+1)%2
 # count+=((len(stack)+k)/(k+1))
 # print stack
 ans.extend(stack)
for i in range(eval(input())):
 n,k = r()
 arr = list(map(int,list(input())))
 if k==1:
  s=[]
  c=0
  for i in range(n):
   s.append((c+1)%2)
   c+=1
  s1=[]
  c=1
  for i in range(n):
   s1.append((c+1)%2)
   c+=1
  ans1,ans2=0,0
  for i in range(n):
   if arr[i]!=s1[i]:
    ans2+=1
   if arr[i]!=s[i]:
    ans1+=1
  s1=list(map(str,s1))
  s=list(map(str,s))
  if ans1<ans2:
   print(ans1)
   print(''.join(s))
  else:
   print(ans2)
   print(''.join(s1))
 else:
  # print japasas
  ans=[]
  c=1
  count=0
  stack=[arr[0]]
  for i in range(1,n):
   if arr[i]==arr[i-1]:
    stack.append(arr[i])
   else:
    process(stack)
    stack=[arr[i]]
  # ans.extend(stack)
  process(stack)
  count=0
  for i in range(n):
   if ans[i]!=arr[i]:
    count+=1
  print(count)
  ans=list(map(str,ans))
  print(''.join(ans))