#include<iostream>
using namespace std;
#include<string.h>
#include<stack>
#define max_len 15//字元串的最大長度
int num_push,num_pop;
int x[max_len*2];
char str[max_len+1];
int n;
stack<char> operate;
char target[max_len+1];
int count11[26], count12[26];
int count21[26], count22[26];
bool first_check(char str1[],char str2[])//先做粗略的檢查
{
int len1=strlen(str1), len2=strlen(str2);
if(len1!=len2)
return false;
for(int index=0;index<26;index++)
count11[index]=count12[index]=count21[index]=count22[index]=0;
len1--; len2--;
while(len1>=0)
{
if(str1[len1]>='A' && str1[len1]<='Z')
count11[str1[len1]-'A']++;
else count12[str1[len1]-'a']++;
len1--;
}
while(len2>=0)
{
if(str2[len2]>='A' && str2[len2]<='Z')
count21[str2[len2]-'A']++;
else count22[str2[len2]-'a']++;
len2--;
}
for(int i=0;i<26;i++)
{
if(count11[i]!=count21[i] || count12[i]!=count22[i])
return false;
}
return true;
}
bool mid_check(int num_pop)
{
char temp[max_len+1];
int p,q; p=q=0;
int i=0;
while(operate.size())
{
operate.pop();
}
while(q<num_pop)
{
if(x[i]==0)
{
operate.push(str[p]); p++;
}
else
{
temp[q]=operate.top(); q++;
operate.pop();
}
i++;
}
temp[q]='/0';
for(int index=0;index<num_pop;index++)
{
if(temp[index]!=target[index])
return false;
}
return true;
}
void dfs(int level)
{
if(level>n)
{
for(int i=0;i<n;i++)
if(x[i]==0)
cout<<'i'<<' ';
else cout<<'o'<<' ';
cout<<endl;
}
else
{
for(int i=0;i<2;i++)
{
if(i==0)
{
if(num_push+1<=n/2 && num_pop<=n/2)
{
x[level-1]=0; num_push++;
dfs(level+1);
num_push--;
}
}
else
{
if( num_push<=n/2 && num_pop+1<=n/2 && num_pop+1<=num_push )
{
x[level-1]=1; num_pop++;
if(mid_check(num_pop) == false)
{
num_pop--;
return;
}
dfs(level+1);
num_pop--;
}
}
}
}
}
int main()
{
while(cin>>str>>target)
{
if(first_check(str,target))
{
cout<<'['<<endl;
n=strlen(str);
n*=2;
num_push=num_pop=0;
dfs(1);
cout<<']'<<endl;
}
else
{
cout<<'['<<endl;
cout<<']'<<endl;
}
}
return 0;
}
#include<iostream>
using namespace std;
#include<string.h>
#include<stack>
#define max_len 15//字元串的最大長度
int num_push,num_pop;
int x[max_len*2];
char str[max_len+1];
int n;
stack<char> operate;
char target[max_len+1];
int count11[26], count12[26];
int count21[26], count22[26];
bool first_check(char str1[],char str2[])//先做粗略的檢查
{
int len1=strlen(str1), len2=strlen(str2);
if(len1!=len2)
return false;
for(int index=0;index<26;index++)
count11[index]=count12[index]=count21[index]=count22[index]=0;
len1--; len2--;
while(len1>=0)
{
if(str1[len1]>='A' && str1[len1]<='Z')
count11[str1[len1]-'A']++;
else count12[str1[len1]-'a']++;
len1--;
}
while(len2>=0)
{
if(str2[len2]>='A' && str2[len2]<='Z')
count21[str2[len2]-'A']++;
else count22[str2[len2]-'a']++;
len2--;
}
for(int i=0;i<26;i++)
{
if(count11[i]!=count21[i] || count12[i]!=count22[i])
return false;
}
return true;
}
bool mid_check(int num_pop)
{
char temp[max_len+1];
int p,q; p=q=0;
int i=0;
while(operate.size())
{
operate.pop();
}
while(q<num_pop)
{
if(x[i]==0)
{
operate.push(str[p]); p++;
}
else
{
temp[q]=operate.top(); q++;
operate.pop();
}
i++;
}
temp[q]='/0';
for(int index=0;index<num_pop;index++)
{
if(temp[index]!=target[index])
return false;
}
return true;
}
void dfs(int level)
{
if(level>n)
{
for(int i=0;i<n;i++)
if(x[i]==0)
cout<<'i'<<' ';
else cout<<'o'<<' ';
cout<<endl;
}
else
{
for(int i=0;i<2;i++)
{
if(i==0)
{
if(num_push+1<=n/2 && num_pop<=n/2)
{
x[level-1]=0; num_push++;
dfs(level+1);
num_push--;
}
}
else
{
if( num_push<=n/2 && num_pop+1<=n/2 && num_pop+1<=num_push )
{
x[level-1]=1; num_pop++;
if(mid_check(num_pop) == false)
{
num_pop--;
return;
}
dfs(level+1);
num_pop--;
}
}
}
}
}
int main()
{
while(cin>>str>>target)
{
if(first_check(str,target))
{
cout<<'['<<endl;
n=strlen(str);
n*=2;
num_push=num_pop=0;
dfs(1);
cout<<']'<<endl;
}
else
{
cout<<'['<<endl;
cout<<']'<<endl;
}
}
return 0;
}