def noDup(kywrd):
  #for debug
  print("Entering function noDup")
  returnStr="";
  vowelArray = ('a', 'e', 'i', 'o', 'u','A','E','I','O','U');
  for char_index in range(len(kywrd)):
    if(not (char_index+1 < len(kywrd) and kywrd[char_index]==kywrd[char_index+1] and not kywrd[char_index] in vowelArray)):
      returnStr = returnStr + kywrd[char_index]
  temp = returnStr[1::]
  for c in returnStr:
        if c in vowelArray:
            temp = temp.replace(c,""); 
  returnStr = returnStr[0:1:] + temp
  return returnStr

def removeChars(inputstr):
   #for debug
  print("Entering function removeChars")
  checkChars = inputstr.split(' ')
  keyword1=checkChars[0]
  keyword2=checkChars[1]
  string1 = noDup(keyword1)
  #fordebug
  print(string1)
  string2 = noDup(keyword2)
  #fordebug
  print(string2)
  tStr1=""
  tStr2=""
  pos=0
  for a, b in zip(string1, string2):
   if( a!=b):
     tStr1= tStr1+a
     tStr2= tStr2+b
   pos=pos+1
  string1 = tStr1 + string1[pos::]
  string2 = tStr2  + string2[pos::]
  tStr1=""
  tStr2=""
  pos=0
  for a, b in zip(reversed(string1), reversed(string2)):
   if( a!=b):
     tStr1= tStr1+a
     tStr2= tStr2+b
     
   pos=pos+1
  string1 = tStr1 + string1[pos::]
  str2 = tStr2  + string2[pos::]
  string1 = string1[::-1]
  str2 = str2[::-1]
  if(len(string1)len(str2)):
   print(checkChars, string2)
  else :
   wrdLst = []
   wrdLst.append(string1)
   wrdLst.append(str2)
   wrdLst.sort()
   print(checkChars,wrdLst[0])

noOfWords = int(input('Enter number of words to check\n'))
expression = []
print('Enter the Input')
for i in range(noOfWords):
  expression.append(input())
print('Output')
for str in expression:
  removeChars(str.upper())