IDENTIFICATION DIVISION.
PROGRAM-ID. 161A.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP        PIC X(20).
01 X          PIC 9(3).
01 Y          PIC 9(3).
01 Z          PIC 9(3).
01 I          PIC 9(2).
01 J          PIC 9(2).
01 P          PIC 9(2).
01 ED.
   03 A       PIC ZZ9.
   03 FIILER  PIC X VALUE SPACE.
   03 B       PIC ZZ9.
   03 FIILER  PIC X VALUE SPACE.
   03 C       PIC ZZ9.
   03 FIILER  PIC X VALUE SPACE.
01 OUT        PIC X(12).
*>
PROCEDURE DIVISION.
  ACCEPT INP.
*>
  UNSTRING INP DELIMITED BY ' '
      INTO X Y Z.
  MOVE X TO B.
  MOVE Y TO C.
  MOVE Z TO A.
*>
  MOVE SPACE TO OUT.
  MOVE 1 TO P.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > 3
    PERFORM VARYING P FROM P BY 1 UNTIL ED(P:1) <> ' '
    END-PERFORM
    PERFORM VARYING P FROM P BY 1 UNTIL ED(P:1) = ' '
        ADD 1 TO J 
        MOVE ED(P:1) TO OUT(J:1)
    END-PERFORM
    ADD 1 TO J
    MOVE ' ' TO OUT(J:1)
  END-PERFORM
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.
