ocaml solution to PALIN on spoj