#include<iostream>
#include <cstring>
#include<cstdio>
using namespace std;
const char E[]="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
class Set
{
private:
char str[200];
int count;
public:
Set()
{
count=0;
str[0]='/0';
}
Set(const char *s)
{
for(int i=0;i<strlen(s);i++)
{
str[i]=s[i];
count++;
}
str[count]='/0';
}
void order_output()//排序去重
{
char p[200];
int m=0;
for(int j=0;E[j]!='/0';j++)
for(int i=0;str[i]!='/0';i++)
if(str[i]==E[j])
{
p[m]=str[i];
m++;
break;
}
count=m;
p[m]='/0';
for(int i=0;i<m;i++)
str[i]=p[i];
str[m]='/0';
}
Set operator & (const Set &x) const//交集操作符重载
{
Set p1;int m=0;
for (int i=0;str[i]!='/0';i++)
for(int j=0;x.str[j]!='/0';j++)
{
if (str[i]==x.str[j])
{
p1.str[m]=str[i];
m++;
}
}
p1.str[m]='/0';
p1.order_output();
p1.output ();
return p1;
}
Set operator |(const Set &x) const//并集操作符重载
{
Set p2;
strcpy(p2.str,str);
strcat(p2.str,x.str);
p2.order_output();
p2.output ();
return p2;
}
Set operator -(const Set &x) const//差集操作符重载
{
Set p3;
int m=0;
for(int i=0;str[i]!='/0';i++)
{
int j;
for(j=0;x.str[j]!='/0';j++)
if(str[i]==x.str[j]) break;
if(x.str[j]=='/0')
{
p3.str[m]=str[i];
m++;
}
}
p3.str[m]='/0';
p3.output ();
return p3;
}
Set jueduibu() const//补集函数
{
Set p4;int m=0;
for(int i=0;E[i]!='/0';i++)
{
int j;
for(j=0;str[j]!='/0';j++)
if(E[i]==str[j]) break;
if(str[j]=='/0')
{
p4.str[m]=E[i];
m++;
}
}
p4.str[m]='/0';
p4.output();
return p4;
}
void output()
{
cout<<"{";
if(strlen(str)>0)
{
for(int i=0;i<strlen(str)-1;i++)
cout<<str[i]<<",";
cout<<str[strlen(str)-1];
}
cout<<"}"<<endl;
}
friend istream& operator>>(istream& in, Set& x);
};
istream& operator>>(istream& in, Set& x)
{
in >>x.str;
return in;
}
int main()
{
Set a,b;
cin>>a;
a.order_output();
a.output ();
cin>>b;
b.order_output ();
b.output();
a&b;
a|b;
a-b;
a.jueduibu ();
return 0;
}