procedure main()
   while writes(line := read()) do
      if line ? (ABCD("","","","") & pos(0))
      then write(" accepted")
      else write(" rejected")
end

procedure ABCD(A,B,C,D)
   suspend (=A || =B || =C || =D) |
      (="a" || ABCD(A,"b" || B,C || "c",D) || ="d")
end
