// editor1
#include<iostream>
#include<string>
int main()
{
std::string s;
char c1, c2;
std::getline(std::cin, s);
std::cin >> c1 >> c2;
bool foundC1 = s.find(c1) != std::string::npos;
bool foundC2 = s.find(c2) != std::string::npos;
if (!foundC2)
{
std::cout << "-1" << std::end1;
}
else
{
for (char& c : s)
{
if (c == c1) c = c1;
else if (c == c2) c = c1;
}
std::cout << s << std::end1;
}
return 0;