use std::io::{Read, stdin}; fn main() { let mut buf = String::new(); stdin().read_to_string(&mut buf).unwrap(); let mut tok = buf.split_whitespace(); let mut get = || tok.next().unwrap(); macro_rules! get { ($t:ty) => (get().parse::<$t>().unwrap()); () => (get!(usize)); } let n = get!(); let k = get!(); let mut ls = vec![]; for _ in 0..k { ls.push(get!()); } let mut grid = vec![]; for _ in 0..n { let tmp: Vec<_> = get().as_bytes() .iter() .map(|&ch| (ch - b'0') as i32) .collect(); grid.push(tmp); } // println!("{:?}", grid); for &l in ls.iter() { let mut max_sum = 0; let mut max_i = 0; for i in 0..n { let mut sum = 0; for j in 0..l { sum += grid[i][j]; } if sum > max_sum { max_sum = sum; max_i = i; } } for j in 0..l { grid[max_i][j] = 1 - grid[max_i][j]; } println!("{0} 1 {0} {1}", max_i + 1, l); } }