use std::io; fn main() { let mut nm = String::new(); io::stdin().read_line(&mut nm).ok(); let nm: Vec = nm.trim().split_whitespace() .map(|e| e.parse().unwrap()).collect(); let mut s = String::new(); io::stdin().read_line(&mut s).ok(); let mut p: (usize, usize) = (0, 0); let mut lat: Vec> = vec![vec![1; nm[0] + 1]; nm[0] + 1]; lat[0][0] = 0; for e in s.chars() { match e { 'U' => { p.0 += 1 }, 'D' => { p.0 -= 1 }, 'R' => { p.1 += 1 }, 'L' => { p.1 -= 1 }, _ => {}, }; if p.0 >= 0 && p.0 <= nm[0] && p.1 >= 0 && p.1 <= nm[0] { lat[p.0][p.1] = 0; } } lat.iter().rev().for_each(|e| { println!("{}", e.iter().map(|i| i.to_string()).collect::>().join(" ")); }); }