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

struct KnuthMorrisPratt {
    string ptn;
    vector<int> fail;   // longest prefix suffix matching of [0, i)
    KnuthMorrisPratt(const string &ptn) : ptn(ptn) {
        int m = ptn.size();
        fail.assign(m + 1, -1);
        for (int i = 0, j = -1; i < m; i++) {
            while (j >= 0 && ptn[i] != ptn[j]) j = fail[j];
            fail[i + 1] = ++j;
        }
    }
    // the period of ptn[0:i]
    int period(int i) { return i - fail[i]; }
    // the index i such that S[i:] has the exact prefix p
    vector<int> match(const string &s) {
        int m = ptn.size(), n = s.size();
        vector<int> res;
        for (int i = 0, k = 0; i < n; i++) {
            while (k >= 0 && s[i] != ptn[k]) k = fail[k];
            if (++k == m) res.emplace_back(i - m + 1);
        }
        return res;
    }
};

int main() {
    string T, P;
    cin >> T >> P;
    for (int i: KnuthMorrisPratt(P).match(T)) cout << i << endl;
    return 0;
}

### Prompt

Develop a solution in CPP to the problem described below:

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 <algorithm>
#include <iostream>
#include <vector>
using namespace std;

struct KnuthMorrisPratt {
    string ptn;
    vector<int> fail;   // longest prefix suffix matching of [0, i)
    KnuthMorrisPratt(const string &ptn) : ptn(ptn) {
        int m = ptn.size();
        fail.assign(m + 1, -1);
        for (int i = 0, j = -1; i < m; i++) {
            while (j >= 0 && ptn[i] != ptn[j]) j = fail[j];
            fail[i + 1] = ++j;
        }
    }
    // the period of ptn[0:i]
    int period(int i) { return i - fail[i]; }
    // the index i such that S[i:] has the exact prefix p
    vector<int> match(const string &s) {
        int m = ptn.size(), n = s.size();
        vector<int> res;
        for (int i = 0, k = 0; i < n; i++) {
            while (k >= 0 && s[i] != ptn[k]) k = fail[k];
            if (++k == m) res.emplace_back(i - m + 1);
        }
        return res;
    }
};

int main() {
    string T, P;
    cin >> T >> P;
    for (int i: KnuthMorrisPratt(P).match(T)) cout << i << endl;
    return 0;
}

```