;; -*- 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 ()
  (declare #.OPT)
  (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))
         (threshold-h-sup (+ w 1))
         (threshold-h-inf 0)
         (threshold-v-sup (+ h 1))
         (threshold-v-inf 0))
    (declare (uint32 threshold-h-sup threshold-h-inf threshold-v-sup threshold-v-inf h w n sx sy))
    (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 threshold-h-inf (max 0 (- threshold-h-inf 1))))
               (#\L (setf threshold-h-sup (min (+ w 1) (+ threshold-h-sup 1))))
               (#\D (setf threshold-v-inf (max 0 (- threshold-v-inf 1))))
               (#\U (setf threshold-v-sup (min (+ h 1) (+ threshold-v-sup 1)))))
             (case (aref t-moves i)
               (#\R (decf threshold-h-sup))
               (#\L (incf threshold-h-inf))
               (#\D (decf threshold-v-sup))
               (#\U (incf threshold-v-inf)))
          ;; (dbg threshold-h-sup threshold-h-inf threshold-v-sup threshold-v-inf)
             (when (or (<= (- threshold-h-sup threshold-h-inf) 1)
                       (<= (- threshold-v-sup threshold-v-inf) 1))
               (write-line "NO")
               (return-from main)))
    (write-line (if (and (< threshold-h-inf sx threshold-h-sup)
                         (< threshold-v-inf sy threshold-v-sup))
                    "YES"
                    "NO"))))

#-swank(main)


Measured memory_bytes: 24932