n,m=map(int,input().split()) s=input() grid=[[1]*(n+1) for _ in range(n+1)] y=n;x=0 grid[y][x]=0 for i in range(m): if s[i]=='U': y-=1 elif s[i]=='D': y+=1 elif s[i]=='L': x-=1 else: x+=1 grid[y][x]=0 for i in grid: print(*i)