`#include[HTML_REMOVED]
using namespace std;
map[HTML_REMOVED]a;
char ch;
string s1,s2;
string find(string s)
{
return a[s]==s?s:a[s]=find(a[s]);
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
while(cin>>ch&&ch!=’$’)
{
cin>>s1;
if(ch==’#’)
{
s2=s1;
if(a[s1]==”“)a[s1]=s1;
}
else if(ch==’+’)a[s1]=s2;
else cout<<s1<<” “<<find(s1)<<endl;
}
return 0;
}`