#include<bits/stdc++.h>
using namespace std;
//不會
int main(){
string a;
getline(cin,a);
int l=a.length();
string b;
bool out=false;
while(getline(cin,b)&&b.length()!=0){
if(b.length()==l){
int f=0,c[26]={0},d[26]={0};
for(int i=0;i<l;i++){
if(a[i]==b[i]){
f=1;break;
}
if(c[a[i]%26]==0)c[a[i]%26]=b[i]-'a'+1;
if(d[b[i]%26]==0)d[b[i]%26]=a[i]-'a'+1;
if(c[a[i]%26]!=b[i]-'a'+1){
f=1;break;
}
if(d[b[i]%26]!=a[i]-'a'+1){
f=1;break;
}
}
if(f==0)cout<<b<<endl,out=true;
}
b="";
}
if(!out)cout<<"impossible\n";
return 0;
}