#include <iostream>
#include <string>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
string s, names;
getline(cin, s);
getline(cin, names);
size_t pos = 0;
while ((pos = names.find(s, pos)) != string::npos) {
names.replace(pos, s.length(), "\n");
pos += 1;
}
cout << names;
return 0;
}