use std::io::Read; fn main() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let l: Vec<_> = s.split_whitespace().collect(); let n = l[0].parse::().unwrap() + 1; let mut a = vec!["1"; n * n]; let (mut x, mut y) = (0, n - 1); a[n * n - n] = "0"; for d in l[2].chars() { match d { 'D' => y = (y + 1) % n, 'U' => y = (y + n - 1) % n, 'L' => x = (x + 1) % n, 'R' => x = (x + n - 1) % n, _ => (), } a[x + y * n] = "0"; } a.chunks(n).for_each(|r| println!("{}", r.join(" "))); }