#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>

using namespace std;

int cnt_r[200001][4];

int main(){

    int H, W, N;
    cin >> H >> W >> N;
    int sr, sc;
    cin >> sr >> sc;
    string S, T;
    cin >> S;
    cin >> T;

    // L:0, R:1, U:2, D:3

    int temp1 = 0;
    int temp2 = 0;
    int temp3 = 0;
    int temp4 = 0;

    cnt_r[N][0] = 0;
    cnt_r[N][1] = 0;
    cnt_r[N][2] = 0;
    cnt_r[N][3] = 0;

    for(int i = N - 1; i >= 0; i--){
        temp1 = 0;
        if(i != 0 && S[i] == 'L'){
            temp1 += 1;
            cnt_r[i][0] = 1;
        }
        else{
            cnt_r[i][0] = 0;
        }

        if(i != N - 1 && T[i] == 'R'){
            temp1 -= 1;
        }

        cnt_r[i][0] = max(cnt_r[i][0], temp1 + cnt_r[i + 1][0]);
    }

    for(int i = N - 1; i >= 0; i--){
        temp2 = 0;
        if(i != 0 && S[i] == 'R'){
            temp2 += 1;
            cnt_r[i][1] = 1;
        }
        else{
            cnt_r[i][1] = 0;
        }

        if(i != N - 1 && T[i] == 'L'){
            temp2 -= 1;
        }

        cnt_r[i][1] = max(cnt_r[i][1], temp2 + cnt_r[i + 1][1]);
    }

    for(int i = N - 1; i >= 0; i--){
        temp3 = 0;
        if(i != 0 && S[i] == 'U'){
            temp3 += 1;
            cnt_r[i][2] = 1;
        }
        else{
            cnt_r[i][2] = 0;
        }

        if(i != N - 1 && T[i] == 'D'){
            temp3 -= 1;
        }

        cnt_r[i][2] = max(cnt_r[i][2], temp3 + cnt_r[i + 1][2]);
    }

    for(int i = N - 1; i >= 0; i--){
        temp4 = 0;
        if(i != 0 && S[i] == 'D'){
            temp4 += 1;
            cnt_r[i][3] = 1;
        }
        else{
            cnt_r[i][3] = 0;
        }

        if(i != N - 1 && T[i] == 'U'){
            temp4 -= 1;
        }

        cnt_r[i][3] = max(cnt_r[i][3], temp4 + cnt_r[i + 1][3]);
    }

    int tempL = sc;

    for(int i = 0; i < N; i++){

        if(S[i] == 'L'){
            tempL--;
        }

        if(T[i] == 'R'){
            if(cnt_r[i + 1][1] < W - tempL){
                tempL++;
            }
        }

        if(cnt_r[i + 1][0] >= tempL){
            cout << "NO" << endl;
            return 0;
        }
    }

    int tempR = sc;
    for(int i = 0; i < N; i++){
        if(S[i] == 'R'){
            tempR++;
        }
        if(T[i] == 'L'){
            if(cnt_r[i + 1][0] < tempR - 1){
                tempR--;
            }
        }

        if(cnt_r[i + 1][1] > W - tempR){
            cout << "NO" << endl;
            return 0;
        }
    }

    int tempU = sr;
    for(int i = 0; i < N; i++){

        if(S[i] == 'U'){
            tempU--;
        }

        if(T[i] == 'D'){
            if(cnt_r[i + 1][3] < H - tempU){
                tempU++;
            }
        }

        if(cnt_r[i + 1][2] >= tempU){
            cout << "NO" << endl;
            return 0;
        }
    }

    int tempD = sr;
    for(int i = 0; i < N; i++){
        if(S[i] == 'D'){
            tempD++;
        }
        if(T[i] == 'U'){
            if(cnt_r[i + 1][2] < tempD - 1){
                tempD--;
            }
        }

        if(cnt_r[i + 1][3] > H - tempD){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 3848