func_code_string: #include<bits/stdc++.h>   using namespace std;   template<typename AA>inline void CMax(AA &u,AA v){if(v>u)u=v;}   template<typename AA>inline void CMin(AA &u,AA v){if(v<u)u=v;}   #define Put(a) cout<<(a)<<endl   #define For(a,b,c) for(int a=(b);a<=(c);++a)   #define Fov(a,b,c) for(int a=(b);a>=(c);--a)   #define Foe(a,b,c) for(int a=(b);a<(c);++a)   #define Clear(a,b) memset(a,b,sizeof(a))   const double eps=1E-8;const int Inf=0x3f3f3f3f,oo=0x7fffffff,Mod=998244353;   typedef long long lon;const lon Lnf=0x3f3f3f3f3f3f3f3f;   template<typename AA>void read(AA &x)   {int s=0;char c;while(c=getchar(),(c< 0 ||c> 9 )&&c!= - );c== - ?(s=1,x=0):(x=c- 0 );   while(c=getchar(),c>= 0 &&c<= 9 ) x=x*10+c- 0 ;if(s) x=-x;}   template<typename AA, typename...Args>void read(AA &t,Args &...args)   {read(t);read(args...);}template<typename AA>void print(AA k){int num=0;   static char stk[23];if(k<0){putchar( - );k=-k;}while(k>0)stk[++num]=k%10+48,k/=10;   if(!num)putchar( 0 );else while(num)putchar(stk[num--]);putchar(  n );}   inline int Log2(int x) {if(!x)return 0;else return 31-__builtin_clz(x);}   char getc(){char ch;do{ch=getchar();}while(ch==   ||ch==  n );return ch;}   lon Pow(lon d,lon m){lon f=1;while(m){if(m&1)f=f*d%Mod;d=d*d%Mod;m>>=1;}return f;}   //#include<ext/rope> using namespace __gnu_cxx;   //#include<bits/extc++.h>#include<ext/pb_ds/assoc_container.hpp>   //using namespace __gnu_pbds;   //#pragma GCC optimize(3)   int N,M,S,Q,K,T=1;      int u,v;   char s[300030];      int n;   int nd[300030];   int ansp;char ansc;      void init() {    int cnt[26]={};    For(a,1,n) {     if(cnt[s[a]- a ]==0) nd[a]=nd[a-1]+K-1;     else nd[a]=nd[a-1]-1;        cnt[s[a]- a ]=(cnt[s[a]- a ]+1)%K;        if(a<n&&s[a+1]< z ) {      Fov(b,25,0) {       if( a +b==s[a+1]) break;          if(cnt[b]==0) {        nd[a+1]=nd[a]+K-1;       }       else {        nd[a+1]=nd[a]-1;       }          if(n-a-1>=nd[a+1]&&(n-a-1-nd[a+1])%K==0) ansp=a+1,ansc= a +b;         }     }       }   }         signed main()   {    //freopen( 1.in , r ,stdin);       read(T);    while(T--) {     read(N,K);     scanf( %s ,s+1); n=strlen(s+1);     ansp=1;ansc=s[1]+1;     if(N%K) {puts( -1 );continue;}        init();          //printf( %d %c n ,ansp,ansc);        if(nd[n]==0) {printf( %s n ,s+1);continue;}     if(ansp==1&&ansc> z ) {puts( -1 );continue;}                int cnt[26]={};     s[ansp]=ansc;     For(a,1,ansp) {      cnt[s[a]- a ]=(cnt[s[a]- a ]+1)%K;     }     For(a,0,25) if(cnt[a]!=0) cnt[a]=K-cnt[a];        int now=n;     Fov(a,25,0) {      while(cnt[a]--) s[now--]= a +a;     }     while(now>ansp) s[now--]= a ;        printf( %s n ,s+1);    }          return 0;   }