use std::io::{stdin, Read}; fn main() { let mut buf = String::new(); stdin().read_to_string(&mut buf).unwrap(); let mut buf = buf.split_whitespace(); let mut get = || buf.next().unwrap().parse::().unwrap(); let n = get() as usize; let m = get() as usize; let mut xs = vec![]; for _ in 0..n { xs.push(get()); } let mut v = 0; let mut ys = vec![]; for &x in xs.iter() { if v & x > 0 { continue; } v |= x; ys.push(x); if ys.len() >= m { break; } } for i in 0..ys.len() { if i > 0 { print!(" "); } print!("{}", ys[i]); } println!(); }