There are a pattern and a text . Apply the Rabin-Karp algorithm for the strings using the polynomial hash function with and .
The output should contain lines consisting of 3 numbers: the first is the hash value for the current substring of the text, the second is the number of symbol-by-symbol comparisons of the pattern with the current substring, and the third is 1 if the substrings are equal and 0 otherwise.
Keep it in mind that hashes are calculated starting from the right.
For instance, the output may look like this:
1 2 3
4 5 6
7 8 9
7 7 7