The preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of the prefixes can be the full name. Typically there are multiple possible logins for each person.

You are given the first and the last name of a user. Return the alphabetically earliest login they can get (regardless of other potential Polygon users).

As a reminder, a prefix of a string s is its substring which occurs at the beginning of s: "a", "ab", "abc" etc. are prefixes of string "{abcdef}" but "b" and 'bc" are not. A string a is alphabetically earlier than a string b, if a is a prefix of b, or a and b coincide up to some position, and then a has a letter that is alphabetically earlier than the corresponding letter in b: "a" and "ab" are alphabetically earlier than "ac" but "b" and "ba" are alphabetically later than "ac".


-----Input-----

The input consists of a single line containing two space-separated strings: the first and the last names. Each character of each string is a lowercase English letter. The length of each string is between 1 and 10, inclusive. 


-----Output-----

Output a single string — alphabetically earliest possible login formed from these names. The output should be given in lowercase as well.


-----Examples-----
Input
harry potter

Output
hap

Input
tom riddle

Output
tomr

Difficulty: EASY

Solutions:
(first, last) = map(str, input().split())
string = first[0]
for i in first[1:]:
	if i < last[0]:
		string += i
	else:
		break
print(string + last[0])


(first, last) = input().split()
s = first[0]
for c in first[1:]:
	if c >= last[0]:
		break
	else:
		s += c
print(s + last[0])


X = input()
x = X.split()
fname = x[0]
sname = x[1]
ans = ''
for i in range(len(fname)):
	if i == 0:
		ans += fname[i]
	elif ord(fname[i]) < ord(sname[0]):
		ans += fname[i]
	else:
		break
ans += sname[0]
print(ans)


a = input().split()
b = a[0]
c = a[1]
x = len(b)
y = len(c)
i = 1
j = 1
lst = []
while i < x + 1:
	r = b[0:i]
	j = 1
	while j <= y + 1:
		s = c[0:j]
		k = r + s
		lst.append(k)
		j = j + 1
	i = i + 1
e = sorted(lst)
print(e[0])


src = input().split()
(a, b) = (src[0], src[1])
res = [a[0]]
(i, j) = (1, 0)
while i < len(a) and j == 0:
	if a[i] < b[j]:
		res.append(a[i])
		i += 1
	else:
		res.append(b[j])
		j += 1
if j == 0:
	res.append(b[0])
print(''.join(res))


s = input().split()
s1 = s[0][1:]
print(s[0][0], end='')
for i in s1:
	if ord(i) >= ord(s[1][0]):
		print(s[1][0], end='')
		break
	else:
		print(i, end='')
else:
	print(s[1][0], end='')


(a, b) = input().split()
print(a[0], end='')
for i in a[1:]:
	if i >= b[0]:
		break
	print(i, end='')
print(b[0])


(a, b) = input().split()
s = []
d = []
for i in range(1, len(a) + 1):
	s.append(a[0:i])
for i in range(1, len(b) + 1):
	d.append(b[0:i])
cur = s[0] + d[0]
for i in s:
	for j in d:
		if i + j < cur:
			cur = i + j
print(cur)


(a, b) = map(str, input().split())
k = 0
print(a[0], end='')
for i in range(1, len(a)):
	if str(a[i]) < str(b[k]):
		print(a[i], end='')
	else:
		print(b[0], end='')
		exit()
print(b[0])


s = input()
ans = ''
temp = s.split()
first = temp[0]
second = temp[1]
ans = first[0]
i = 1
for x in range(1, len(first)):
	if first[x] < second[0]:
		ans += first[x]
	else:
		break
ans += second[0]
print(ans)


(s, t) = map(str, input().split())
min_s = 'zzzzzzzzzzzzzzzzzzzz'
for i in range(len(s)):
	for j in range(len(t)):
		temp = s[:i + 1] + t[:j + 1]
		if temp < min_s:
			min_s = temp
print(min_s)


(n, m) = map(list, input().split())
print(n[0], end='')
for i in n[1:]:
	if ord(i) < ord(m[0]):
		print(i, end='')
	else:
		break
print(m[0])


import sys
import math
import itertools
import functools
import collections
import operator

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return ' '.join(map(str, arr))

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
(n, sn) = input().split()
ans = n[0]
for i in range(len(n) - 1):
	if n[i + 1] < sn[0]:
		ans += n[i + 1]
	else:
		break
print(ans + sn[0])


(first_name, last_name) = input().split()
first_done = first_name.lower()
last_done = last_name.lower()
login = first_name[0]
for i in range(1, len(first_name)):
	if ord(first_done[i]) < ord(last_done[0]):
		login += first_name[i]
	else:
		break
login += last_name[0]
print(login)


(n1, n2) = map(list, input().split())

def prefix(s):
	ans = []
	n = len(s)
	for i in range(1, n + 1):
		ans.append(s[:i])
	return ans
ans = [n1[0], n2[0]]
for i in prefix(n1):
	for j in prefix(n2):
		ans = min(ans, i + j)
print(''.join(ans))


(a, b) = input().split()
k = []
for i in range(len(a)):
	for j in range(len(b)):
		s = a[:i + 1] + b[:j + 1]
		k.append(s)
print(sorted(k)[0])


(a, b) = input().split(' ')
s = ''
(first, last) = (a, b)
(i, j) = (1, 0)
s += first[0]
while i < len(first) and first[i] < last[j]:
	s += first[i]
	i += 1
s += last[0]
print(s)


s = input().split()
n = s[1][0]
print(s[0][0], end='')
for i in range(1, len(s[0])):
	if s[0][i] < n:
		print(s[0][i], end='')
	else:
		print(n)
		exit(0)
print(n)


def main():
	(a, b) = input().split()
	for i in range(1, len(a)):
		if ord(a[i]) >= ord(b[0]):
			print(a[0:i] + b[0])
			break
	else:
		print(a + b[0])
try:
	while True:
		main()
except EOFError:
	pass


import sys
input = sys.stdin.readline
s = input().strip()
(f, l) = s.split()
u = f[0]
i = 1
while i < len(f) and f[i] < l[0]:
	u += f[i]
	i += 1
u += l[0]
print(u)


(f, l) = input().split()

def hey(f, l):
	s = f[0]
	for i in f[1:]:
		if i < l[0]:
			s += i
		else:
			s += l[0]
			return s
	s += l[0]
	return s
print(hey(f, l))


(s1, s2) = input().split()
s = []
for i in range(1, len(s1) + 1):
	for j in range(1, len(s2) + 1):
		s.append(s1[0:i] + s2[0:j])
s.sort()
print(s[0])


l = input().split(' ')
val = ord(l[1][0])
temp = l[0][1:]
count = 0
for c in temp:
	if ord(c) < val:
		count += 1
	else:
		break
print(l[0][0] + temp[:count] + l[1][0])


ins = input().split()
total = 1
ans = ins[0][0]
while total < len(ins[0]) and ins[0][total] < ins[1][0]:
	ans = ans + ins[0][total]
	total += 1
print(ans + ins[1][0])


(s, t) = input().split()
n = len(s)
m = len(t)
rec = []
for i in range(1, n + 1):
	for j in range(1, m + 1):
		rec.append(s[:i] + t[:j])
rec = sorted(rec)
print(rec[0])


(s1, s2) = map(str, input().split())
if len(s1) == 1:
	print(s1[0] + s2[0])
else:
	x = 1
	s = s1[0]
	while s1[x] < s2[0]:
		s += s1[x]
		x += 1
		if x == len(s1):
			break
	print(s + s2[0])


(x, y) = input().split()
z = x[0]
i = 1
while i < len(x):
	if x[i] < y[0]:
		z += x[i]
	else:
		z += y[0]
		break
	i += 1
if i == len(x):
	z += y[0]
print(z)


(a, b) = input().split()
c = []
f = ''
for i in range(len(a)):
	f += a[i]
	e = ''
	for j in range(len(b)):
		e += b[j]
		c.append(f + e)
c.sort()
print(c[0])


s = input().split(' ')
r = s[0][0]
for i in range(1, len(s[0])):
	if ord(s[0][i]) < ord(s[1][0]):
		r += s[0][i]
	else:
		break
print(r + s[1][0])


(a, b) = input().split()
compare = a[0] + b[0]
ans = a[0]
for i in a[1:]:
	if i < b[0]:
		ans += i
	else:
		break
print(ans + b[0])


import sys, bisect
(f, l) = list(sys.stdin.readline().split())
a = [f[0]]
b = [l[0]]
for i in range(1, len(f)):
	a.append(a[i - 1] + f[i])
for i in range(1, len(l)):
	b.append(b[i - 1] + l[i])
temp = []
for i in range(len(a)):
	for j in range(len(b)):
		temp.append(a[i] + b[j])
temp.sort()
print(temp[0])


(a, b) = input().split()
a = str(a)
b = str(b)
m = a[0]
t = 0
i = 0
flag = 0
while i < len(a) - 1:
	i = i + 1
	if a[i] < b[t]:
		m = m + a[i]
	else:
		m = m + b[t]
		flag = 1
		break
if i == len(a) - 1 and flag == 0:
	m = m + b[t]
print(m)


str = str(input())
s = str.split(' ')
a = s[0]
b = s[1]
ans = a + b
m = ''
n = ''
for i in a:
	m += i
	for j in b:
		n += j
		if ans > m + n:
			ans = m + n
	n = ''
print(ans)


(first, last) = input().split()
i = 1
while i < len(first) and first[i] < last[0]:
	i += 1
print(first[:i] + last[0])


from math import gcd, ceil
from collections import defaultdict as dd

def lcm(a, b):
	return a * b // gcd(a, b)

def inin():
	return int(input())

def inar():
	return list(map(int, input().split()))

def ar(element, size):
	return [element for i in range(size)]

def digitsum(num):
	su = 0
	while num:
		su += num % 10
		num //= 10
	return su
(n, t) = input().split()
title = t[0]
ans = n[0]
for i in n[1:]:
	if i >= title:
		break
	ans += i
ans += title
print(ans)


(n, s) = input().split()
last = s[0]
ans = n[0]
for x in n[1:]:
	if x < last:
		ans += x
	else:
		break
print(ans + last)


(s, t) = input().split()
res = s[0]
for c in s[1:]:
	if c >= t[0]:
		break
	res += c
print(res + t[0])


(f, l) = input().split(' ')
i = 1
while i < len(f) and f[i] < l[0]:
	i += 1
print(f[:i] + l[0])


(f, l) = input().split(' ')
ans = ''
ans += f[0]
i = 1
j = 0
while True:
	if i == len(f):
		ans += l[j]
		break
	x = ord(f[i])
	y = ord(l[j])
	if x < y:
		ans += f[i]
		i += 1
	else:
		ans += l[j]
		break
print(ans)


((s1, s2), l) = (input().split(), list())
for i in range(len(s1)):
	for i1 in range(len(s2)):
		l.append(s1[:i + 1] + s2[:i1 + 1])
print(min(l))


import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 10 ** 9 + 7

def lcm(x, y):
	return x * y / gcd(x, y)

def fact(x, mod=mod):
	ans = 1
	for i in range(1, x + 1):
		ans = ans * i % mod
	return ans

def arr2D(n, m, default=0):
	lst = []
	for i in range(n):
		temp = [default] * m
		lst.append(temp)
	return lst

def sortDictV(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}

def solve(a, b):
	(i, j) = (0, 0)
	ans = ''
	while i < len(a) or j < len(a):
		if i == 0 or (i < len(a) and ord(a[i]) < ord(b[j])):
			ans += a[i]
			i += 1
		else:
			ans += b[j]
			break
	return ans
(a, b) = input().split()
print(solve(a, b))


(n, s) = map(str, input().strip().split())
un = [n[0]]
for i in range(1, len(n)):
	if n[i] < s[0]:
		un.append(n[i])
	else:
		un.append(s[0])
		break
if un[-1] != s[0] or len(un) <= 1:
	un.append(s[0])
for i in un:
	print(i, end='')


s = input().lower()
l = s.split()
ans = ''
ans += l[0][0]
i = 1
while i < len(l[0]) and ans + l[0][i] < ans + l[1][0]:
	ans += l[0][i]
	i += 1
i = 1
ans += l[1][0]
while i < len(l[1]) and ans + l[1][i] < ans:
	ans += l[1][i]
	i += 1
print(ans)


(a, b) = input().split()
ans = []
for x in range(1, len(a) + 1):
	for y in range(1, len(b) + 1):
		ans.append(a[:x] + b[:y])
ans = sorted(ans)
print(ans[0])


(a, b) = input().split()
ans = a[0]
for i in range(1, len(a)):
	if a[i] < b[0]:
		ans += a[i]
	else:
		break
ans += b[0]
print(ans)


(s1, s2) = input().split()
i = 1
print(s1[0], end='')
while i < len(s1) and s2[0] > s1[i]:
	print(s1[i], end='')
	i += 1
print(s2[0])


(a, b) = input().split()
i = 1
while i < len(a) and a[i] < b[0]:
	i += 1
print(a[:i] + b[0])


def get_username(ls):
	name = ls[0]
	surname = ls[1]
	username = [name[0]]
	i = 1
	j = 0
	while True:
		if i >= len(name):
			username.append(surname[j])
			return ''.join(username)
		if name[i] < surname[j]:
			username.append(name[i])
			i += 1
		else:
			username.append(surname[j])
			return ''.join(username)
s = input()
ls = s.split(' ')
print(get_username(ls))


import sys
name = sys.stdin.readline()
(firstname, lastname) = name.split()
logins = []
for i in range(len(firstname)):
	for j in range(len(lastname)):
		logins.append(firstname[:i + 1] + lastname[:j + 1])
print(sorted(logins)[0])


(string1, string2) = list(input().split())
second_elem = string2[0]
res = '' + string1[0]
flag = 1
for (ind, elem) in enumerate(string1):
	if ind == 0:
		continue
	if elem >= second_elem:
		res += second_elem
		flag = 0
		break
	else:
		res += elem
if flag:
	res += second_elem
print(res)


x = input().split()
a = x[0][0]
for i in range(1, len(x[0])):
	if x[0][i] < x[1][0]:
		a += x[0][i]
	else:
		break
a += x[1][0]
print(a)


arr = input().split()
strings = []
for i in range(0, len(arr[0]), 1):
	for j in range(0, len(arr[1]), 1):
		string_here = arr[0][:i + 1] + arr[1][:j + 1]
		strings = strings + [string_here]
strings.sort()
print(strings[0])


(a, b) = map(str, input().split())
j = 0
k = 0
for i in range(1, len(a)):
	if ord(a[i]) >= ord(b[0]):
		j = i
		break
	else:
		k += 1
if k == len(a) - 1:
	print(a + b[0])
else:
	print(a[:j] + b[0])


(a, b) = input().split(' ')
aa = []
bb = []
for i in range(len(a)):
	aa.append(a[:i + 1])
for i in range(len(b)):
	bb.append(b[:i + 1])
aa.sort()
bb.sort()
c = []
for x in aa:
	for y in bb:
		c.append(x + y)
c.sort()
print(c[0])


(s, r) = map(str, input().split())
s = list(s)
r = list(r)
k = [s[0]]
q = r[0]
for j in range(1, len(s)):
	if s[j] < q:
		k.append(s[j])
	else:
		break
k.append(q)
print(''.join(k))


s = [str(i) for i in input().split(' ')]
(a, b) = (s[0], s[1])
w = a[0]
for i in range(1, len(a)):
	if b[0] > a[i]:
		w += a[i]
	else:
		break
print(w + b[0])


(im, fam) = input().split()
ans = str()
for (i, el) in enumerate(im[:-1]):
	if im[i + 1] >= fam[0]:
		ans = im[:i + 1] + fam[0]
		break
else:
	ans = im + fam[0]
print(ans)


t = list(input())
n = len(t)
for i in range(n):
	if t[i] == ' ':
		s = i + 1
		break
j = 0
k = 0
h = s - 1
fla = 0
li = []
li.append(t[j])
while fla == 0:
	if t[j + 1] < t[s] and fla == 0 and (j < h - 1):
		li.append(t[j + 1])
		j = j + 1
	elif t[j + 1] >= t[s] and j < h - 1 and (fla == 0):
		fla = 1
		li.append(t[s])
	elif j == h - 1:
		j = j + 1
		li.append(t[s])
		fla = 1
x = len(li)
for v in range(x):
	print(li[v], end='')


x = input()
n = len(x)
a = ''
b = ''
i = 0
while x[i] != ' ':
	a += x[i]
	i += 1
i += 1
b = x[i:n]
c = a[0]
i = 1
while i != len(a) and a[i] < b[0]:
	c += a[i]
	i += 1
c += b[0]
print(c)


S = input()
(X, Y) = S.split()
ans = ''
n = len(X)
m = len(Y)
i = 1
while i < n:
	if X[i] < Y[0]:
		ans += X[i]
		i += 1
	else:
		break
print(X[0] + ans + Y[0])


n = str(input())
i = 0
b = ''
while n[i] != ' ':
	b = b + n[i]
	i = i + 1
ans = ''
ans = ans + n[0]
for j in range(1, len(b)):
	if n[j] < n[i + 1]:
		ans = ans + n[j]
	else:
		break
ans = ans + n[i + 1]
print(ans)


x = input()
a = x.split()
string = a[0][0]
i = 1
while i < len(a[0]) and ord(a[0][i]) < ord(a[1][0]):
	string += a[0][i]
	i += 1
string += a[1][0]
print(string)


(esem, la9ab) = input().split()
ch = esem[0]
lett = esem[0]
for i in range(1, len(esem)):
	if esem[i] < la9ab[0]:
		ch += esem[i]
	else:
		break
ch += la9ab[0]
print(ch)


(first, last) = map(str, input().split())
ans = first[0]
for c in range(1, len(first)):
	if first[c] < last[0]:
		ans += first[c]
	else:
		break
ans += last[0]
print(ans)


name = input().split()
a = ord(name[1][0])
st = name[0][0]
i = 1
try:
	while ord(name[0][i]) < a:
		st += name[0][i]
		i += 1
		if i == len(name[0]):
			break
except IndexError:
	pass
st += name[1][0]
print(st)


from itertools import takewhile
(u, v) = input().split()
print(u[0] + ''.join(list(takewhile(lambda x: x < v[0], u[1:]))) + v[0])


s = input()
x = s.split(' ')
f = x[0]
sec = x[1]
ans = f[0]
f = f.replace(ans, '', 1)
last = sec[0]
for i in f:
	if i < last:
		ans += i
	else:
		break
print(ans + last)


(a, b) = input().split()
ans = a[0] + b[0]
for i in range(len(a)):
	for j in range(len(b)):
		t = a[:i + 1] + b[:j + 1]
		ans = min(ans, t)
print(ans)


names = input().split()
login = names[0][0]
for i in range(1, len(names[0])):
	if ord(names[0][i]) < ord(names[1][0]):
		login += names[0][i]
	else:
		login += names[1][0]
		break
else:
	login += names[1][0]
print(login)


(f, s) = input().split()
l = f[0]
for c in f[1:]:
	if c >= s[0]:
		break
	l += c
print(l + s[0])


s = input().lower().split(' ')
x = s[0][0] + s[1][0]
i = 1
while i < len(s[0]):
	t = x[:-1] + s[0][i] + x[-1]
	if t < x:
		x = t
	else:
		break
	i = i + 1
print(x)


(fn, ln) = input().split()

def gensub(s):
	res = []
	n = len(s)
	for i in range(1, n + 1):
		res.append(s[0:i])
	return res
gfn = gensub(fn)
gln = gensub(ln)
names = [f + l for f in gfn for l in gln]
print(min(names))


(first, last) = input().split()
first = list(first)
last = list(last)
s = []
s.append(first[0])
k = 0
j = 0
flag = 1
for i in range(len(first) - 1):
	if last[j] > first[k + 1]:
		s.append(first[k + 1])
		k += 1
	else:
		flag = 0
		s.append(last[j])
		break
if flag == 1:
	s.append(last[j])
print(''.join(s))


(a, b) = input().split()
s = a[0] + b[0]
c = a[0]
for i in range(1, len(a)):
	c += a[i]
	if c + b[0] < s:
		s = c + b[0]
print(s)


(first, last) = tuple(input().split())
search_space = []
for i in range(1, len(first) + 1):
	for j in range(1, len(last) + 1):
		search_space.append(first[:i] + last[:j])
print(min(search_space))


(f, l) = input().split(' ')
ans = []
ans.append(f[0])
f = f[1:]
ch = l[0]
flag = 0
for i in f:
	if ord(ch) <= ord(i):
		ans.append(ch)
		flag = 1
		break
	else:
		ans.append(i)
if flag == 0:
	ans.append(l[0])
print(''.join(map(str, ans)))


[n, s] = input().split(' ')
nl = [n[0:i] for i in range(1, len(n) + 1)]
sl = [s[0:i] for i in range(1, len(s) + 1)]
l = []
for x in nl:
	for y in sl:
		l.append(x + y)
print(sorted(l)[0])


(q, w) = input().split()
s = q[0]
q = q[1:]
while len(q) > 0:
	if q[0] < w[0]:
		s += q[0]
		q = q[1:]
	else:
		q = ''
print(s + w[0])


(name, surname) = input().split()
ans = name[0]
for i in name[1:]:
	if i < surname[0]:
		ans += i
	else:
		break
ans += surname[0]
print(ans)


n = input().split()
w = n[0]
v = n[1]
z = w[0]
for i in w[1:]:
	if ord(i) < ord(v[0]):
		z = z + i
	else:
		break
z = z + v[0]
print(z)


(f, s) = input().strip().split()
print(f[0], end='')
for i in range(1, len(f)):
	if f[i] < s[0]:
		print(f[i], end='')
	else:
		break
print(s[0], end='')


(f, l) = input().strip().split()
ans = f[0]
i = 1
while i < len(f) and f[i] < l[0]:
	ans += f[i]
	i += 1
ans += l[0]
print(ans)


s = list(input().split())
a = []
for i in range(len(s[0])):
	for j in range(len(s[1])):
		a.append(s[0][0:i + 1] + s[1][0:j + 1])
print(min(a))


(x, y) = input().split()
mn = 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzz'
for i in range(len(x)):
	for j in range(len(y)):
		z = x[:i + 1] + y[:j + 1]
		mn = min(mn, z)
print(mn)


def getprfx(s):
	tab = [s[0]]
	for i in range(1, len(s)):
		x = tab[i - 1] + s[i]
		tab.append(x)
	return tab
(n, m) = input().split()
(a, b) = (getprfx(n), getprfx(m))
mn = a[0] + b[0]
for i in a:
	for j in b:
		if i + j < mn:
			mn = i + j
print(mn)


s3 = input()
s1 = s3.split()[0]
s2 = s3.split()[1]
l1 = len(s1)
l2 = len(s2)
v = []
for i in range(0, l1):
	for j in range(0, l2):
		ans = ''
		for k in range(0, i + 1):
			ans = ans + s1[k]
		for k in range(0, j + 1):
			ans = ans + s2[k]
		v.append(ans)
v.sort()
print(v[0])


def main():
	(s, t) = input().split()
	minimal = ''
	for i in range(len(s) + 1):
		for j in range(len(t) + 1):
			if not i or not j:
				continue
			else:
				pref = s[:i] + t[:j]
				minimal = pref if not minimal else min(minimal, pref)
	print(minimal)
main()


(f, l) = map(str, input().split())
i = 1
j = 0
while i < len(f):
	if ord(f[i]) < ord(l[j]):
		i += 1
	else:
		break
print(f[0:i] + l[0])


def main():
	(first, last) = input().split(' ')
	check = chr(123)
	list1 = []
	check = last[0]
	c = 0
	for item in first:
		if item < check or c == 0:
			list1.append(item)
			c = 1
		else:
			break
	for i in list1:
		print(i, end='')
	print(last[0], end='')
main()


name = input().split(' ')
out = [name[0][0]]
for i in range(1, len(name[0])):
	if name[0][i] < name[1][0]:
		out.extend(name[0][i])
	else:
		break
out.extend(name[1][0])
for i in range(len(out)):
	print(out[i], end='')


(name, surname) = input().split()
res = name[0] + ''
for i in range(2, len(name) + 1):
	if name[i - 1:i] < surname[0]:
		res += name[i - 1:i]
	else:
		break
res += surname[0]
print(res)


(n, m) = input().split()
ans = n[0]
i = 1
while i != len(n):
	if n[i] < m[0]:
		ans = ans + n[i]
	else:
		break
	i = i + 1
ans = ans + m[0]
print(ans)


(name, surname) = input().split()
ans = name[0] + surname[0]
for i in range(len(name)):
	cur_ans = name[:i + 1]
	for j in range(len(surname)):
		cur_ans += surname[:j + 1]
		ans = min(ans, cur_ans)
print(ans)


def main():
	(F, L) = input().split()
	id = []
	apnd = id.append
	for i in range(1, len(F) + 1):
		apnd(F[:i] + L[0])
	print(min(id))
main()


(a, b) = map(str, input().split())
l = []
for i in range(len(str(a))):
	for j in range(len(str(b))):
		l.append(a[0:i + 1] + b[0:j + 1])
l.sort()
print(l[0])


from collections import Counter, deque

def lInt(d=None):
	return map(int, input().split(d))
(s, t) = input().split(' ')
ans = 'zzzzzzzzzzzzzzzzzzzz'
for i in range(1, len(s) + 1):
	for j in range(1, len(t) + 1):
		x = s[:i] + t[:j]
		ans = min(ans, x)
print(ans)


s = input()
sl = s.split(' ')
s1 = sl[0]
s2 = sl[1]
i = 0
j = 0
ans = ''
ans += s1[0]
for i in range(1, len(s1)):
	if s1[i] >= s2[0]:
		break
	else:
		ans += s1[i]
ans += s2[0]
print(ans)


(n1, n2) = input().split()
minlog = n1[0] + n2[0]
for i in range(len(n1)):
	for j in range(len(n2)):
		log = n1[:i + 1] + n2[:j + 1]
		if log < minlog:
			minlog = log
print(minlog)


import sys

def Rint():
	return map(int, input().split())
for line in sys.stdin:
	(a, b) = line.split()
	ac = [ord(c) for c in a]
	bc = [ord(c) for c in b]
	ans = []
	ia = 0
	na = len(a)
	ib = 0
	nb = len(b)
	while ia < na and ib == 0 and (ib < nb):
		if ia == 0 and ib == 0:
			ans += a[ia]
			ia += 1
			continue
		if ac[ia] < bc[ib]:
			ans += a[ia]
			ia += 1
		else:
			ans += b[ib]
			ib += 1
	if ib == 0:
		ans += b[ib]
	print(''.join(ans))


niz = input().strip().split()
I = niz[0]
P = niz[1]
s = I[0]
i = 1
while i < len(I) and I[i] < P[0]:
	s += I[i]
	i += 1
j = 0
s += P[0]
print(s)


m = []
i = 1
(a, b) = map(str, input().split())
while True:
	if len(a) - 1 >= i and a[i] < b[0]:
		m.append(a[i])
		i += 1
	else:
		m.append(b[0])
		break
print(a[0] + ''.join(m))


(s1, s2) = input().split(' ')
ans = 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'
for i in range(1, len(s1) + 1):
	for j in range(1, len(s2) + 1):
		if ans > s1[:i] + s2[:j]:
			ans = s1[:i] + s2[:j]
print(ans)


(f, l) = input().split()
n = []
for i in range(len(f)):
	for j in range(len(l)):
		n.append(f[:i + 1] + l[:j + 1])
print(sorted(n)[0])


name = input().strip().split()
(a, b) = (name[0], name[1])
all_name = []
for i in range(1, len(a) + 1):
	for j in range(1, len(b) + 1):
		new = a[:i] + b[:j]
		all_name.append(new)
all_name.sort()
print(all_name[0])


s = input()
li = s.split(' ')
s1 = li[0]
s2 = li[1]
len1 = len(s1)
len2 = len(s2)
f = 0
i = 1
while i < len1:
	if s1[i] >= s2[0]:
		f = 1
		ans = s1[0:i]
		break
	i = i + 1
if f == 0:
	ans = s1
ans += s2[0:1]
print(ans)


(a, b) = list(map(str, input().split()))
an = -1
for i in range(len(a)):
	for j in range(len(b)):
		c = int(i == -1) + int(j == -1)
		if an == -1 or a[0:i + 1] + b[0:j + 1] < an:
			an = a[0:i + 1] + b[0:j + 1]
print(an)


a = [str(i) for i in input().split()]
ans = ''
ans += a[0][0]
for i in range(1, len(a[0])):
	if ord(a[0][i]) < ord(a[1][0]):
		ans += a[0][i]
	else:
		break
ans += a[1][0]
print(ans)


(a, b) = map(str, input().split())
print(a[0], end='')
ok = 0
for i in a:
	if ok == 0:
		ok = 1
		continue
	if i >= b[0]:
		break
	print(i, end='')
print(b[0])


(f, l) = map(str, input().split(' '))
ans = f[0]
i = 1
while i < len(f) and f[i] < l[0]:
	ans += f[i]
	i += 1
print(ans + l[0])


(f, l) = map(str, input().split())
s = ''
for i in range(1, len(f)):
	if f[i] < l[0]:
		s += str(f[i])
	else:
		break
print(f[0] + s + l[0])


(s, r) = input().split()
(n, m) = (len(s), len(r))
l = s[0]
for i in range(1, n):
	if s[i] < r[0]:
		l = l + s[i]
	else:
		break
l = l + r[0]
print(l)


(a, b) = input().split()
ans = 'z' * 100
for i in range(1, len(a) + 1):
	for j in range(1, len(b) + 1):
		if a[:i] + b[:j] < ans:
			ans = a[:i] + b[:j]
print(ans)


(f, l) = input().split()
t1 = f[0]
k1 = ord(t1)
t2 = l[0]
k2 = ord(t2)
for s in f[1:]:
	if ord(s) < k2:
		t1 += s
	else:
		break
print(t1 + t2)


s = input().split()
first_name = s[0]
last_name = s[1]
result = first_name[0]
for i in range(1, len(first_name)):
	if first_name[i] < last_name[0]:
		result = result + first_name[i]
	else:
		break
result = result + last_name[0]
print(result)


m = 'z' * 100
(fname, sname) = input().split()
for i in range(1, len(fname) + 1):
	for j in range(1, len(sname) + 1):
		now = fname[:i] + sname[:j]
		if now < m:
			m = now
print(m)


(a, b) = input().split()
l = len(a)
li = [a[0], b[0]]
j = 1
for i in range(1, l):
	if li[-1] > a[i]:
		li.insert(j, a[i])
	else:
		break
	j += 1
print(''.join(li))


import sys
f = sys.stdin
(fn, ln) = f.readline().split()
ans = fn[0]
lfc = ln[0]
cl2 = lfc
for x in fn[1:]:
	if x < cl2:
		ans = ans + x
	else:
		break
print(ans + lfc)


[f_name, s_name] = input().split(' ')
choices = []
f_len = len(f_name)
s_len = len(s_name)
for f in range(f_len):
	for s in range(s_len):
		choices.append(f_name[:f + 1] + s_name[:s + 1])
choices.sort()
print(choices[0])


(first, last) = input().split()
username = first[0]
first = first[1:]
while first != '' and first[0] < last[0]:
	username = username + first[0]
	first = first[1:]
print(username + last[0])


(f, s) = input().split()
lenf = len(f)
lens = len(s)
temp = []
for i in range(1, lenf + 1):
	for j in range(1, lens + 1):
		temp.append(f[0:i] + s[0:j])
temp.sort()
print(temp[0])


(x, y) = map(str, input().split())
n = 0
ls = []
m = len(x)
for i in range(m):
	if i == 0:
		ls.append(x[i])
	elif x[i] < y[0]:
		ls.append(x[i])
	else:
		break
ls.append(y[0])
print(''.join(ls))


(a, b) = input().split()
l = []
for i in range(len(a)):
	for j in range(len(b)):
		l.append(a[:i + 1] + b[:j + 1])
l = sorted(l)
print(l[0])


(a, b) = input().split()
res = a[0]
for (index, c) in enumerate(a):
	if index == 0:
		continue
	if c < b[0]:
		res += c
	else:
		break
res += b[0]
print(res)


(s, t) = input().split()
m = 'z' * 100
for i in range(1, len(s) + 1):
	for j in range(1, len(t) + 1):
		m = min(m, s[:i] + t[:j])
print(m)


S = input()
names = S.split()
fn = names[0]
ln = names[1]
poss = []
for i in range(1, len(fn) + 1):
	for j in range(1, len(ln) + 1):
		poss.append(fn[0:i] + ln[0:j])
poss.sort()
print(poss[0])


([a, b], r) = (input().split(), '')
for (i, c) in enumerate(a):
	if i == 0 or c < b[0]:
		r += c
	else:
		break
print(r + b[0])


(f, s) = input().strip().split()
names = []
for fi in range(1, len(f) + 1):
	for si in range(1, len(s) + 1):
		names.append(f[:fi] + s[:si])
names.sort()
print(names[0])


line = input().split(' ')
fname = line[0]
lname = line[1]
f = 1
l = 0
ret = fname[0]
while f < len(fname) and fname[f] < lname[l]:
	ret += fname[f]
	f += 1
ret += lname[0]
print(ret)


def main():
	(first, second) = input().split()
	foo = set()
	for i in range(len(first)):
		for j in range(len(second)):
			foo.add(first[:i + 1] + second[:j + 1])
	print(min(foo))
main()


N = input().split(' ')
first = N[0]
last = N[1]
ans = first[0]
for i in range(1, len(first)):
	if first[i] < last[0]:
		ans += first[i]
	else:
		break
ans += last[0]
print(ans)


(a, b) = map(str, input().split())
ans = a[0]
i = 1
while i < len(a) and a[i] < b[0]:
	ans += a[i]
	i += 1
ans += b[0]
print(ans)


(n, s) = input().split()
viv = n[0]
for i in range(1, len(n)):
	if ord(n[i]) >= ord(s[0]):
		print(viv + s[0])
		break
	viv += n[i]
else:
	print(viv + s[0])


(first_name, last_name) = list(map(str, input().split()))
i = 1
ans = first_name[0]
while i < len(first_name) and first_name[i] < last_name[0]:
	ans = ans + first_name[i]
	i = i + 1
ans = ans + last_name[0]
print(ans)


s = input().split()
new = ''
for i in range(len(s[0])):
	if i:
		if s[0][i] < s[1][0]:
			new += s[0][i]
		else:
			break
	else:
		new += s[0][i]
print(new + s[1][0])


a = input()
j = a.index(' ')
s1 = a[1:j]
s2 = a[j + 1:]
s = a[0]
flag = 0
for it in range(0, len(s1)):
	if ord(s1[it]) < ord(s2[0]):
		s = s + s1[it]
		continue
	else:
		s = s + s2[0]
		flag = 1
		break
if flag == 0:
	s = a[0] + s1 + s2[0]
print(s)


(s1, s2) = input().split()
ans = s1[0]
ans = []
n1 = len(s1)
n2 = len(s2)
for end1 in range(1, n1 + 1):
	for end2 in range(1, n2 + 1):
		ans.append(s1[0:end1] + s2[0:end2])
ans.sort()
print(ans[0])


s = input()
(n, f) = s.split(' ')
s = n[0]
i = 1
while i < len(n) and n[i] < f[0]:
	s += n[i]
	i += 1
print(s + f[0])


inu = input().split()
(first, last) = (inu[0], inu[1])
(l, name, st) = ([], '', '')
for fi in first:
	st = st + fi
	name = st
	for se in last:
		name = name + se
		l.append(name)
l.sort()
print(l[0])


(sou, dest) = input().split(' ')
dest1 = dest[0]
g = ord(dest1)
s = sou[0]
r = len(sou)
for j in range(1, r):
	i = sou[j]
	f = ord(i)
	if f < g:
		s += i
	else:
		break
print(s + dest1)


(first, last) = input().split()
if len(first) == 1:
	print(first[0] + last[0])
else:
	i = 1
	while i < len(first) and first[i] < last[0]:
		i += 1
	print(first[:i] + last[0])


n = input().strip().split()
index = 0
for i in range(1, len(n[0])):
	if ord(n[0][i]) < ord(n[1][0]):
		index = i
	else:
		break
output = ''
for j in range(index + 1):
	output += n[0][j]
output += n[1][0]
print(output)


import sys
a = sys.stdin.readline().split()
new = []
n = ''
for i in range(len(a[0])):
	n += a[0][i]
	new.append(n + a[1][0])
new.sort()
print(new[0])


s = input().split()
d = set()
for i in range(1, len(s[0]) + 1):
	for j in range(1, len(s[1]) + 1):
		d.add(s[0][:i] + s[1][:j])
print(sorted(d)[0])


string = input().split()
print(string[0][0], end='')
for x in range(1, len(string[0])):
	if string[0][x] < string[1][0]:
		print(string[0][x], end='')
	else:
		break
print(string[1][0])


(s1, s2) = input().split()
rez = s1[0]
i = 1
while i < len(s1) and s1[i] < s2[0]:
	rez += s1[i]
	i += 1
rez += s2[0]
print(rez)


import sys
read = sys.stdin.readline
(fn, ln) = read().strip().split()
ans = fn[0]
for _fn in fn[1:]:
	if _fn < ln[0]:
		ans += _fn
	else:
		break
print(ans + ln[0])


S = list(map(str, input().split()))
X = []
for i in range(1, len(S[0]) + 1):
	p = S[0][0:i]
	for j in range(1, len(S[1]) + 1):
		q = S[1][0:j]
		X.append(p + q)
X.sort()
print(X[0])


(s1, s2) = input().split()
minn = 'zzzzzzzzzzzzzzzzz'
for i in range(1, len(s1) + 1):
	for j in range(1, len(s2) + 1):
		if s1[:i] + s2[:j] < minn:
			minn = s1[:i] + s2[:j]
print(minn)


from sys import stdin, stdout
(input, print) = (stdin.readline, stdout.write)
(a, b) = [i for i in input().split()]
ans = a[0]
for i in a[1:]:
	if i < b[0]:
		ans += i
	else:
		break
ans += b[0]
print(ans)


(ass, bss) = input().split()
c = []
r = ''
for i in range(len(ass)):
	r += ass[i]
	g = ''
	for j in range(len(bss)):
		g += bss[j]
		c.append(r + g)
c.sort()
print(c[0])


(n1, n2) = input().split()
(l, i, f) = (n1[0], 1, n2[0])
while i < len(n1) and n1[i] < f:
	l += n1[i]
	i += 1
print(l + f)


(firstname, lastname) = input().split()
a = firstname[0]
for i in range(1, len(firstname)):
	if ord(firstname[i]) < ord(lastname[0]):
		a += firstname[i]
	else:
		break
print(a + lastname[0])


(name, surname) = input().split()
counter = 1
for i in range(1, len(name)):
	if name[i] >= surname[0]:
		break
	counter += 1
result = name[:counter] + surname[0]
print(result)


(s1, s2) = input().split()
ans = s1[0]
i = 1
while i < len(s1) and s1[i] < s2[0]:
	ans += s1[i]
	i += 1
ans += s2[0]
print(ans)


a = str(input())
for i in range(0, len(a) - 1):
	if ord(a[i]) == 32:
		nam = a[:i]
		fam = a[i + 1:]
		break
ans = []
ans.append(nam[0])
nam += 'z'
for i in range(1, len(nam)):
	if nam[i] < fam[0]:
		ans.append(nam[i])
	else:
		ans.append(fam[0])
		break
print(''.join(ans))


(first, last) = map(str, input().split())
checkedagainst = last[0]
ans = first[0]
for i in range(1, len(first)):
	if ord(first[i]) < ord(checkedagainst):
		ans += first[i]
	else:
		break
ans += checkedagainst
print(ans)


(f, l) = input().split()
s = f[0]
for i in range(1, len(f)):
	if ord(f[i]) >= ord(l[0]):
		break
	s += f[i]
s += l[0]
print(s)


(a, b) = input().split()
best = a[0] + b[0]
for i_a in range(len(a)):
	for i_b in range(len(b)):
		cur = a[0:i_a + 1] + b[0:i_b + 1]
		if cur < best:
			best = cur
print(best)


s = str(input())
s = s.split()
a = s[0]
b = s[1][0]
d = a[0]
for i in range(1, len(a)):
	if ord(a[i]) < ord(b):
		d = d + a[i]
	elif ord(a[i]) == ord(b):
		break
	else:
		break
print(d + b)


(f, l) = input().split()
id = '' + f[0]
f = f[1:]
id_2 = ''

def func(f, l):
	global id_2
	if len(f) == 0:
		id_2 = id_2 + l[0]
		print(id + id_2)
	else:
		lst = [f[0], l[0]]
		lst.sort()
		id_2 = id_2 + lst[0]
		if lst[0] == l[0]:
			print(id + id_2)
		else:
			f = f[1:]
			func(f, l)
func(f, l)


z = input().split()
fn = z[0]
ln = z[1]
print(fn[0], end='')
for i in range(1, len(fn), 1):
	if fn[i] < ln[0]:
		print(fn[i], end='')
	else:
		break
print(ln[0])


(name, family) = input().split()
a = []
for i in range(len(name)):
	for j in range(len(family)):
		s = name[:i + 1] + family[:j + 1]
		a.append(s)
a.sort()
print(a[0])


(name, surname) = map(str, input().split())
name = list(name)
surname = list(surname)
lenName = len(name)
lenSurname = len(surname)
stringList = []
for i in range(1, len(name) + 1):
	for j in range(1, len(surname) + 1):
		newString = name[0:i] + surname[0:j]
		stringList.append(newString)
newList = sorted(stringList)
a = newList[0]
b = ''.join(a)
print(b)


line = input()
a = line.split(' ')[0]
b = line.split(' ')[1]
ans = 'zzzzzzzzzz'
for i in range(len(a)):
	for j in range(len(b)):
		temp = a[:i + 1] + b[:j + 1]
		ans = min(temp, ans)
print(ans)


(fname, lname) = map(str, input().split())
ans = []
ans.append(fname[0])
for i in range(1, len(fname)):
	if fname[i] < lname[0]:
		ans.append(fname[i])
	else:
		break
ans.append(lname[0])
string = ''.join(ans)
print(string)


(x, y) = input().split(' ')
a = []
for i in range(1, len(x) + 1):
	for j in range(1, len(y) + 1):
		a.append(x[:i] + y[:j])
a.sort()
print(a[0])


(a, b) = input().split()
s = a[0]
c = a[1:]
for i in range(len(c)):
	if c[i] < b[0]:
		s += c[i]
	else:
		break
t = s + b[0]
print(t)


s = input()
fir = s.split()[0]
las = s.split()[1]
f = [fir[0]]
l = [las[0]]
t = las[0]
i = 1
while i < len(fir) and ord(t) > ord(fir[i]):
	f.append(fir[i])
	i += 1
print(''.join(f) + t)


N = list(map(str, input().split()))
(fn, ln) = (str(N[0]), str(N[1]))
un = ''
flag = 0
i = 1
un = un + fn[0]
while i < len(fn):
	if fn[i] < ln[0]:
		un = un + fn[i]
		i = i + 1
	else:
		un = un + ln[0]
		flag = 1
		break
if flag == 0:
	un = un + ln[0]
	print(un)
else:
	print(un)


(s, t) = input().split()
l = []
for i in range(len(s)):
	for j in range(len(t)):
		l.append(s[:i + 1] + t[:j + 1])
l.sort()
print(l[0])


(f, l) = list(map(str, input().split()))
fr = f[0]
lr = l[0]
for i in range(1, len(f)):
	if ord(f[i]) < ord(lr):
		fr += f[i]
	else:
		break
fr += lr
print(fr)


(name, surname) = input().split(' ')[:2]
best = ''
first = True
for lenName in range(1, len(name) + 1):
	for lenSName in range(1, len(surname) + 1):
		candidate = name[:lenName] + surname[:lenSName]
		if first or candidate < best:
			best = candidate
			first = False
print(best)


(n, p) = input().split()
d = n[0]
for i in range(1, len(n)):
	if n[i] < p[0]:
		d += n[i]
	else:
		break
print(d + p[0])


(n, s) = input().split()
l = 'z' * 100
for i in range(1, len(n) + 1):
	for j in range(1, len(s) + 1):
		l1 = n[:i] + s[:j]
		if l1 < l:
			l = l1
print(l)


s = input().split()
pos = []
if len(s[0]) == len(s[1]) == 1:
	print(s[0] + s[1])
else:
	for i in range(1, len(s[0]) + 1):
		for j in range(1, len(s[1]) + 1):
			pos.append(s[0][:i] + s[1][:j])
	pos.sort()
	print(pos[0])


(s1, s2) = input().split()
ans = s1[0]
for j in s1[1:]:
	if j < s2[0]:
		ans = ans + j
	else:
		break
ans += s2[0]
print(ans)


s = input().split(' ')
result = s[0][0]
end = s[1][0]
for i in range(1, len(s[0])):
	if ord(s[0][i]) < ord(end):
		result += s[0][i]
	else:
		break
result += end
print(result)


(s1, s2) = input().split()
s3 = s1[0]
i = 1
j = 0
while i < len(s1) and j < len(s2):
	if s1[i] < s2[j]:
		s3 += s1[i]
		i += 1
	else:
		s3 += s2[j]
		j += 1
		break
if j == 0:
	s3 += s2[j]
print(s3)


y = list(map(str, input().split()))
(a, b) = (y[0], y[1])
ind = b[0]
s = ''
s += a[0]
for i in range(1, len(a)):
	if a[i] < ind:
		s += a[i]
	else:
		break
s += ind
print(s)


(first, last) = str(input()).split(' ')
best = None
for i in range(1, len(first) + 1):
	for j in range(1, len(last) + 1):
		cand = first[:i] + last[:j]
		if best is None or cand < best:
			best = cand
print(best)


(st1, st2) = input().split()
d = 0
for i in st1:
	if i < st2[0] or not d:
		d = 1
		print(i, end='')
	else:
		break
print(st2[0])


def main():
	(first, last) = input().split()
	print(min((first[:i] + last[:j] for i in range(1, len(first) + 1) for j in range(1, len(last) + 1))))
main()


from collections import *
import itertools
import sys

def main():
	(a, b) = input().split()
	ans = a + b
	n = len(a)
	m = len(b)
	for i in range(1, n + 1):
		for j in range(1, m + 1):
			c = a[:i] + b[:j]
			ans = min(ans, c)
	print(ans)
main()


s = input().split(' ')
l = []
s1 = s[0]
s2 = s[1]
for i in range(1, len(s1) + 1):
	l.append(s1[0:i])
p = []
for i in range(1, len(s2) + 1):
	p.append(s2[0:i])
m = []
for i in range(0, len(l)):
	for j in range(0, len(p)):
		m.append(l[i] + p[j])
m.sort()
print(m[0])


name = input()
name = name.split(' ')
count = 0
for ch in name[0]:
	if count == 0:
		count += 1
		print(ch, end='')
	elif ch < name[1][0]:
		print(ch, end='')
	else:
		break
count = 0
print(name[1][0])


(a, b) = input().split()
s = set()
for i in range(1, len(a) + 1):
	s.add(a[:i] + b[0])
print(min(s))


(first, last) = input().split()
firstPrefixes = [first[:a] for a in range(1, len(first) + 1)]
lastPrefixes = [last[:a] for a in range(1, len(last) + 1)]
possible = set()
for b in firstPrefixes:
	for c in lastPrefixes:
		possible.add(b + c)
print(sorted(possible)[0])


(s1, s2) = [i for i in input().split(' ')]
str = s1 + s2
for i in range(1, len(s1) + 1):
	for j in range(1, len(s2) + 1):
		var = s1[0:i] + s2[0:j]
		if var < str:
			str = var
print(str)


def pref(f, l):
	min_val = 'zzzzzzzzzzz'
	for i in range(1, len(f) + 1):
		if str(f[:i]) + l[0] < min_val:
			min_val = str(f[:i]) + l[0]
	return min_val
(f, l) = input().split()
print(pref(f, l))


(firstname, lastname) = input().split()
words = []
for i in range(1, len(firstname) + 1):
	for j in range(1, len(lastname) + 1):
		words.append(firstname[:i] + lastname[:j])
print(min(words))


x = input().split(' ')
ans = x[0] + x[1]
for i in range(len(x[0])):
	t = x[0][:i + 1]
	for j in range(len(x[1])):
		t += x[1][j]
		if t < ans:
			ans = t
print(ans)


(name, lastname) = input().split()
login = name[0]
for letter in name[1:]:
	if letter < lastname[0]:
		login = login + letter
	else:
		break
login += lastname[0]
print(login)


def main():
	mode = 'filee'
	if mode == 'file':
		f = open('test.txt', 'r')
	get = lambda : [str(x) for x in (f.readline() if mode == 'file' else input()).split()]
	[g, h] = get()
	a = []
	k = ''
	for i in range(len(g)):
		k = k + g[i]
		a.append(k + h[0])
	a.sort()
	print(a[0])
	if mode == 'file':
		f.close()
main()


l = []
s = input()
w = s.split()
for i in range(1, len(w[0]) + 1):
	for j in range(1, len(w[1]) + 1):
		x = w[0][:i] + w[1][:j]
		l.append(x)
l.sort()
print(l[0])


getInputList = lambda : list(input().split())
getInputIntList = lambda : list(map(int, input().split()))
arr = getInputList()
a = []
for i in range(len(arr[0])):
	for j in range(len(arr[1])):
		a.append(arr[0][0:i + 1] + arr[1][0:j + 1])
a.sort()
print(a[0])


(first, last) = input().split()
l = []
l.append(first[0])
for i in range(1, len(first)):
	if first[i] < last[0]:
		l.append(first[i])
	else:
		break
l.append(last[0])
print(''.join(l))


(name, family) = input().split()
name = name + 'z'
l = 1
while name[l] < family[0]:
	l = l + 1
print(name[0:l] + family[0])


name = input().split()
ans = name[0][0]
for s in name[0][1:]:
	if s < name[1][0]:
		ans += s
	else:
		break
ans += name[1][0]
print(ans)


(name, fam) = input().split()
ans = name[0]
for ch in name[1:]:
	if ch < fam[0]:
		ans += ch
	else:
		break
ans += fam[0]
print(ans)


(s1, s2) = map(str, input().split())
s = ''
s += s1[0]
for i in range(1, len(s1)):
	if ord(s1[i]) < ord(s2[0]):
		s += s1[i]
	else:
		break
s += s2[0]
print(s)


import sys
input = sys.stdin.readline
s = input().rstrip().split()
ans = []
ans.append(s[0][0])
for i in range(1, len(s[0])):
	if s[0][i] < s[1][0]:
		ans.append(s[0][i])
	else:
		break
ans.append(s[1][0])
for char in ans:
	print(char, end='')


def dildo():
	l = []
	x = input()
	m = x.split()
	for j in range(1, len(m[0]) + 1):
		for i in range(1, len(m[1]) + 1):
			l.append(m[0][:j] + m[1][:i])
	l.sort()
	print(l[0])
dildo()


(a, b) = input().split()
a1 = a[0] + b[0]
i = 1
j = 1
while 1:
	a2 = a[:i + 1] + b[:j]
	a3 = a[:i] + b[:j + 1]
	if a1 <= a2 and a1 <= a3:
		print(a1)
		break
	elif a1 > a2:
		a1 = a2
		if i < len(a) - 1:
			i += 1
	elif a1 > a3:
		a1 = a3
		if j < len(b) - 1:
			j += 1
	if i == len(a) and j == len(b):
		break


arr = list(input().strip().split())
s1 = arr[0]
s2 = arr[1]
ans = [s1[0]]
k = 1
while k < len(s1):
	if s1[k] >= s2[0]:
		break
	ans.append(s1[k])
	k += 1
ans.append(s2[0])
print(''.join(ans))


def getLogin(a, b):
	result = a[0]
	a = a[1:]
	while len(a) > 0 and a[0] < b[0]:
		result += a[0]
		a = a[1:]
	result += b[0]
	return result
(a, b) = input().split()
print(getLogin(a, b))


(a, b) = input().split()
n = max(len(a), len(b))
s = a[0]
j = 0
f = 0
for i in range(1, len(a)):
	if a[i] < b[j]:
		s += a[i]
	else:
		s += b[j]
		f = 1
		break
if f == 1:
	print(s)
else:
	print(s + b[0])


(first, last) = input().strip().split()
index = 1
while index != len(first) and first[index] < last[0]:
	index += 1
print(first[0:index] + last[0])


a = input().split()
n = []
X = ''
for i in a[0]:
	X += i
	n.append(X + a[1][0])
n = sorted(n)
print(n[0])


(name, surname) = input().split()
res = name[0]
name = name[1:]
while name and surname[0] > name[0]:
	res += name[0]
	name = name[1:]
res += surname[0]
print(res)


IL = lambda : list(map(int, input().split()))
I = lambda : int(input())
(f, l) = input().split()
print(min([f[:i] + l[:j] for i in range(1, len(f) + 1) for j in range(1, len(l) + 1)]))


(first, last) = input().split(' ')
names = []
for i in range(len(first)):
	for j in range(len(last)):
		names.append(first[:i + 1] + last[:j + 1])
minname = 'z' * 99999
for name in names:
	if minname > name:
		minname = name
print(minname)


(s, t) = input().split()
i = 1
n = len(s)
while i < n and s[i] < t[0]:
	i += 1
print(s[:i] + t[0])


(A, B) = input().split()
strings = []
for i in range(0, len(A), 1):
	for j in range(0, len(B), 1):
		string_here = A[:i + 1] + B[:j + 1]
		strings = strings + [string_here]
strings.sort()
print(strings[0])


(First, Last) = input().split()
Result = First[0]
i = 1
while i < len(First) and First[i] < Last[0]:
	Result += First[i]
	i += 1
print(Result + Last[0])


(Fn, Ln) = input().lower().split()
R = Fn[0]
for i in Fn[1:]:
	if i < Ln[0]:
		R += i
	else:
		break
R += Ln[0]
print(R)


(n, f) = map(str, input().split())
lst = []
for i in range(1, len(n) + 1):
	for j in range(1, len(f) + 1):
		lst.append(n[:i] + f[:j])
print(sorted(lst)[0])


(name, surname) = tuple(input().rstrip().split(' '))
name = list(name)
surname = list(surname)
char = surname[0]
prefix = list()
prefix.append(name[0])
for c in name[1:]:
	if ord(c) < ord(char):
		prefix.append(c)
	else:
		break
prefix.append(char)
print(''.join(prefix))