unittest
{
	assert( [ "2 3 3", "2 2", "RRL", "LUD" ].parse.expand.solve == "YES" );
	assert( [ "4 3 5", "2 2", "UDRRR", "LLDUD" ].parse.expand.solve == "NO" );
	assert( [ "5 6 11", "2 1", "RLDRRUDDLRL", "URRDRLLDLRD" ].parse.expand.solve == "NO" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto hwn = input.front.split.to!( long[] );
	input.popFront;
	auto rc = input.front.split.to!( long[] );
	input.popFront;
	auto s = input.front.to!( dchar[] );
	input.popFront;
	auto t = input.front.to!( dchar[] );
	return tuple( hwn[ 0 ], hwn[ 1 ], rc[ 0 ], rc[ 1 ], s, t );
}

auto solve( long h, long w, long r, long c, dchar[] s, dchar[] t )
{
	// 縦と横は別に考えて良い
	if( solve2!( 'U', 'D' )( h, r, s, t ) && solve2!( 'L', 'R' )( w, c, s, t ) ) return "YES";
	else                                                                         return "NO";
}

auto solve2( dchar L, dchar R )( long w, long p, dchar[] s, dchar[] t )
{
	// 駒を取り除けることが確定する範囲を計算
	auto ll = 0L;
	auto rr = w + 1;
	auto l  = ll;
	auto r  = rr;
	foreach( sc, tc; zip( s, t ).retro )		// 逆順で考える
	{
		switch( tc )
		{
			case L: r += ( r < rr ); break;
			case R: l -= ( ll < l ); break;
			default: /* nop */       break;
		}
		switch( sc )
		{
			case L: l++;       break;
			case R: r--;       break;
			default: /* nop */ break;
		}
		if( l + 1 == r ) break;
	}
	return ( l < p && p < r );
}
