You are teaching students to generate strings consisting of unique lowercase latin characters (a-z). You give an example reference string $s$ to the students.
You notice that your students just copy paste the reference string instead of creating their own string. So, you tweak the requirements for strings submitted by the students.
Let us define a function F(s, t) where s and t are strings as the number of characters that are same in both the strings. Note that the position doesn't matter. Here are a few examples of F(s, t):
F("abc", "def") = 0
F("abc", "acb") = 3
F("back", "abcd") = 3
Now you ask your students to output a string t with lowercase unique characters of the same length as $s$, such that F(s, t) $\leq k$ where you are also given the value of $k$. If there are multiple such strings, you ask them to output the lexicographically smallest possible string. If no such string is possible, output the string "NOPE" without quotes.

-----Input:-----
- The first line will contain $T$, the number of testcases. Then the testcases follow. 
- Each testcase contains of a single line of input, which contains a string $s$ and an integer $k$.

-----Output:-----
For each testcase, output in a single line the lexicographically smallest string t such that F(s, t) <= k or "NOPE" without quotes if no such string exists.

-----Constraints-----
- $1 \leq T \leq 10000$
- $1 \leq $length of string s $(|s|) \leq 26$
- $s$ only consists of characters $a$ to $z$
- There are no repeating characters in s
- $0 \leq k \leq |s|$

-----Sample Input:-----
4
helowrd 0
background 0
abcdefghijklmnopqrstuvwxyz 0
b 1

-----Sample Output:-----
abcfgij
efhijlmpqs
NOPE
a

Starter code:

Solutions:
for _ in range(int(input())):
 s,k=map(str,input().split())
 k=int(k)
 n="NOPE"
 al=[0]*26
 for ele in s:
  al[ord(ele)-ord('a')]=1
 l=len(s)
 ans=[]
 # print(al)
 for i in range(26):
  if len(ans)==l:
   break
  elif al[i]==1 and k>0:
   k-=1
   ans.append(chr(i+ord('a')))
  elif al[i]==0:
   ans.append(chr(i+ord('a')))
 
 if len(ans)!=l:
  print(n)
 else:
  print("".join(ans))

# cook your dish here
t = int(input())
tt = 0
while tt < t :
 tt = tt + 1
 str = input()
 s, k = str.split()
 k = int(k)
 l = len(s)
 if l >= 14 and (2*l - k) > 26:
  print("NOPE")
 else :
  thisList = []
  j = 0
  while j < 26 :
   thisList.append(0)
   j = j + 1
  j = 0
  while j < l :
   a = str[j]
   b = ord(a)
   b = b - 97
   thisList[b] = 1
   j = j + 1
  str = ""
  j = 0
  i = 0
  while j < l:
   c = chr(i + 97)
   if thisList[i] == 0 :
    str = str + c
    j = j + 1
   elif k > 0:
    str = str + c
    j = j + 1 
    k = k - 1
   else :
    pass
   i = i + 1
  print(str) 
    
   
   
   
   
   
   
   
   
   
   
   
   
   


letters = ['a']
for i in range(0, 25): letters.append(chr(ord(letters[i]) + 1))
for tests in range(int(input())):
 word = input().split();integer = int(word[1]);ret = ''
 for i in letters:
  if integer > 0: 
   ret += i
   if i in word[0]: integer -= 1
  else:
   if i not in word[0]: ret += i
  if len(ret) == len(word[0]): break
 print('NOPE') if len(ret) != len(word[0]) else print(ret)

# cook your dish here
letters = ['a']
for i in range(0, 25): letters.append(chr(ord(letters[i]) + 1))

for tests in range(int(input())):
 word = input().split()
 integer = int(word[1])
 ret = ''
 for i in letters:
  if integer > 0: 
   ret += i
   if i in word[0]: integer -= 1
  else:
   if i not in word[0]: ret += i
  if len(ret) == len(word[0]): break
 if len(ret) != len(word[0]): print('NOPE')
 else: print(ret)

# cook your dish here
alpha = "abcdefghijklmnopqrstuvwxyz"
for _ in range(int(input())):
 s, k = input().split()
 k = int(k)
 l = len(s)
 res = ''.join(sorted(s))
 if (26-l)+k < l:
  print("NOPE")
 else:
  for i in alpha:
   if l == 0:
    break
   else:
    if i not in res:
     print(i, end = "")
     l -= 1
    else:
     if k!= 0:
      print(i, end = "")
      k -= 1 
      l -= 1
  print() 

import math,sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
lili=lambda:list(map(int,sys.stdin.readlines()))
li = lambda:list(map(int,input().split()))
#for deque append(),pop(),appendleft(),popleft(),count()
I=lambda:int(input())
S=lambda:input().strip()
mod = 1000000007

for i in range(I()):
 s,n=list(map(str,input().split()))
 n=int(n)
 p="abcdefghijklmnopqrstuvwxyz"
 d=Counter(s)
 ans=""
 for i in p:
  if(len(ans)==len(s)):
   break
  if(i not in d):
   ans+=i
  else:
   if(n):
    ans+=i
    n-=1
 if(len(ans)==len(s)):
  print(ans)
 else:
  print("NOPE")

# cook your dish here
t=int(input())
while(t>0):
 fs,k=map(str,input().split())
 k=int(k)
 fs=list(set(fs))
 arr=""
 for a in range(97,123):
  if(chr(a) in fs):
   if(k>0):
    arr+=chr(a)
    k-=1
   else:
    continue
  else:
   arr+=chr(a)
 if(len(fs)<=len(arr)):
  print(arr[:len(fs)])
 else:
  print('NOPE')
 t-=1

t=int(input())
while(t>0):
 fs,k=list(map(str,input().split()))
 k=int(k)
 fs=list(set(fs))
 arr=""
 for a in range(97,123):
  if(chr(a) in fs):
   if(k>0):
    arr+=chr(a)
    k-=1
   else:
    continue
  else:
   arr+=chr(a)
 if(len(fs)<=len(arr)):
  print(arr[:len(fs)])
 else:
  print('NOPE')
 t-=1
  


n = int(input())
while(n>0):
 s1,c1=input().split(" ")
 c1=int(c1)
 s1=list(set(s1))
 answer=""
 for c in range(97,123):
  if chr(c) in s1:
   if(c1>0):
    answer+=chr(c)
    c1=c1-1;
   else:
    continue 
  else:
   answer+=chr(c)
 if(len(s1)<=len(answer)):
  print(answer[:len(s1)])
 else:
  print("NOPE");
 n=n-1;

for _ in range(int(input())):
 s = input().split()
 k = int(s[1])
 s = s[0]
 ll = len(s)
 if (26-ll+k)>=ll:
  l = [0]
  for i in range(26):
   l.append(0)
  for i in s:
   l[ord(i)-96]=1
  a = 0
  b = 1
  for i in range(ll):
   if a<k:
    if l[b]==1:
     print(chr(96+b),end="")
     a+=1
    else:
     print(chr(96+b),end="")
   else:
    while b<=26 and l[b]==1:
     b+=1
    print(chr(96+b),end="")
   b+=1
 else:
  print('NOPE',end="")
 print()

from math import sqrt
def ii():return int(input())
def si():return input()
def mi():return list(map(int,input().split()))
def li():return list(mi())
abc="abcdefghijklmnopqrstuvwxyz"
t=ii()
while(t):
 t-=1
 m=[0]*26
 s=input().split()
 s1=s[0]
 k=int(s[1])
 n=len(s1)
 for i in range(len(s1)):
  m[ord(s1[i])-ord('a')]+=1
 s=""
 for i in range(26):
  if(m[i]!=0):
   if(k>0):
    s+=abc[i]
    k-=1
  else:
   s+=abc[i]
 if(n!=len(s[:n])):
  print("NOPE")
 else:
  print(s[:n])
  
 
 
 
 
 
 


# cook your dish here
for _ in range(int(input())):
 s,k = map(str,input().split())
 k = int(k)
 if (26-len(s))+k<len(s):print("NOPE")
 else:
  k1,ans = k,""
  for i in range(97,123):
   a = chr(i)
   if s.count(a)>0:
    if k1>0:
     k1 -= 1
     ans += a
   else:ans += a
   if len(ans)==len(s):break
  print(ans)

for t in range(int(input())):
 flag=False
 a=[0]*26
 s,k=(input().split())
 k=int(k)
 s=list(s)
 n=len(s)
 nn=n
 ans=[]
 for i in range(n):
  a[ord(s[i])-ord('a')]=1
 for i in range(26):
  if(a[i]==0 and n>0):
   flag=True
   
   ans.append(chr(ord('a')+i))
   n-=1
  elif (a[i]==1 and n>0 and k>0):
   ans.append(chr(ord('a')+i))
   n-=1
   k-=1
   flag=True
 #  print(ans)
 if(flag and len(ans)==nn):
  for i in ans:
   print(i,end='')
  print()
 else:
  print("NOPE")
 

# cook your dish here
for _ in range(int(input())):
 t,k=input().split()
 k=int(k)
 str=''
 for c in range(97,123):
  if chr(c) in t:
   if k>0:
    str+=chr(c)
    k=k-1
   else:
    continue
  else:
   str+=chr(c)
 if len(str)>=len(t):
  print(str[:len(t)])
 else:
  print('NOPE')

t = int(input())
while t>0:
 t -= 1
 s,k= input().split()
 k = int(k)
 n = len(s)
 d = []
 for i in range(97,97+26):
  d.append(chr(i))
 st = ""
 for i in d:
  if i not in s:
   st+=i
  else:
   if k>0:
    st+=i
    k -=1
  if len(st) == n:
   print(st)
   break
 if len(st) < n:
  print("NOPE")

# cook your dish here
t=int(input())
while t>0:
 l=list(input().split())
 a=int(l[1])
 s=list(l[0])
 o=""
 for i in range(97,123):
  if(chr(i) in s):
   if(a>0):
    o+=chr(i)
    a-=1
  else:
   o+=chr(i)
 if(len(s)<=len(o)):
  print("".join(o[0:len(s)]))
 else:
  print("NOPE")
 t-=1

for _ in range(int(input())):
 s,k=input().split()
 k=int(k)
 # arr = list(n)
 t=""
 for i in range(97,123):
  if chr(i) not in s:
   t+=chr(i)
   if len(t)==len(s):
    break
  elif chr(i) in s and k>0:
   t+=chr(i)
   k-=1
   if len(t)==len(s):
    break
 if len(t)==len(s):
  print(t)
 else:
  print("NOPE")


for _ in range(int(input())):
 s,k=map(str,input().split())
 s1=list(set(s))
 k=int(k)
 ans=""
 for i in range(97,123):
  if chr(i) in s1:
   if(k>0):
    ans+=chr(i)
    k-=1
   else:
    continue 
  else:
   ans+=chr(i)
 if(len(s1)<=len(ans)):
  print(ans[:len(s1)])
 else:
  print("NOPE");

T=int(input())
for i in range(0,T):
 a,b=input().split()
 b=int(b)
 n=len(a)
 a=list(set(a))
 r=[]
 for c in range(97,123):
  if(len(r)==n):
   break
  else:
   if chr(c) not in a:
    r.append(chr(c))
   else:
    if(b>0):
     r.append(chr(c))
     b=b-1
 if(len(r)!=n):
  print("NOPE")
 else:
  print(''.join(r))


t=int(input())
while (t>0):
 s,k=input().split()
 s=list(s)
 k=int(k)
 anstr=""
 for i in range(97,123):
  if (chr(i) in s):
   if (k>0):
    anstr=anstr+chr(i)
    k=k-1
  else:
   anstr=anstr+chr(i)
 if (len(anstr)>=len(s)):
  print(anstr[:len(s)])
 else:
  print("NOPE")
 t=t-1

# cook your dish here
for _ in range(int(input())):
 s,k = input().split()
 k = int(k)
 ref = "abcdefghijklmnopqrstuvwxyz"
 l = len(s)
 r = ""
 i=0
 while len(r)!=l and i<26:
  if ref[i] in s and k>0:
   r+=ref[i]
   i+=1
   k-=1
  elif ref[i] in s:
   i+=1
   continue
  else:
   r+=ref[i]
   i+=1
 if len(r) == len(s):
  print(r)
 else:
  print("NOPE")
   


t=int(input())
for _ in range(t):
 #lol={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q'        ,'r','s','t','u','v','w','x','y','z'}
 s,k=input().split()
 k=int(k)
 n=len(s)
 x=list(set(s))
 final=''
 for i in range(97,123):
  if(chr(i) in x):
   if(k>0):
    final+=chr(i)
    k-=1
   else:
    continue
  else:
   final+=chr(i)
 if(len(s)<=len(final)):
  print(final[:n])
 else:
  print('NOPE')
    


t = int(input())
g = 'abcdefghijklmnopqrstuvwxyz'
while t:
 t-=1
 s,k = input().split()
 h = len(s)
 k = int(k)
 ans = []
 count = 0
 d = {}
 for i in s:
  d[i] = True
 s = list(s)
 s = sorted(s)
 for i in range(k):
  ans.append(s[i])
 currentIndex=0
 ans = ans[::-1]
 for i in range(26):
  if g[i] not in d:
   if count+k<h:
    count+=1
    ans.append(g[i])
    ans = sorted(ans)[::-1]
   else:
    for j in range(h):
     if ans[j]>g[i]:
      ans[j] = g[i]
      ans = sorted(ans)[::-1]
      break
 ans = sorted(ans)
 if count+k == h:
  
  print(''.join(ans))
 else:
  print("NOPE")


import string

for a in range(int(input())):
 s, k = input().split()
 k = int(k)
 if 26 - len(s) + k < len(s):
  print("NOPE")
 else:
  t = ""
  f = 0
  for c in string.ascii_lowercase:
   if c in s and f < k:
    t += c
    f += 1
   elif c not in s:
    t += c
   if len(t) == len(s):
    break
  print(t)