import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); HashSet set = new HashSet<>(); set.add(0); char[] arr = sc.next().toCharArray(); int current = 0; for (char c : arr) { if (c == 'L') { current--; } else if (c == 'U') { current += n + 1; } else if (c == 'D') { current -= n + 1; } else { current++; } set.add(current); } StringBuilder sb = new StringBuilder(); for (int i = n; i >= 0; i--) { for (int j = 0; j <= n; j++) { if (j > 0) { sb.append(" "); } if (set.contains(i * (n + 1) + j)) { sb.append("0"); } else { sb.append("1"); } } sb.append("\n"); } System.out.print(sb); } }