use proconio::{fastout, input}; const DIRS: [(isize, isize); 4] = [(0, 1), (1, 0), (0, -1), (-1, 0)]; trait OrdExt { fn chmax(&mut self, other: Self) -> bool; fn chmin(&mut self, other: Self) -> bool; } impl OrdExt for T { fn chmax(&mut self, other: Self) -> bool { if *self < other { *self = other; true } else { false } } fn chmin(&mut self, other: Self) -> bool { if *self > other { *self = other; true } else { false } } } #[fastout] fn main() { input! { N: usize, K: usize, S: [String; N], T: [String; N], } let mut isok = true; for k in 0..K { let mut S2 = S.iter().skip(k).step_by(K).cloned().collect::>(); let mut T2 = T.iter().skip(k).step_by(K).cloned().collect::>(); S2.sort(); T2.sort(); if S2 != T2 { isok = false; break; } } if isok { println!("Yes"); } else { println!("No"); } }