*x,S,T=*$<
eval"H,W,N,I,J="+x.join.split*?,
puts [[H,I,?U,?D],[W,J,?L,?R]].all?{|w,j,a,b|l=0
r=w
(1..N).all?{|k|T[~k]==a&&r<w&&r+=1
T[~k]==b&&l>0&&l-=1
S[~k]==a&&l<w&&l+=1
S[~k]==b&&r>0&&r-=1
l<r}&&l<j&&j<=r}?:YES: :NO