#include #include #include #include #include #include #include #include #include static const int MOD = 1000000007; using ll = long long; using u32 = unsigned; using u64 = unsigned long long; using namespace std; template constexpr T INF = ::numeric_limits::max()/32*15+208; int main() { int n, m; cin >> n >> m; string s; cin >> s; vector> v(n+1, vector(n+1, 1)); string a = "URLD"; array dy{1, 0, 0, -1}, dx{0, 1, -1, 0}; int y = 0, x = 0; v[y][x] = 0; for (int i = 0; i < m; ++i) { for (int j = 0; j < 4; ++j) { if(s[i] == a[j]) y += dy[j], x += dx[j]; } v[y][x] = 0; } for (int i = 0; i <= n; ++i) { for (int j = 0; j <= n; ++j) { if(j) printf(" "); printf("%d", v[n-i][j]); } puts(""); } return 0; }