A Needle in the Haystack#2301

A Needle in the Haystack

1 second
122.174 megabytes
Very easy

Write a program that finds all occurrences of a given pattern in a given input string. This is often referred to as finding a needle in a haystack. The program has to find all positions of the needle in the haystack.

Input

The input consists of several test cases. Each test case is composed of three lines:

  • the length of the needle,

  • the needle itself,

  • the haystack.

The length of the needle does not exceed characters. The size of the haystack is not limited; your program should read it as it processes it.

The test cases come one after another, each occupying exactly three lines, with no separators between them.

Output

For each test case your program should output all positions of the needle's occurrences in the haystack. If a match is found, the output should contain the position of the first character of the match. Characters in the haystack are numbered starting from zero.

For each test case, the positions should be sorted in ascending order, and each should be printed on a separate line. Between two different test cases, the positions should be separated by an empty line.

Examples

Example 1

Loading
Loading