# -----------------------------------------------------------------------------------------
# Oak Valley Coding Club 2019-2020
# Solution for 2020 ACSL Programming Problem #2 – Junior Division
# Author :  Rahul Varma
# Language: Python 3.x
# -----------------------------------------------------------------------------------------


#-----------------------------------------------
# Main Functions to solve the problem

def eliminate(S1,S2):
    listS2 = list(S2)
    listS1 = list(S1)
    a = 0
    OriginalLen1 = len(listS1)
    OriginalLen2 = len(listS2)
    doublesS1 = 0
    doublesS2 = 0
    while a in range (0,len(listS1)-1):
        if (listS1[a] == listS1[a+1]):
           listS1.pop(a+1)
           
        a = a+1
    b =0
    while b in range (0,len(listS2)-1):
        if (listS2[b] == listS2[b+1]):
            listS2.pop(b+1)
        b = b+1
        
    i = 1

    while (i len(S2):
        result = S2
    if len(S1) == len(S2):
        bothS = [S1,S2]
        bothS.sort()
        result = bothS[0]

    return result



#-----------------------------------------------
# Auxiliary code for reading input and writing output
input = 'input.txt'
output = 'output.txt'

def readinput():
  words=[]
  with open(input) as f:
    lines = f.readlines()
    for line in lines:
      if line.split()!=[]:
        words.append(line.split())

  for j in range (0,len(words)):
    for i in range(0,len(words[j])):
      words[j][i]=(words[j][i])

  return words


def writeoutput(line):
  with open(output,'a') as f:
     f.write(str(line)+'\n')

def clearoutput():
  f=open(output,'w')
  f.write('')

allinputs = readinput()

clearoutput()
for line in allinputs:
    S1 = line[0]
    S2 = line[1]
    writeoutput(eliminate(S1, S2))
    print(eliminate(S1,S2))