#include<string>
#include<iostream>
#include<vector>
using namespace std;
void replace(string &s, char torep, char rep,const vector<int> &vec,int index )
{
    if (index == vec.size() )
              cout << s<<",";
    else {
        replace(s, torep, rep, vec, index+1);
        s[vec[index]] = rep;
        replace(s, torep, rep, vec, index + 1);
        s[vec[index]] = torep;
    }
}
int main()
{
    string s;
    char torep,rep;
    cin >> s >> torep >> rep;
    vector<int> vec;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == torep)
            vec.push_back(i);
    }
    replace(s, torep, rep,vec,vec[0]);
}