12
12 3
zazasqzqsasq
1 1
z
1 1
a
15 4
abccbaabccbazaa
16 8
cadjfdsljfdkljds
6 2
baazaa
6 3
bosszb
6 1
qwerty
7 7
daaaaaa
14 2
acabcbdeffewzd
18 6
zzzzzzzzzzzzyyyyyz
9 4
aabaabbbc

zazasqzqsasq
z
a
-1
cbbbbbbbbccccccc
baazbz
bpbbpp
qwerty
ddddddd
acabcbdeffexdx
zzzzzzzzzzzzzzzzzz
-1

def toNum(letter):
    return ord(letter) - ord('a')

def toChr(num):
    return chr(num + ord('a'))

def getRemaining(num, k):
    return (k - num % k) % k

def getRemainingSum(k, cnt):
    sm = 0
    for num in cnt:
        sm += getRemaining(num, k)
    return sm
    
for cases in range(int(input())):
    n, k = map(int, input().split())
    s = input()
    cnt = [0 for x in range(26)]
    if n % k != 0:
        print(-1)
        continue

    for letter in s:
        cnt[toNum(letter)] += 1
    
    sm = getRemainingSum(k, cnt)
    #print(f"cnt = {cnt}")
    #print(f"sm = {sm}")

    if sm == 0:
        # the string itself is the solution
        print(s)
        continue

    i = n - 1
    flag = True
    while i >= 0 and flag:
        # remove the needs of the current element from total
        sm -= getRemaining(cnt[toNum(s[i])], k)

        # recount current element needs without itself
        cnt[toNum(s[i])] -= 1

        # update the total sum accordingly
        sm += getRemaining(cnt[toNum(s[i])], k)

        # itereate through possible replacements starting with the next alphabet letter
        j = toNum(s[i]) + 1
        while j < 26:
            # save current sum
            lastsum = sm

            # remove the needs of the current candidate letter 
            sm -= getRemaining(cnt[j], k)

            # increment current candidate letter cnt
            cnt[j] += 1

            # update the sum with up to date current candidate needs
            sm += getRemaining(cnt[j], k)

            if i + sm + 1 <= n:
                # seems like a suitable candidate as the sum fits 

                # print out the parts we are sure about
                for pos in range(i):
                    print(s[pos], end="")
                
                # print good candidate
                print(toChr(j), end="")

                # need to resolve the remaining part
                add = []
                
                # iterate alphabet starting from the beginning
                for w in range(26):
                    # if letter w is needed n times, print it out
                    f = getRemaining(cnt[w], k)
                    while f:
                        f -= 1
                        add.append(toChr(w))
                # now even if is sm is 0 (no letters needed) there might still be letters missing
                # e.g. n = 6, k = 2 current str = aabb
                # so we fill the remaining places with 'a'

                while len(add) + i + 1 < n:
                    add.append(toChr(0))

                # sort the remaining to get the minimal string
                # we are sure not getting anything less than the initial string
                # as the candidate is already larger than whomever it replaced
                add.sort()

                print("".join(add))
                flag = False
                break

            # bad candidate, decrement its count to get rdy for the next one
            cnt[j] -= 1

            # restore current sum
            sm = lastsum

            j += 1
        i -= 1

