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; for i in 0..m { v ^= xs[i]; } for j in 0..n { for i in m..n { let i = i + (i + j) % 7; if i >= n { break; } let e = v ^ xs[j] ^ xs[i]; if e > v { xs.swap(i, j); v = e; break; } } } for i in 0..m { if i > 0 { print!(" "); } print!("{}", xs[i]); } println!(); }