function func(var ch: string): string; const ss: array[1 .. 4] of string = ('nord','west','east','south'); var s: string; error, found: boolean; i, j: integer; begin s := ''; error := false; if length(ch) > 2 then error := true else for i := 1 to length(ch) do if pos(ch[i], copy(ch, 1, i - 1)) > 0 then error := true else begin found := false; for j := 1 to 4 do begin if ch[i] = copy(ss[j], 1, 1) then begin s := s + ' ' + ss[j]; found := true; end; end; if not found then error := true; end; if error then func := 'error !' else func := s; end; var ch : string; begin write('s = '); readln(ch); writeln(func(ch)); end.