#include <bits/stdc++.h>   #define mp make_pair   #define fi first   #define se second   #define pb push_back   #define eb emplace_back   #define all(x) (x).begin(), (x).end()   #define rall(x) (x).rbegin(), (x).rend()   #define forn(i, n) for (int i = 0; i < (int)(n); ++i)   #define for1(i, n) for (int i = 1; i <= (int)(n); ++i)   #define ms(x, y) memset(x, y, sizeof(x))   #define SZ(x) int(x.size())   #define fk cout<< fk <<endl   #define db(x) cout<<(#x)<< = <<(x)<<endl   #define db2(x,y) cout<<(#x)<< = <<(x)<<   <<(#y)<< = <<(y)<<endl   using namespace std;   typedef pair<int, int> pii;   typedef vector<int> vi;   typedef long long i64;   template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }   template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }   void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout<<fixed;}   //1.integer overflow (1e5 * 1e5) (2e9 + 2e9)   //2.runtime error   //3.boundary condition   int tc,n,k,cnt[30],need[30];   string s;   int main() {       fastio();          cin>>tc;       while(tc--){           cin>>n>>k;           cin>>s;           ms(cnt,0);           for(int i=0; i<n; ++i){               int num=int(s[i])-int( a );               ++cnt[num];           }           bool ok=true;           for(int i=0; i<26; ++i){               if(cnt[i]%k!=0) ok=false;           }           if(ok){               cout<<s<<  n ;               continue;           }           bool have=false;           string ans=  ;           for(int i=n-1; i>=0; --i){               string res=  ;               int cur=int(s[i])-int( a );               --cnt[cur];               if(cur==25) continue;               int all_need=0;               ms(need,0);               for(int j=0; j<26; ++j){                   int goal=(cnt[j]+k-1)/k*k;                   need[j]=goal-cnt[j];                   all_need+=goal-cnt[j];               }               if(all_need<=n-i){                   if(all_need==n-i){                       int find=-1;                       for(int j=cur+1; j<26; ++j){                           if(need[j]>0){                               find=j;                               break;                           }                       }                       if(find!=-1){                           have=true;                           for(int j=0; j<i; ++j) res+=s[j];                           char ch=char(int( a )+find);                           res+=ch;                           --need[find];                           for(int j=0; j<26; ++j){                               while(need[j]>0){                                   char ch_temp=char(int( a )+j);                                   res+=ch_temp;                                   need[j]--;                               }                           }                           ans=res;                           break;                       }                   } else{                       if(((n-i)-all_need)%k==0){                           int find=-1;                           for(int j=cur+1; j<26; ++j){                               if(need[j]>0){                                   find=j;                                   break;                               }                           }                           if(find==cur+1){                               need[0]+=(n-i)-all_need;                               have=true;                               for(int j=0; j<i; ++j) res+=s[j];                               res+=char(int( a )+cur+1);                               --need[cur+1];                               for(int j=0; j<26; ++j){                                   while(need[j]>0){                                       res+=char(int( a )+j);                                       --need[j];                                   }                               }                               ans=res;                               break;                           } else{                               need[cur+1]+=k;                               need[0]+=(n-i)-all_need-k;                               have=true;                               for(int j=0; j<i; ++j) res+=s[j];                               res+=char(int( a )+cur+1);                               --need[cur+1];                               for(int j=0; j<26; ++j){                                   while(need[j]>0){                                       res+=char(int( a )+j);                                       --need[j];                                   }                               }                               ans=res;                               break;                           }                       }                   }               }           }        //   if(have) assert(SZ(ans)==n);           if(have) cout<<ans<<  n ;           else cout<<-1<<  n ;       }       return 0;   }