IDENTIFICATION DIVISION.
PROGRAM-ID. 141B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 S     PIC X(101).
01 CNT   PIC 9(3).
01 SW    PIC 9(1).
01 I     PIC 9(3).
01 OUT   PIC X(3).
01 X     PIC X(1).
   88 R  VALUES IS 'R' 'U' 'D'.
   88 L  VALUES IS 'L' 'U' 'D'.
*>
PROCEDURE DIVISION.
  ACCEPT S.
  UNSTRING S DELIMITED BY ' '
      INTO S COUNT CNT.
*>
  MOVE 0     TO SW.
  MOVE 'Yes' TO OUT.
  PERFORM VARYING I FROM 1 BY 1 
    UNTIL (I > CNT) OR (OUT = 'No')
*>
    MOVE S(I:1) TO X
    IF NOT ((SW = 0 AND R) OR (SW = 1 AND L))
      MOVE 'No' TO OUT
    END-IF
*>
    COMPUTE SW = 1 - SW
  END-PERFORM.
*>
  DISPLAY OUT.
  STOP RUN.
