Aho Corasick - Application
hard
Given an integer n indicating the number of patterns.Then follow n lines, each containing non empty strings, representing patterns. Then comes a non empty string representing text. Output n lines where ith line contains the positions of all occurances of the ith pattern in text.
Constraints
|pattern| < 10^5 |text| < 10^5
Format
Input
First line: n Then follow n lines, each containing non empty strings, representing patterns. Next line consists of a string, text
Output
Print n lines each consisting of occurrences of ith pattern's start index , print -1 if ith pattern doesnt occur
Example
Sample Input
6
ACC
ATC
CAT
GCG
C
T
GCATCG
Sample Output
-1
2
1
-1
1 4
3