;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(declaim (inline read-line-into))
(defun read-line-into (buffer-string &key (in *standard-input*) (terminate-char #\Space))
  (declare (simple-base-string buffer-string))
  (loop for c of-type base-char =
           #-swank (code-char (read-byte in nil #.(char-code #\Newline)))
           #+swank (read-char in nil #\Newline)
        for idx from 0
        until (char= c #\Newline)
        do (setf (schar buffer-string idx) c)
        finally (when (< idx (length buffer-string))
                  (setf (schar buffer-string idx) terminate-char))
                (return (values buffer-string idx))))

(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((h (read))
         (w (read))
         (n (read))
         (sy (read))
         (sx (read))
         (t-moves (make-string n :element-type 'base-char))
         (a-moves (make-string n :element-type 'base-char))
         (danger-h-sup (+ w 1))
         (danger-h-inf 0)
         (danger-v-sup (+ h 1))
         (danger-v-inf 0))
    (read-line-into t-moves)
    (read-line-into a-moves)
    (loop for i from (- n 1) downto 0
          do (case (aref a-moves i)
               (#\R (setf danger-h-inf (max 0 (- danger-h-inf 1))))
               (#\L (setf danger-h-sup (min (+ w 1) (+ danger-h-sup 1))))
               (#\D (setf danger-v-inf (max 0 (- danger-v-inf 1))))
               (#\U (setf danger-v-sup (min (+ h 1) (+ danger-v-sup 1)))))
             (case (aref t-moves i)
               (#\R (decf danger-h-sup))
               (#\L (incf danger-h-inf))
               (#\D (decf danger-v-sup))
               (#\U (incf danger-v-inf)))
          ;; (dbg danger-h-sup danger-h-inf danger-v-sup danger-v-inf)
             (when (or (<= (- danger-h-sup danger-h-inf) 1)
                       (<= (- danger-v-sup danger-v-inf) 1))
               (write-line "NO")
               (return-from main)))
    (write-line (if (and (< danger-h-inf sx danger-h-sup)
                         (< danger-v-inf sy danger-v-sup))
                    "YES"
                    "NO"))))

#-swank(main)


Measured memory_bytes: 26980