SPOJ NHAY

(NHAY)- Needle in a Haystack

 * [ Problem statament]

Summary
Given a string S and a pattern P, find all occurrences of P in S.

Explanation
This is a straightforward implementation of string matching algorithms, the Knuth-Morris-Pratt algorithm is among the easiest.

Input
2 na banananobano 6 foobar foo 9 foobarfoo barfoobarfoobarfoobarfoobarfoo

Output
2 4

3 9 15 21