/1CHIEU - Đường một chiều

<Problem>

http://ntucoder.net/Problem/Details/4484
              Uses Crt;
        Var a,b:longint; s1,s2,temp:string;
        Begin
            readln(a,b);
            readln(s1);
            readln(s2);
            //Ta co the di den tat ca moi noi phu thuoc vao 4 duong mot chieu o ngoai cung
            temp:=s1[1]+s1[a]+s2[1]+s2[b]; //writeln(temp);
            //if temp='RLUD' then writeln(1);
            if (temp='RLUD') or (temp='LRDU') then
             begin
                 writeln('YES');
                 exit;
             end;
            writeln('NO');
        End.