var
st:array[0..10000]of char; s,s1:string; g,g1,i,j,z:longint; t:char;
begin
z:=0;
readln(s);
readln(s1);
g:=length(s);
g1:=length(s1);
for i:=1 to g do
for j:=1 to g1 do if s[i]=s1[j] then
inc(z);
st[z]:=s[i];
break;
end;
for i:=1 to z-1 do for j:=i+1 to z do if st[i]>st[j] then
t:=st[i];
st[i]:=st[j];
st[j]:=t;
st[z+1]:='-';
for i:=1 to z do i st[i]<>st[i+1] then write(st[i],' ');
end.
var
st:array[0..10000]of char;
s,s1:string;
g,g1,i,j,z:longint;
t:char;
begin
z:=0;
readln(s);
readln(s1);
g:=length(s);
g1:=length(s1);
for i:=1 to g do
for j:=1 to g1 do if s[i]=s1[j] then
begin
inc(z);
st[z]:=s[i];
break;
end;
for i:=1 to z-1 do for j:=i+1 to z do if st[i]>st[j] then
begin
t:=st[i];
st[i]:=st[j];
st[j]:=t;
end;
st[z+1]:='-';
for i:=1 to z do i st[i]<>st[i+1] then write(st[i],' ');
end.