n,m=map(int,input().split()) a=[[1]*(n+1)for _ in range(n+1)] a[n][0]=0 y,x=n,0 for c in input(): if c=='U':y-=1 if c=='D':y+=1 if c=='L':x-=1 if c=='R':x+=1 a[y][x]=0 for b in a: print(*b)