#include //#include using namespace std; //using namespace atcoder; using ll = long long; using ld = long double; //using mint = modint; //mint::set_mod(M); //using mint = modint998244353; //using mint = modint1000000007; template using pq = priority_queue; //大きい順 template using pq_g = priority_queue, greater>; //小さい順 #define vec_unique(v) v.erase(unique(v.begin(), v.end()), v.end()) //重複削除 #define vec_iota(v) iota(v.begin(), v.end(), 0) //0, 1, 2, 3, ..., n - 1にセット #define concat(a, b) a.insert(a.end(), b.begin(), b.end()) #define debug(x) cerr << #x << " = " << x << endl int dx[4] = {1, -1, 0, 0}; int dy[4] = {0, 0, 1, -1}; //int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1}; //int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1}; #define INF 2e18 #define INF2 2e9 int main() { int h, w; cin >> h >> w; vector s(h); for(int i = 0; i < h; i++) { cin >> s[i]; } bool check = false; bool hand = false; for(int i = 0; i < h; i++) { for(int j = 0; j < w; j++) { if(s[i][j] == 'y' && !check && !hand) { check = true; } else if(s[i][j] == 'y' && check && !hand) { hand = true; s[i][j] = 'Y'; } else if(s[i][j] == 'y' && check && hand) { check = false; hand = false; } else if(s[i][j] == '9' && check && hand) { check = false; hand = false; } else if(s[i][j] == '9' && !check && !hand) { check = true; } } } for(int i = 0; i < h; i++) { cout << s[i] << endl; } //cout << fixed << setprecision(15) << << endl; return 0; }