let () = Scanf.scanf "%d %d %d\n%d %d\n%s\n%s\n" @@ fun h w n sr sc s t ->
  let racc_u = Array.make_matrix (n + 1) 2 sr in
  let racc_d = Array.make_matrix (n + 1) 2 sr in
  let cacc_l = Array.make_matrix (n + 1) 2 sc in
  let cacc_r = Array.make_matrix (n + 1) 2 sc in
  for i = 0 to n - 1 do
    racc_u.(i + 1).(0) <- racc_u.(i).(1) - if s.[i] = 'U' then 1 else 0;
    racc_u.(i + 1).(1) <- min h (racc_u.(i + 1).(0) + if t.[i] = 'D' then 1 else 0);

    racc_d.(i + 1).(0) <- racc_d.(i).(1) + if s.[i] = 'D' then 1 else 0;
    racc_d.(i + 1).(1) <- max 1 (racc_d.(i + 1).(0) - if t.[i] = 'U' then 1 else 0);

    cacc_l.(i + 1).(0) <- cacc_l.(i).(1) - if s.[i] = 'L' then 1 else 0;
    cacc_l.(i + 1).(1) <- min w (cacc_l.(i + 1).(0) + if t.[i] = 'R' then 1 else 0);

    cacc_r.(i + 1).(0) <- cacc_r.(i).(1) + if s.[i] = 'R' then 1 else 0;
    cacc_r.(i + 1).(1) <- max 1 (cacc_r.(i + 1).(0) - if t.[i] = 'L' then 1 else 0)
  done;
  print_endline @@
  if
    Array.fold_left (Array.fold_left ( && )) true @@
    Array.init (n + 1) @@ fun i ->
      Array.init 2 @@ fun j ->
        0 < racc_u.(i).(j) && racc_d.(i).(j) <= h &&
        0 < cacc_l.(i).(j) && cacc_r.(i).(j) <= w
  then "YES"
  else "NO"

