use proconio::{input, marker::Chars}; fn main() { input!{ h: usize, w: usize, mut s: [Chars; h] } for i in 0..h{ for j in (0..w).rev(){ if s[i][j] == '9'{ if j == w - 1{ s[i][j - 1] = 'Y' } else if s[i][j + 1] == 'y' && j + 5 < w && s[i][j + 5] == 'y'{ continue; } else if j > 0{ s[i][j - 1] = 'Y' } } } } for s in s{ let s = s.iter().collect::(); println!("{}", s.replace("9yiwiy", "9Yiwiy")); } }