#include<fstream>
#include<iterator>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
string from,to;
cin>>from>>to;
ifstream ifs(from.c_str());
istream_iterator<string>ii(ifs);
istream_iterator<string>eos;
vector<string>v;
copy(ii,eos,back_inserter(v));
sort(v.begin(),v.end());
copy(v.begin(), v.end(),ostream_iterator<string>(cout, " ") );
ofstream ofs(to.c_str(),ios_base::app);
ostream_iterator<string>oo(ofs);
unique_copy(v.begin(),v.end(),*oo);
ifs.close();
ofs.close();
system("pause");
return 0;
}