use proconio::input; fn main() { input!{ h: usize, w: usize, mut s: [String; h] } if w<6 { for i in 0..h{ println!("{}", s[i]); } return; } for i in 0..h { let mut j = 0; while j <= w-6 { if &s[i][j..j+6] == "yiwiy9" { s[i].replace_range(j..j+6, "yiwiY9"); j += 6; } else if &s[i][j..j+6] == "9yiwiy" { s[i].replace_range(j..j+6, "9Yiwiy"); j+=6; } else { j+=1; } } println!("{}", s[i]); } }