#include <bits/stdc++.h>
using namespace std;
#define itn int

template <class T, class T2>
class LazySegTree {
    using F = function<T(T, T)>;
    using G = function<T(T, T2)>;
    using H = function<T2(T2, T2)>;
    using P = function<T2(T2, int)>;
    int n;
    vector<T> data;
    vector<T2> lazy;
    const F f;
    const G g;
    const H h;
    const P p;
    const T e;
    const T2 e2;

public:
    LazySegTree(const vector<T>& as, const F f, const G g, const H h, const P p, const T& e, const T2 e2) : f(f), g(g), h(h), p(p), e(e), e2(e2) {
        n = 1;
        while (n < as.size()) n <<= 1;
        data.assign(2 * n, e);
        lazy.assign(2 * n, e2);
        for (int i = 0; i < as.size(); i++) {
            data[n + i] = as[i];
        }
        for (int i = n - 1; i > 0; i--) {
            data[i] = f(data[2 * i], data[2 * i + 1]);
        }
    }

    void propagate(int k, int len) {
        if (lazy[k] != e2) {
            if (k < n) {
                lazy[2 * k] = h(lazy[2 * k], lazy[k]);
                lazy[2 * k + 1] = h(lazy[2 * k + 1], lazy[k]);
            }
            data[k] = g(data[k], p(lazy[k], len));
            lazy[k] = e2;
        }
    }

    T update(int a, int b, const T2& x, int k, int l, int r) {
        propagate(k, r - l);
        if (r <= a || b <= l) {
            return data[k];
        } else if (a <= l && r <= b) {
            lazy[k] = h(lazy[k], x);
            propagate(k, r - l);
            return data[k];
        } else {
            return data[k] = f(update(a, b, x, 2 * k, l, (l + r) >> 1), update(a, b, x, 2 * k + 1, (l + r) >> 1, r));
        }
    }

    T update(int a, int b, const T2& x) {
        return update(a, b, x, 1, 0, n);
    }

    T query(int a, int b, int k, int l, int r) {
        propagate(k, r - l);
        if (r <= a || b <= l) {
            return e;
        } else if (a <= l && r <= b) {
            return data[k];
        } else {
            return f(query(a, b, 2 * k, l, (l + r) >> 1), query(a, b, 2 * k + 1, (l + r) >> 1, r));
        }
    }

    T query(int a, int b) {
        return query(a, b, 1, 0, n);
    }
};

int main() {
    int H, W, n;
    cin >> H >> W >> n;
    int sx, sy;
    cin >> sx >> sy;
    sx--, sy--;
    string s, t;
    cin >> s >> t;
    vector<int> R(n), L(n), U(n), D(n);
    vector<int> cR(n + 1), cL(n + 1), cU(n + 1), cD(n + 1);
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') {
            R[i]++;
        }
        if (s[i] == 'L') {
            L[i]++;
        }
        if (s[i] == 'U') {
            U[i]++;
        }
        if (s[i] == 'D') {
            D[i]++;
        }
        if (t[i] == 'R') cR[i + 1]++;
        if (t[i] == 'L') cL[i + 1]++;
        if (t[i] == 'U') cU[i + 1]++;
        if (t[i] == 'D') cD[i + 1]++;
        if (i < n - 1) {
            if (t[i] == 'L') R[i + 1]--;
            if (t[i] == 'R') L[i + 1]--;
            if (t[i] == 'D') U[i + 1]--;
            if (t[i] == 'U') D[i + 1]--;
        }
    }
    for (int i = 1; i < n; i++) {
        R[i] += R[i - 1];
        L[i] += L[i - 1];
        U[i] += U[i - 1];
        D[i] += D[i - 1];
    }
    for (int i = 1; i <= n; i++) {
        cR[i] += cR[i - 1];
        cL[i] += cL[i - 1];
        cU[i] += cU[i - 1];
        cD[i] += cD[i - 1];
    }

    auto f = [](int a, int b) { return max(a, b); };
    auto g = [](int a, int b) { return a + b; };
    auto h = [](int a, int b) { return a + b; };
    auto p = [](int a, int b) { return a; };
    LazySegTree<int, int> fR(R, f, g, h, p, -1e9, 0);
    LazySegTree<int, int> fL(L, f, g, h, p, -1e9, 0);
    LazySegTree<int, int> fU(U, f, g, h, p, -1e9, 0);
    LazySegTree<int, int> fD(D, f, g, h, p, -1e9, 0);

    itn nR = W - sy, nL = sy + 1, nU = sx + 1, nD = H - sx;
    for (int i = 0; i < n; i++) {
        int fr = fR.query(i, n);
        int br = min(cL[i], sy);
        if (fr - br >= nR) {
            cout << "NO" << endl;
            return 0;
        }
        int fl = fL.query(i, n);
        int bl = min(cR[i], W - 1 - sy);
        if (fl - bl >= nL) {
            cout << "NO" << endl;
            return 0;
        }
        int fu = fU.query(i, n);
        int bu = min(cD[i], H - 1 - sx);
        if (fu - bu >= nU) {
            cout << "NO" << endl;
            return 0;
        }
        int fd = fD.query(i, n);
        int bd = min(cU[i], sx);
        if (fd - bd >= nD) {
            cout << "NO" << endl;
            return 0;
        }
        if (s[i] == 'R') {
            fR.update(i, n, -1);
        }
        if (s[i] == 'L') {
            fL.update(i, n, -1);
        }
        if (s[i] == 'U') {
            fU.update(i, n, -1);
        }
        if (s[i] == 'D') {
            fD.update(i, n, -1);
        }
        if (i < n - 1) {
            if (t[i] == 'L') {
                fR.update(i + 1, n, 1);
            }
            if (t[i] == 'R') {
                fL.update(i + 1, n, 1);
            }
            if (t[i] == 'D') {
                fU.update(i + 1, n, 1);
            }
            if (t[i] == 'U') {
                fD.update(i + 1, n, 1);
            }
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 23432