use proconio::input; fn main() { println!("{}", if solve() { "Yes" } else { "No" }); } fn solve() -> bool { input! { (n, m): (usize, usize), ss: [String; m], } if !ss.contains(&"0".repeat(n)) || !ss.contains(&"1".repeat(n)) { return false; } let set = ss .iter() .map(|s| { s.chars() .fold(0_usize, |acc, c| 2 * acc + (c == '1') as usize) }) .collect::>(); let mut exists = vec![false; 1 << n]; for &bits in &set { exists[bits] = true; } for &bits1 in &set { for &bits2 in &set { if !exists[bits1 & bits2] || !exists[bits1 | bits2] { return false; } } } true }