#include<iostream>
#include<vector>
using namespace std;

/*
 * クヌース・モリス・プラット法
 *
 * 単一パターン検索
 */
template<class T> class KMP{
    T pattern;
    vector<int> fail;
public:
    KMP(const T& pattern) : pattern(pattern){
        int pattern_len = (int) pattern.size();
        fail.assign(pattern_len + 1, -1);
        for(int i = 0, j = -1; i < pattern_len; ++i){
            while(j >= 0 && pattern[i] != pattern[j]){
                j = fail[j];
            }
            // 一致しなかった時、次どこから始めるかを格納
            fail[i + 1] = ++j;
        }
    }

    vector<int> match(const T& find){
        int find_len = (int) find.size();
        int pattern_len = (int) pattern.size();
        vector<int> res;
        for(int i = 0, k = 0; i < find_len; ++i){
            while(k >= 0 && find[i] != pattern[k]){
                k = fail[k];
            }
            ++k;
            if(k >= pattern_len){
                // 一致したらSの始まりのidxを格納
                res.push_back(i - pattern_len + 1);
                k = fail[k];
            }

        }
        return res;
    }
};

int main() {

    string find, pattren;
    cin >> find >> pattren;

    KMP<string> kmp(pattren);

    vector<int> ans = kmp.match(find);

    for(int x : ans){
        cout << x << endl;
    }
    return 0;
}


### Prompt

Please formulate a Cpp solution to the following problem:

Find places where a string P is found within a text T. Print all indices of T where P found. The indices of T start with 0.

Constraints

* 1 ≤ length of T ≤ 1000000
* 1 ≤ length of P ≤ 10000
* The input consists of alphabetical characters and digits

Input

In the first line, a text T is given. In the second line, a string P is given.

Output

Print an index of T where P found in a line. Print the indices in ascending order.

Examples

Input

aabaaa
aa


Output

0
3
4


Input

xyzz
yz


Output

1


Input

abc
xyz


Output

### Response

```cpp
#include<iostream>
#include<vector>
using namespace std;

/*
 * クヌース・モリス・プラット法
 *
 * 単一パターン検索
 */
template<class T> class KMP{
    T pattern;
    vector<int> fail;
public:
    KMP(const T& pattern) : pattern(pattern){
        int pattern_len = (int) pattern.size();
        fail.assign(pattern_len + 1, -1);
        for(int i = 0, j = -1; i < pattern_len; ++i){
            while(j >= 0 && pattern[i] != pattern[j]){
                j = fail[j];
            }
            // 一致しなかった時、次どこから始めるかを格納
            fail[i + 1] = ++j;
        }
    }

    vector<int> match(const T& find){
        int find_len = (int) find.size();
        int pattern_len = (int) pattern.size();
        vector<int> res;
        for(int i = 0, k = 0; i < find_len; ++i){
            while(k >= 0 && find[i] != pattern[k]){
                k = fail[k];
            }
            ++k;
            if(k >= pattern_len){
                // 一致したらSの始まりのidxを格納
                res.push_back(i - pattern_len + 1);
                k = fail[k];
            }

        }
        return res;
    }
};

int main() {

    string find, pattren;
    cin >> find >> pattren;

    KMP<string> kmp(pattren);

    vector<int> ans = kmp.match(find);

    for(int x : ans){
        cout << x << endl;
    }
    return 0;
}


```