var	s,s2:ansistring;
	i,vt,j,dem:longint;
	c:char;
	a:array[0..5000] of ansistring;
begin
	readln(s);
	dem:=0;
	s2:='';
	for i:=1 to length(S) do
		if s[i]=' ' then break;
	c:=s[i+1];
	for j:=1 to i-1 do
	begin
		s2:=s2+s[j];
		inc(dem);
		a[dem]:=s2+c;
	end;
	s2:=a[1];
	for i:=2 to dem do
		if a[i]<s2 then s2:=a[i];
	writeln(s2);
end.

var
 s,t1,t2,t3,min : string;
 p,i,j : longint;
begin    min:='zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';
 readln(s);
 p:=pos(' ',s);
 t1:=copy(s,1,p-1);
 t2:=copy(s,p+1,length(s)-p);
 for i:=1 to length(t1) do
  for j:=1 to length(t2) do begin
   t3:=copy(t1,1,i)+copy(t2,1,j);
   if t3<min then min:=t3; end;
 writeln(min);
end.

program Project1;

var
  Name, SurName, Ans: string;
  Space, i: LongInt;
  Ended: Boolean;

function SuperTrim(var s: string): LongInt;
var
  plus, i: LongInt;
begin
  plus := 0;
  For i := Length(s) downto 1 do
  begin
    If ord(s[i+plus]) < 33 then
    begin
      Delete(s, i+plus, 1);
      Result := i+plus;
      inc(plus);
    end;
  end;
end;

begin
  ReadLn(Name);
  Space := SuperTrim(Name);
  SurName := '';
  For i := Space to Length(Name) do
  begin
    SurName := SurName + Name[Space];
    Delete(Name, Space, 1);
  end;
  Ans := Name[1];
  Ended := False;
  For i := 2 to Length(Name) do
  begin
    If Name[i] < SurName[1] then
    begin
      Ans := Ans + Name[i]
    end else
    begin
      Ans := Ans + SurName[1];
      Ended := True;
      Break;
    end;
  end;
  If not Ended then Ans := Ans + SurName[1];
  WriteLn(Ans);
end.

program zzz;
var
  s,fname,sname,res:string;
  i,j:longint;
begin
  read(s);
  fname:=copy(s,1,pos(' ',s)-1);
  sname := copy(s,pos(' ',s)+1,length(s)-pos(' ',s));
  res :=fname[1];
  i:=2;
  j:=1;
  while(i<=length(fname))and(fname[i]<sname[j])  do
  begin
    res:=res+fname[i];
    inc(i);
  end;
  res:= res + sname[1];
  write(res);
end.

var
s,s1:string;
i,n:longint;
begin
read(s);
i:=1;
while (s[i]<>' ') do
 i:=i+1;
n:=i+1;
s1:=s1+s[1];
i:=2;
while (s[i]<s[n]) do
begin
if (s[i]<>' ') then
   s1:=s1+s[i];
   i:=i+1;
end;
s1:=s1+s[n];
write(s1);
end.

var a, b: string;
    i: integer;
begin
    readln (a);
    b := a;
    delete(a, pos(' ', a), 100);
    delete(b, 1, pos(' ', b));

    write(a[1]);
    i := 2;
    while (a[i]<b[1])and(i<=length(a)) do begin
        write(a[i]);
        i := i+1;
    end;
    write(b[1]);
    readln;
end.

var
  a,b:array[0..1000]of string;
  c:char;
  ans,s,p:ansistring;
  i,n,j,e,k,q:longint;
  it:boolean;

begin
  readln(s);
  for i:=2 to length(s) do
    if s[i-1]=' ' then begin j:=i-1;break;end;
  a[0]:='';
  for i:=1 to j-1 do
    begin
      inc(k);
      a[k]:=a[k-1]+s[i];
    end;
  b[0]:='';
  for i:=j+1 to length(s) do
    begin
      inc(e);
      b[e]:=b[e-1]+s[i];
    end;
  ans:=a[1]+b[1];
  for i:=1 to k do
    for j:=1 to e do
      if(a[i]+b[j])<(ans)
        then ans:=a[i]+b[j];
  writeln(ans);
end.

var
 chm,s1,s2,x:ansistring;
 k,i,s:longint;
 a:array[0..1000001] of string;
begin
 readln(s2);
 k:=pos(' ',s2);
 s1:=copy(s2,1,k-1);
 delete(s2,1,k);
 k:=1;
 while k<=length(s1) do
  begin
   x:='';
   for i:=1 to k do
    x:=x+s1[i];
   for i:=1 to length(s2) do
    begin
     x:=x+s2[i];
     inc(s); a[s]:=x;
    end;
   inc(k);
  end;
 chm:=a[1];
 for i:=2 to s do
  if a[i]<chm then chm:=a[i];
 writeln(chm);
end.

var s1,s2:ansistring;
    i:longint;
begin
  readln(s1);
  s2:=copy(s1,pos(' ',s1)+1,length(s1));
  delete(s1,pos(' ',s1),length(s1));
  write(s1[1]);
  for i:=2 to length(s1) do
    if s1[i]<s2[1] then
      write(s1[i])
    else
      break;
  writeln(s2[1]);
end.

var s,f,v,m:ansistring;
    i,j,x,z,k:longint;
begin
  m:='zzzzzzz';
  read(s);
  x:=pos(' ',s);
  z:=length(s);
  k:=z-x+1;
  f:=copy(s,x+1,k);
  delete(s,x,k);
  for i:=1 to z do
   for j:=1 to length(f) do
   begin
    v:=copy(s,1,i)+copy(f,1,j);
    if v<m then
     m:=v;
   end;
  write(m);
end.

var
  na, s, ans : string;
  i : longint;
function min( s1, s2 : string ) : string;
  var
    minl, i : longint;
  begin
    minl := length( s1 );
    if minl > length( s2 )
      then minl := length( s2 );
    for i := 1 to minl do
      begin
        if s1[ i ] = s2[ i ]
          then continue;
        if s1[ i ] < s2[ i ]
          then
            begin
              min := s1;
              exit;
            end;
        if s1[ i ] > s2[ i ]
          then
            begin
              min := s2;
              exit;
            end;
      end;
    if length( s1 ) > length( s2 )
      then min := s2
      else min := s1;
  end;
procedure use( n : longint );
  var
    temp : string;
    i : longint;
  begin
    if ans = ''
      then
        begin
          for i := 1 to n do
            ans := ans + na[i] ;
          ans := ans + s[1];
        end
      else
        begin
          temp := '';
          for i := 1 to n do
            temp := temp + na[i];
          temp := temp + s[1];
          ans := min( ans, temp );
        end;
  end;

begin
  readln( s );
  na := copy( s, 1, pos( ' ', s ) - 1 );
  delete( s, 1, pos( ' ', s ) );
  for i := 1 to length( na ) do
    use( i );
  writeln( ans );
end.

var s,s1:string; i:longint;
begin
readln(s);
s1:=copy(s,1,pos(' ',s)-1);
delete(s,1,pos(' ',s));
write(s1[1]);
for i:=2 to length(s1) do
  if s1[i]<s[1] then write(s1[i]) else break;
writeln(s[1]);
end.

// luogu-judger-enable-o2
var s,s2,s3,min:string;
    i,j,x:longint;
 begin
  min:='zzzzzzzzzzzzzzzzzzzzzzzz';
  readln(s);
  x:=pos(' ',s);
  s2:=copy(s,x+1,length(s)-x+1);
  delete(s,x,length(s)-x+1);
  for i:=1 to length(s) do
  for j:=1 to length(s2) do
  begin
    s3:=copy(s,1,i)+copy(s2,1,j);
    if s3<min then min:=s3;
  end;
  writeln(min);
end.

var
s,s1,s2:string;
i:longint;
begin
readln(s);
for i:=1 to length(s) do begin
if s[i]=' '
then begin
s1:=s;
s2:=s;
delete(s1,i,length(s)-i+1);
delete(s2,1,i);
end;
end;
write(s1[1]);
for i:=2 to length(s1) do begin
if s1[i]<s2[1]
then write(s1[i])
else break;
end;
write(s2[1]);
end.

program r455_1;
var
 n,s,a,b:string;
 l:string[20];
 i,j:byte;
begin
 readln(l);
 n:=copy(l,1,pos(' ',l)-1);
 s:=copy(l,pos(' ',l)+1,length(l)-pos(' ',l));
 l:=n+s;
 for i:=1 to length(n) do
 begin
  a:=copy(n,1,i);
  for j:=1 to length(s) do
  begin
   b:=copy(s,1,j);
   if (a+b)<l then l:=a+b
  end
 end;
 writeln(l)
end.

program abc;
var s:string;i,k:integer;f:char;
begin
read (s);

for i:=1 to length(s) do begin
if s[i]=' ' then f:=s[i+1];
end;
write(s[1]);
i:=2;k:=ord(f);
while ((ord(s[i]))<(ord(f))) and (ord(s[i])>ord(' ')) do
begin
write(s[i]);i:=i+1;end;
write (f);
end.

var
  s,s2,s3,min:string;
  i,j,x:longint;
begin
  min:='zzzzzz';
  readln(s);
  x:=pos(' ',s);
  s2:=copy(s,x+1,length(s)-x+1);
  delete(s,x,length(s)-x+1);
  for i:=1 to length(s) do
  for j:=1 to length(s2) do
  begin
    s3:=copy(s,1,i)+copy(s2,1,j);
    if s3<min then min:=s3;
  end;
  writeln(min);
end.

{CF909A}
var
i:longint;
s:string;
c:char;
begin
readln(s);
c:=s[pos(' ',s)+1];
write(s[1]);
for i:=2 to pos(' ',s)-1 do
 if s[i]<c then
 write(s[i])
 else
 break;
writeln(c);
end.

var a:array [1..11] of char;
b:array [1..11] of char;
i,f,ia,ib:integer;
q:char;
s:string;
begin
i:=1;
read(s);
while s[i]<>' ' do begin
a[i]:=s[i];
inc(i);
end;
ia:=i;
q:=s[i+1];
i:=2;
write(a[1]);
while (a[i]<q) and (i<ia) do begin write (a[i]); inc(i);end; write(q);
end.

//{$R-,Q-,S-,I-}
Uses math;
Const
        fin='';
        fon='';
	//fin='.inp';
	//fon='.out';
        maxC=1000000000;
        maxN=1000+10;
	module=1000000007;

Type
	pnode=^tnode;
        tnode=record
                v,c:longint;
                next:pnode;
		end;
	re=record
		x,y:longint;
		end;

Var
        fi,fo:text;
	n:longint;
        s,a,b:ansistring;

Procedure mo;
Begin
        Assign(fi,fin); Reset(fi);
        Assign(fo,fon); Rewrite(fo);
End;

Procedure dong;
Begin
        Close(fi);
        Close(fo);
End;

Procedure nhap;
Var
	i,j:longint;
Begin
        Readln(fi,a);
        i:=1;
        While a[i]<>' ' do
        Begin
                b:=b+a[i];
                inc(i);
        End;
        inc(i);
        s:=b[1];
        j:=2;
        While (j<=length(b)) and (i<=length(a)) do
        Begin
                If b[j]<a[i] then
                Begin
                        s:=s+b[j];
                        inc(j);
                End else break;
        End;
        s:=s+a[i];
        Writeln(fo,s);
End;

Procedure xuly;
Var
        i,j:longint;
Begin

End;

Procedure xuat;
Begin
End;

BEGIN
        Mo;
        Nhap;
        Xuly;
        Xuat;
        Dong;
END.

var
S:ansistring;
k,ind,i,q:longint;
begin
readln(s);

for i:=1 to length(s)do if s[i]=' ' then ind:=i;
q:=ord(s[ind+1]);
for i:=2 to ind-1 do if ord(s[i])<q then k:=i
else break;
write(s[1]);
for i:=2  to k do write(S[i]);
write(s[ind+1]);
end.

var
  c,f,s,k : ansistring;
  i,j,pos : longint;
begin
  readln(s);
  for i:=1 to length(s) do
    begin
      if s[i]<>' ' then c:=c+s[i]
                   else begin pos:=i; break; end;
    end;
  for i:=pos+1 to length(s) do
    begin
      f:=f+s[i];
    end;
  k:=k+c[1];
  for i:=2 to length(c) do
    begin
      if ord(c[i])<ord(f[1]) then k:=k+c[i]
                             else break;
    end;
  k:=k+f[1];
  writeln(k);
end.

 var s,s1,s2:string;
     i:longint;
begin
  readln(s);
  s1:=copy(s,1,pos(' ',s)-1);
  delete(s,1,pos(' ',s));
  s2:=s;
  s:=s1[1];
  i:=2;
  if length(s1)=1 then
    writeln(s,s2[1])
  else begin
    while ord(s1[i])<ord(s2[1]) do begin
      s:=s+s1[i];
      inc(i);
      if i>length(s1) then
        break;
    end;
    writeln(s,s2[1]);
  end;
end.

var ch:char;
    s,t,ans,now,x:string;
    i,j:longint;
begin
  while not eoln do
  begin
    read(ch);
    if ch<>' ' then s:=s+ch else
    begin
      t:=s;
      s:='';
    end;
  end;
  for i:=1 to length(s)+length(t) do
  ans:=ans+'z';
  for i:=1 to length(t) do
  begin
    now:=now+t[i];
    x:=now;
    for j:=1 to length(s) do
    begin
      x:=x+s[j];
      if x<ans then ans:=x;
    end;
  end;
  writeln(ans);
end.

var s:string;
    i,j,n,k:longint;
begin
readln(s);
n:=length(s);
write(s[1]);
k:=pos(' ',s);
for i:=2 to k-1 do
 if s[i]<s[k+1]
 then write(s[i])
 else break;
write(s[k+1]);
end.

var a,b,s,s1:string;
i,j,k:integer;
begin
read(s1);
i:=1;
while s1[i]<>' ' do
begin
a:=a+s1[i];
i:=i+1;
end;

i:=i+1;

while i<=length(s1) do
begin
b:=b+s1[i];
i:=i+1;
end;

s:=s+a[1];
for i:=2 to length(a) do
 begin
 if a[i]<b[1] then
  s:=s+a[i]
 else
  break;
 end;

 s:=s+b[1];

 writeln(s);
end.

program Strings;
var
   str1,str2: string;
   login:string;
   position,i: integer;
begin
readln(str1);
position:=pos(' ',str1);
str2:=copy(str1,position+1,length(str1)-position+1);
login:=''+str1[1];
i:=2;
while  (ord(str1[i])<ord(str2[1])) and (i<=length(str1)-1-length(str2)) do
   begin
      login:=login+str1[i];
      inc(i);
   end;
login:=login+str2[1];
writeln(login);
end.

var
 a,b,t,min:string;
 i,j,k:longint;
begin
 read(b);
 k:=pos(' ',b);
 a:=copy(b,1,k-1);
 delete(b,1,k);
 min:=a+b;
 for i:=1 to length(a) do
  for j:=1 to length(b) do
   begin
    t:=copy(a,1,i)+copy(b,1,j);
    if t<min then min:=t;
   end;
 write(min);
end.

var s,a,b:ansistring;
c:char;
i,j,r:longint;
aa:array[0..1000] of ansistring;
procedure sort(l,r:longint);
var i,j:longint;
x,y:ansistring;
begin
i:=l;j:=r;x:=aa[(l+r) div 2];
repeat
 while aa[i]<x do inc(i);while x<aa[j] do dec(j);
  if not(i>j) then
    begin
    y:=aa[i];aa[i]:=aa[j];aa[j]:=y;inc(i);j:=j-1;
    end;
until i>j;
if l<j then sort(l,j);if i<r then sort(i,r);
end;
begin
readln(s);
a:=copy(s,1,pos(' ',s)-1);
b:=copy(s,pos(' ',s)+1,length(s));
for i:=1 to length(a) do
  for j:=1 to length(b) do
    begin
    r:=r+1;
    aa[r]:=copy(a,1,i)+copy(b,1,j);
    end;
sort(1,r);
writeln(aa[1]);
end.

var s,s1,s2,s3,min:string;
i,j:longint;
function minl(x,y:longint):longint;
begin
if x<y then exit(x);
exit(y);
end;
begin
readln(s);
min:=succ('z');
s1:=copy(s,1,pos(' ',s)-1);
delete(s,1,pos(' ',s));
for i:=1 to length(s) do
  begin
  s2:=s2+s[i];
  s3:='';
  for j:=1 to length(s1) do
    begin
  s3:=s3+s1[j];

  if s3+s2<min then min:=s3+s2;
  end;

  end;
write(min);

end.

var
s,s1,s2,s3:string;
a:array[1..100000] of string;
i,j,k,c,d,e,n,m:longint;
begin
read(s);
j:=pos(' ',s);
s1:=copy(s,1,j-1);
delete(s,1,j);
k:=1;
while (k<=length(s1)) do
begin
s2:='';
for i:=1 to k do
s2:=s2+s1[i];
for i:=1 to length(s) do
begin
s2:=s2+s[i];
inc(e);
a[e]:=s2;
end;
inc(k);
end;
s1:='';
for i:=1 to e-1 do
for j:=i+1 to e do
if a[i]>a[j] then begin s2:=a[i];a[i]:=a[j];a[j]:=s2;end;
write(a[1]);
end.

var
  s : string;
  i, j, k : integer;
begin
  read(s);
  write(s[1]);
  k := pos(' ', s);
  for i := 2 to k - 1 do
  if s[i] < s[k + 1]
    then
      write(s[i])
    else
      break;
  write(s[k + 1]);
end.

var
 s1,s2,s3,min:ansistring;
 i,j,x:longint;
begin
 readln(s1);
 min:='zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';
 x:=pos(' ',s1);
 s2:=copy(s1,x+1,length(s1));
 delete(s1,x,length(s1));
 for i:=1 to length(s1) do
  for j:=1 to length(s2) do
   begin
    s3:=copy(s1,1,i);
    s3:=s3+copy(s2,1,j);
    if s3<min then min:=s3;
   end;
 writeln(min);
end.

var
  name, fam, log, s: String;
  i: integer;

begin
  readln(name);
  name := lowercase(name);
  fam := name;
  for i := 1 to length(name)
  do
    begin
      if name[i] = ' '
      then
        begin
          delete(name, i, length(name));
          delete(fam, 1, i);
          break;
        end;
    end;

  log := name[1];

  for i := 2 to length(name)
  do
    if ord(name[i]) < ord(fam[1])
    then
      begin
        s := name[i];
        log := concat(log, s)
      end
    else
      break;

  log := concat(log, fam[1]);
  writeln(log);
end.

program Matfey;
var
x12,x11,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10 : int64;
j,i,k : longint;
r1 : real;
c1,c2,c3,c4,c5,c6,c7,c8,c9,c10 : char;
s1,s2,s3,s4,s5,s6,s7,s8,s9,s10 : string;
a1 : array[0..1001] of longint;
begin
readln(s1);
x1:=pos(' ',s1);
s2:=copy(s1,1,x1-1);
s3:=copy(s1,x1+1,1);
s4:='zzzzzzzzzzzz';
for i:=1 to length(s2) do
begin
s5:=s5+s2[i];
if (s5+s3)<s4 then s4:=s5+s3;
end;
{
x4:=length(s4);

for i:=1 to x4 do
begin
x8:=pos(' ',s4);
if x8>0 then delete(s4,x8,1);
end;
 }
writeln(s4);

end.

var st,st1,st2,otv:string;
i,k,ind:integer;
begin
readln(st);
for i:=1 to length(st) do begin
if k=1 then inc(k);
if st[i]=' ' then k:=1;
if k=0 then st1:=st1+st[i];
if k=2 then st2:=st2+st[i];
end;
otv:=otv+st1[1];
k:=1;
while ind<>1 do begin
inc(k);
if (k<=length(st1))and(st1[k]<st2[1]) then otv:=otv+st1[k] else begin otv:=otv+st2[1]; ind:=1; end;
end;
writeln(otv);
end.

var s, s1, s2:string; i:byte;
begin
 read(s);
 for i:=1 to length(s) do
  if s[i]=' ' then begin
   s1:=copy(s, 1, i-1);
   s2:=copy(s, i+1, length(s));
  end;
 write(s1[1]);
 i:=2;
 while (s1[i]<s2[1])and(i<=length(s1)) do begin
  write(s1[i]); i:=i+1; end;
 write(s2[1]);
end.

program qwret;
var a,b,n,u,i,j,k:longint;
st,st1,st2,st3,min: string;
ch: char;
begin
readln(st);
st:=st+' ';
i:=0;
ch:='a';
  while ch<>' ' do
    begin

      st1:=st1+ch;
      inc(i);
      ch:=st[i];

    end;
  ch:='a';
  inc(i);
  while ch<>' ' do
    begin
      ch:=st[i];
      st2:=st2+ch;

      inc(i);
    end;
    //writeln(st1);
    min:='zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';
    for i:=2 to length(st1) do
      begin
        for j:=1 to length(st2) do
          begin
            st3:='';
            for k:=2 to i do
              st3:=st3+st1[k];
            for k:=1 to j do
              st3:=st3+st2[k];
            if st3<min then min:=st3;

          end;

      end;
  writeln(min);
end.

program CONTEST_455_A;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var i, j, n:integer;
  s, s1, s2:string[100];
begin
  for i:=1 to 15 do begin
  read(s1[i]);
  if (s1[i] = ' ') then break;
  end;
  n := i - 1;
  read(s2);
  s := s + s1[1];
  for i:=2 to n do
  if (s1[i] < s2[1]) then s := s + s1[i]
  else break;
  s:= s + s2[1];
  writeln(s);
  readln;
  readln;
end.

var s,d,f:string;i,a:longint;
begin
 read(s);
 a:=pos(' ',s);
 while s[a]=' ' do inc(a);
 write(s[1]);
 i:=2;
 while (s[i]<s[a])and(s[i]<>' ') do begin write(s[i]);inc(i);end;
 write(s[a]);
end.

         const eps=0.000000001;  besk=20000000000008;
               modul=1000000007;
   label 1,2,3,4,5,6;
    type
    int64=longint;
    mas=array [-100..1000000] of int64;   point=record x,y,z,vx,vy,vz:int64;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap; point1=^point;
    mass=array[-100..1000000] of int64;mass1=^mass;
    var j1,left,right,gr,xx,yy,sum,ogr,jloz,jnew,i1,i2,i3,maxdob,nn,kk,pos1,pos2,start,ans,pp,qq,aaa,bbb,ccc,tt,aa,bb,jj,ii,ott,time,ppp,istart,jstart,iii,newdl, t1,t2,cc,ll,rr,oldpos,t,jjj,kol,pos,dloch,told,p,q,pmin,ppold,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s2,m,smin,cen:int64;
   mask,k, step, i,j:longint;
   pointnew,pointold,pointklad,ppoint:point;
    vot,distmin,hh,dist,s0,s1,aanew,bbnew:extended;
    mm,mx,my,mz,tr,maxright,fact,aold,y,och,s,d11,prev,next,z,x,newc,d,nap:array[-10..2000008] of int64;
    a,b,c:mass;
    sd:array[-1000..1000000] of char;
    yyy:array[-10..10000] of extended;
    dot,ddd:array[-10..1210000] of int64;
    ddminus, ppole:array[-1..200,-10..150,-1..150] of int64;
   sss,text1,text2:array[-10..2000000] of string;
   zanxy,zanxz,zanyz:array[-1..200,-1..200] of boolean;
     sot,ss,stest,ss3,ss1,ss2:string;
     ch1,ch2:char;
     traf,dd1,dd:array[-1..5000,-1..5000] of int64;
     zan,zana,zanb:array[-10..2000000] of boolean;
     marked:array[-100..15000] of boolean;
    {sss:string;ch:char;
   } pole1,pole :array [-10..150,-10..150] of char;
    st:array[-100..100000] of string;
     v0,v1,t0:extended;
     zv:point;
     newx,newy:array[-1..200000] of int64;

     koef,yot:extended;
      globflag, flag2,flag,flag1:boolean;
    function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;
 begin
     if (x>0)and(y>=0) then p:=arctan(y/x);
     if x<0 then p:=pi+arctan(y/x);
     if(x>0)and(y<0) then p:=2*pi+arctan(y/x);
     if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;
     al:=p/pi*180;
 end;
  function min(x,y:int64):int64;begin min:=x;if y<x then min:=y; end;
  function max(x,y:int64):int64;begin max:=x;if y>x then max:=y; end;

  function nod(x,y:int64):int64; var z:int64;
begin   repeat  z:=x mod y;x:=y;y:=z;   until  z=0 ;  nod:=x;end;

{procedure udal(ii:longint);
begin  next[prev[ii]]:=next[ii]; prev[next[ii]]:=prev[ii];  end;
 }
function degg(a,k:int64):int64; var p:int64;
begin
 if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else
   begin  p:=degg(a,k div 2); degg:=p*p mod modul;   end;

end;

function good(ch:char):boolean;
begin
  if (ord(ch)>20)and(ord(ch)<220) then good:=true else good:=false;

end;

begin
   { assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
    }

      readln(ss);  n:=length(ss);
      for i:=1 to n do if ss[i]=' ' then ii:=i;
      for i:=1 to ii-1 do ss1:=ss1+ss[i];
      for i:=ii+1 to n do ss2:=ss2+ss[i];

      {writeln(ss1,' ',ss2);
     } p1:=length(ss1);
      p2:=length(ss2);
     { goto 1;  }
     q:=0;
      for i:=1 to p1 do for j:=1 to p2 do
        begin
           inc(q); sss[q]:='';
           for i1:=1 to i do  sss[q]:=sss[q]+ss1[i1];
           for j1:=1 to j do  sss[q]:=sss[q]+ss2[j1];

          { writeln(q,' ',sss[q]);
           }
        end;

     sot:=sss[1];

     for i:=1 to q do if sss[i]<sot then sot:=sss[i];

     writeln(sot);

   1:    close(output);
end.

program Project2;

{$APPTYPE CONSOLE}

var
  s, s1, temp, temp1: string;
  i: Integer;

begin
  read(S);
  i := Length(s);
  while s[i] <> ' ' do
  begin
    temp := s[i] + temp;
    Dec(i);
  end;
  i := 1;
  while s[i] <> ' ' do
  begin
    temp1 := temp1 + s[i];
    Inc(i);
  end;
  s1 := temp1[1];
  for i := 2 to Length(temp1) do
  begin
    if temp1[i] < temp[1] then
      s1 := s1 + temp1[i]
      else Break;
  end;
  s1:=s1+temp[1];
   write(s1);
end.

var
s:string;
i,k:longint;
begin
    readln(s);
    i:=1;
    write(s[1]);
    while(i<pos(' ',s)-1) do begin
       i:=i+1;
       if (s[i]<s[pos(' ',s)+1]) then write(s[i])
       else break;
    end;
    writeln(s[pos(' ',s)+1]);
end.

var i,j,n:longint;
    s,s1:string;
begin
 readln(s);
 i:=0;
 while s[i]<>' ' do
  inc(i);
 while s[i]=' ' do
  inc(i);
 j:=2;
 while (s[j]<s[i])and(s[j]<>' ') do
  inc(j);
 writeln(copy(s,1,j-1),s[i]);
end.

var
a,b,x,min:string;
i,j:longint;
begin
readln(a);
b:=copy(a,pos(' ',a)+1,length(a)-pos(' ',a)+1);
delete(a,pos(' ',a),length(a)-pos(' ',a)+1);
min:='zzzzzzzzzzzzzzzzzzzzzzzz';
for i:=1 to length(a) do
  for j:=1 to length(b) do
    begin
      x:=copy(a,1,i)+copy(b,1,j);
      if x<min then min:=x;
    end;
writeln(min);
end.

var s,s1:ansistring; i:longint;
begin
readln(s);
s1:=copy(s,1,pos(' ',s)-1);
delete(s,1,pos(' ',s));
write(s1[1]);
for i:=2 to length(s1) do
  if s1[i]<s[1] then write(s1[i]) else break;
writeln(s[1]);
end.

var
  s,s2,s3,min:ansistring;
  i,j,x:longint;
begin
  min:='zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';
  readln(s);
  x:=pos(' ',s);
  s2:=copy(s,x+1,length(s)-x+1);
  delete(s,x,length(s)-x+1);
  for i:=1 to length(s) do
  for j:=1 to length(s2) do
  begin
    s3:=copy(s,1,i)+copy(s2,1,j);
    if s3<min then min:=s3;
  end;
  write(min);
end.

var
    s,t:string;
    i,n:longint;
begin
    readln(s);
    n:=length(s);
    i:=pos(' ',s);
    t:=copy(s,i+1,n);
    delete(s,i,n);
    n:=length(s);
    write(s[1]);
    i:=2;
    while (i<=n) and (s[i]<t[1]) do
    begin
        write(s[i]);
        inc(i);
    end;
    writeln(t[1]);
end.

Program z1;
var s,d:string;
    i,k,t:integer;
begin
read(s);
k:=pos(' ',s);
d:=s[1];
i:=1;
t:=0;
while (i<k-1)and(t=0) do
begin
i:=i+1;
if ord(S[i])<ord(S[k+1]) then d:=d+s[i]
                         else begin d:=d+s[k+1];t:=1;end;
end;
if t=0 then d:=d+s[k+1];
write(d);
end.

var a,s,d,f,g: integer;
c,z,x: string;
begin
  read (c);
  for a:=1 to length(c) do
  if c[a]=' ' then begin
                     d:=a;
                     break;
                   end;
                   for a:=1 to d-1 do
                   z:=z+c[a];
                   for a:=d+1 to length(c) do
                   x:=x+c[a];

  for a:=2 to length(z) do
  if (ord(z[a])>ord(x[1])) or (ord(z[a])=ord(x[1]))  then begin
                                s:=a;
                                f:=1;
                                break;
                              end;
                              if f=1 then for a:=1 to s-1 do
                              write (z[a]) else for a:=1 to length(z) do write (z[a]);
                              write (x[1]);
end.

var
 s1,s2,s3,min:ansistring;
 i,j,k:longint;
begin
 min:='zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';
 readln(s1);
 k:=pos(' ',s1);
 s2:=copy(s1,k+1,length(s1));
 delete(s1,k,length(s1));
 for i:=1 to length(s1) do
  for j:=1 to length(s2) do
   begin
    s3:=copy(s1,1,i)+copy(s2,1,j);
    if s3<min then min:=s3;
   end;
   writeln(min);
end.

var s1,s2,ans:string;
i,j,x:longint;
begin
 read(s1);
 x:=pos(' ',s1);
 s2:=copy(s1,x+1,length(s1)-x+1);
 delete(s1,x,length(s1)-x+1);
 ans:=s1[1];
 for i:=2 to length(s1) do
 if  s1[i]<s1[i-1] then ans:=ans+s1[i]
 else break;
 ans:=ans+s2[1];
 for i:=2 to length(s2) do
 if s2[i]>s2[i-1] then ans:=ans+s2[i]
 else break;
 write(ans);
end.

var a:array [1..11] of char;
b:array [1..11] of char;
i,f,ia,ib:integer;
q:char;
s:string;
begin
i:=1;
read(s);
while s[i]<>' ' do begin
a[i]:=s[i];
inc(i);
end;
ia:=i;
for i:=1 to (length(s)-ia) do
b[i]:=s[i+ia];
ib:=i;
i:=1;
if a[i]<=b[i] then begin write(a[i]); inc(i);
while (a[i]<b[1]) and (i<=ia) do begin write (a[i]); inc(i);end; write(b[1]);
end
else begin
write(b[i]); inc(i);
while (a[1]>b[i]) and (i<=ib) do begin write (b[i]); inc(i);end;
write(a[1]);
end;
end.

var
  s,s2,s3,min:string;
  i,j,x:longint;
begin
  readln(s);
  x:=pos(' ',s);
  s2:=copy(s,x+1,length(s)-x+1);
  delete(s,x,length(s)-x+1);
  for i:=1 to length(s) do
  for j:=1 to length(s2) do
  begin
    s3:=copy(s,1,i)+copy(s2,1,j);
    if s3<min then min:=s3;
  end;
  writeln(min);
end.

var s, s1, s2:string; i:byte;
begin
 read(s);
 for i:=1 to length(s) do
  if s[i]=' ' then begin
   s1:=copy(s, 1, i-1);
   s2:=copy(s, i+1, length(s));
  end;
 write(s1[1]);
 i:=2;
 while s1[i]>s2[1] do begin
  write(s1[i]); i:=i+1; end;
 write(s2[1]);
end.

var s, s1, s2:string; i:byte;
begin
 read(s);
 for i:=1 to length(s) do
  if s[i]=' ' then begin
   s1:=copy(s, 1, i-1);
   s2:=copy(s, i+1, length(s));
  end;
 write(s1[1]);
 for i:=2 to length(s1) do
  if s1[i]<=s1[i-1] then write(s1[i]) else break;
 write(s2[1]);
 i:=2;
 while (s1[i-1]>s2[i-1]) do begin
  read(s2[i]); i:=i+1; end;
end.

var s, s1, s2:string; i:byte;
begin
 read(s);
 for i:=1 to length(s) do
  if s[i]=' ' then begin
   s1:=copy(s, 1, i-1);
   s2:=copy(s, i+1, length(s));
  end;
 write(s1[1]);
 for i:=2 to length(s1) do
  if s1[i]<s1[i-1] then write(s1[i]) else break;
 write(s2[1]);
end.

var s, s1, s2:string; i:byte;
begin
 read(s);
 for i:=1 to length(s) do
  if s[i]=' ' then begin
   s1:=copy(s, 1, i-1);
   s2:=copy(s, i+1, length(s));
  end;
 write(s1[1]);
 i:=2;
 while s1[i]<s2[1] do begin
  write(s1[i]); i:=i+1; end;
 write(s2[1]);
end.

var s, s1, s2:string; i:byte;
begin
 read(s);
 for i:=1 to length(s) do
  if s[i]=' ' then begin
   s1:=copy(s, 1, i-1);
   s2:=copy(s, i+1, length(s));
  end;
 write(s1[1]);
 for i:=2 to length(s1) do
  if s1[i]<s1[i-1] then write(s1[i]) else break;
 write(s2[1]);
 i:=2;
 while (s1[i-1]>=s2[i-1]) do begin
  read(s2[i]); i:=i+1; end;
end.

var s, s1, s2:string; i:byte;
begin
 read(s);
 for i:=1 to length(s) do
  if s[i]=' ' then begin
   s1:=copy(s, 1, i-1);
   s2:=copy(s, i+1, length(s));
  end;
 write(s1[1]);
 for i:=2 to length(s1) do
  if s1[i]<=s1[i-1] then write(s1[i]) else break;
 write(s2[1]);
end.

var	s:ansistring;
	i,vt,j:longint;
	c:char;
begin
	readln(s);
	for i:=1 to length(s) do
		if s[i]=' ' then break;
	if (s[2]<s[i+1]) then
	begin
	vt:=1;
	c:=s[vt];
	for j:=2 to i-1 do
		if s[j]<c then
		begin
			vt:=j;
			c:=s[vt];
		end;
	for j:=1 to vt do
		write(s[j]);
	write(s[i+1]);
	end
	else
	begin
		write(s[1]);
		write(s[i+1]);
	end;
end.

var	s:ansistring;
	i,vt,j:longint;
	c:char;
begin
	readln(s);
	for i:=1 to length(s) do
		if s[i]=' ' then break;
	vt:=1;
	c:=s[vt];
	for j:=2 to i-1 do
		if s[j]<c then
		begin
			vt:=j;
			c:=s[vt];
		end;
	for j:=1 to vt do
		write(s[j]);
	write(s[j+1]);
end.

var	s:ansistring;
	i,vt,j:longint;
	c:char;
begin
	readln(s);
	for i:=1 to length(s) do
		if s[i]=' ' then break;
	vt:=1;
	c:=s[vt];
	for j:=2 to i-1 do
		if s[j]<c then
		begin
			vt:=j;
			c:=s[vt];
		end;
	for j:=1 to vt do
		write(s[j]);
	write(s[i+1]);
end.

var i,n:longint;
    s:string;
begin
 readln(s);
 i:=0;
 while s[i]<>' ' do
  inc(i);
 while s[i]=' ' do
  inc(i);
 writeln(s[1],s[i]);
end.

var s,a,b:ansistring;
c:char;
i,q:longint;
begin
readln(s);
a:=copy(s,1,pos(' ',s)-1);
b:=copy(s,pos(' ',s)+1,length(s));
c:=a[1];
q:=1;
for i:=2 to length(a) do
  if a[i]<c then
    begin
    c:=a[i];
    q:=i;
    end;
writeln(copy(a,1,q),b[1]);
end.

var a,s,d,f,g: integer;
c,z,x: string;
begin
  read (c);
  for a:=1 to length(c) do
  if c[a]=' ' then begin
                     d:=a;
                     break;
                   end;
                   for a:=1 to d-1 do
                   z:=z+c[a];
                   for a:=d+1 to length(c) do
                   x:=x+c[a];

  for a:=2 to length(z) do
  if ord(z[a])>ord(x[1]) then begin
                                s:=a;
                                f:=1;
                                break;
                              end;
                              if f=1 then for a:=1 to s-1 do
                              write (z[a]) else for a:=1 to length(z) do write (z[a]);
                              write (x[1]);
end.

var st,st1,st2,otv:string;
i,k:integer;
begin
readln(st);
for i:=1 to length(st) do begin
if k=1 then inc(k);
if st[i]=' ' then k:=1;
if k=0 then st1:=st1+st[i];
if k=2 then st2:=st2+st[i];
end;
otv:=otv+st1[1];
k:=1;
while otv[k]<>st2[1] do begin
inc(k);
if (k<=length(st1))and(st1[k]<st2[1]) then otv:=otv+st1[k] else otv:=otv+st2[1];
end;
writeln(otv);
end.

program Project2;

{$APPTYPE CONSOLE}

var
  s, s1, temp, temp1: string;
  i: Integer;

begin
  read(S);
  i := Length(s);
  while s[i] <> ' ' do
  begin
    temp := s[i] + temp;
    Dec(i);
  end;
  i := 1;
  while s[i] <> ' ' do
  begin
    temp1 := temp1 + s[i];
    Inc(i);
  end;
  s1 := temp1[1];
  for i := 2 to Length(temp1) do
  begin
    if temp1[i] < temp[1] then
      s1 := s1 + temp1[i]
      else Break;
  end;
  s1:=s1+temp[1];
  for i:=2 to Length(temp) do
   begin
     if temp[i]>temp[i-1] then
      s1:=s1+temp[i]
      else Break;
   end;
   write(s1);
end.

program Project2;

{$APPTYPE CONSOLE}

var
  s, s1, temp, temp1: string;
  i: Integer;

begin
  read(S);
  i := Length(s);
  while s[i] <> ' ' do
  begin
    temp := s[i] + temp;
    Dec(i);
  end;
  i := 1;
  while s[i] <> ' ' do
  begin
    temp1 := temp1 + s[i];
    Inc(i);
  end;
  s1 := temp1[1];
  for i := 2 to Length(temp1) do
  begin
    if temp1[i] < temp[1] then
      s1 := s1 + temp1[i]
      else Break;
  end;
  s1:=s1+temp[1];
  for i:=2 to Length(temp) do
   begin
     if temp[i]>temp[Length(temp)] then
      s1:=s1+temp[i]
      else Break;
   end;
   write(s1);
end.

program Project2;

{$APPTYPE CONSOLE}

var
  s, s1, temp, temp1: string;
  i: Integer;

begin
  read(S);
  i := Length(s);
  while s[i] <> ' ' do
  begin
    temp := s[i] + temp;
    Dec(i);
  end;
  i := 1;
  while s[i] <> ' ' do
  begin
    temp1 := temp1 + s[i];
    Inc(i);
  end;
  s1 := temp1[1];
  for i := 2 to Length(temp1) do
  begin
    if Ord(temp1[i]) < ord(temp1[i - 1]) then
      s1 := s1 + temp1[i]
      else Break;
  end;
  s1:=s1+temp[1];
  for i:=2 to Length(temp) do
   begin
     if ord(temp[i])>Ord(temp[i-1]) then
      s1:=s1+temp[i]
      else Break;
   end;
   write(s1);
end.

program Project1;

var
  Name, SurName, Ans: string;
  Space, i: LongInt;

function SuperTrim(var s: string): LongInt;
var
  plus, i: LongInt;
begin
  plus := 0;
  For i := Length(s) downto 1 do
  begin
    If ord(s[i+plus]) < 33 then
    begin
      Delete(s, i+plus, 1);
      Result := i+plus;
      inc(plus);
    end;
  end;
end;

begin
  ReadLn(Name);
  Space := SuperTrim(Name);
  SurName := '';
  For i := Space to Length(Name) do
  begin
    SurName := SurName + Name[Space];
    Delete(Name, Space, 1);
  end;
  Ans := Name[1];
  For i := 2 to Length(Name) do
  begin
    If Name[i] < SurName[1] then
    begin
      Ans := Ans + Name[i]
    end else
    begin
      Ans := Ans + SurName[1];
      Break;
    end;
    If i = Length(Name) then Ans := Ans + SurName[1];
  end;
  WriteLn(Ans);
end.

var
s,s1:string;
i,n:longint;
begin
read(s);
i:=1;
while (s[i]<>' ') do
 i:=i+1;
n:=i+1;
s1:=s1+s[1];
i:=2;
while (s[i]<s[i-1]) do
begin
if (s[i]<>' ') then
   s1:=s1+s[i];
   i:=i+1;
end;
s1:=s1+s[n];
write(s1);
end.

var
s,s1:string;
i,n:longint;
begin
read(s);
i:=1;
while (s[i]<>' ') do
 i:=i+1;
n:=i+1;
s1:=s1+s[1];
i:=2;
while (s[i]<s[1]) do
begin
if (s[i]<>' ') then
   s1:=s1+s[i];
   i:=i+1;
end;
s1:=s1+s[n];
write(s1);
end.

var
  c:char;
  s,p:ansistring;
  i,n,j:longint;
  it:boolean;

begin
  readln(s);
  for i:=2 to length(s) do
    if s[i-1]=' ' then begin j:=i-1;c:=s[i];break;end;
  p:=s[1];
  for i:=2 to j-1 do if(s[i]<c)and(s[i]<p[length(p)])then p:=p+s[i] else break;
  writeln(p,c);
end.

var
  s,p:ansistring;
  i,n:longint;
  it:boolean;

begin
  readln(s);
  write(s[1]);
  for i:=2 to length(s) do
    if s[i-1]=' ' then begin write(s[i]);halt;end;
end.

var
    s,t:string;
    i,n:longint;
begin
    readln(s);
    n:=length(s);
    i:=pos(s,' ');
    t:=copy(s,i+1,n);
    delete(s,i,n);
    n:=length(s);
    write(s[1]);
    i:=2;
    while (i<=n) and (s[i]<t[1]) do
    begin
        write(s[i]);
        inc(i);
    end;
    writeln(t[1]);
end.

var
  sname, fname : string;
  min, ind, i : longint;

begin
  readln( sname );
  fname := copy( sname, 1, pos( ' ', sname ) - 1 );
  delete( sname, 1, pos( ' ', sname ) );
  min := ord( fname[1] );
  ind := 1;
  for i := 2 to length( fname ) do
    begin
      if min > ord( fname[i] )
        then
          begin
            ind := i;
            min := ord( fname[i] );
          end;
    end;
  for i := 1 to ind do
    write(fname[i]);
  write(sname[1]);
end.

var
  sname, fname : string;
  min, min2, ind, i : longint;

begin
  readln( sname );
  fname := copy( sname, 1, pos( ' ', sname ) - 1 );
  delete( sname, 1, pos( ' ', sname ) );
  min := ord( fname[1] );
  ind := 1;
  min2 := ord( sname[1] );
  for i := 2 to length( fname ) do
    begin
      if ( min > ord( fname[i] ) ) and (min2 > ord(fname[i]))
        then
          begin
            ind := i;
            min := ord( fname[i] );
          end;
    end;
  for i := 1 to ind do
    write(fname[i]);
  write(sname[1]);
end.

var
    s,t:string;
    i,n:longint;
begin
    readln(s);
    n:=length(s);
    i:=pos(s,' ');
    t:=copy(s,i+1,n);
    delete(s,i,n);
    n:=length(s);
    i:=1;
    while (i<=n) and (s[i]<t[1]) do
    begin
        write(s[i]);
        inc(i);
    end;
    writeln(t[1]);
end.