Added Z algorithm.