#include #include #include #include #include #include #include #include using namespace std; int main() { int n, m, x = 0, y = 0, cnt = 0; string s; cin >> n >> m >> s; vector> v(n+1, vector(n+1, 1)); v[0][0] = 0; for (int i = 0; i < s.size(); i++){ if (s[i] == 'R') x++; else if (s[i] == 'L') x--; else if (s[i] == 'U') y++; else y--; if (v[y][x]) v[y][x]--; } string delim = ""; for (int i = n; i >= 0; i--){ for (auto p : v[i]){ cout << delim << p; delim = " "; cnt++; if (!(cnt % (n+1))){ cout << endl; delim = ""; } } } }