Two version - very fresh of karp rabin alg