#include using namespace std; typedef long long ll; int main() { int n, m; cin >> n >> m; string s; cin >> s; vector< vector > grids(n + 1, vector(n + 1, false)); grids[n][0] = true; int cx = 0, cy = n; for (int i = 0; i < m; ++i) { if (s[i] == 'D') cy++; else if (s[i] == 'U') cy--; else if (s[i] == 'R') cx++; else cx--; if (cx < n + 1 && cy < n + 1 && cx >= 0 && cy >= 0) grids[cy][cx] = true; } for (int i = 0; i < n + 1; ++i) { for (int j = 0; j < n + 1; ++j) { if (!grids[i][j]) { cout << 1; } else { cout << 0; } if (j < n) cout << ' '; } puts(""); } return 0; }