Problem:
Score : 1100 points

Problem Statement

We will call a string that can be obtained by concatenating two equal strings an even string.
For example, xyzxyz and aaaaaa are even, while ababab and xyzxy are not.

For a non-empty string S, we will define f(S) as the shortest even string that can be obtained by appending one or more characters to the end of S.
For example, f(abaaba)=abaababaab.
It can be shown that f(S) is uniquely determined for a non-empty string S.

You are given an even string S consisting of lowercase English letters.
For each letter in the lowercase English alphabet, find the number of its occurrences from the l-th character through the r-th character of f^{10^{100}} (S).

Here, f^{10^{100}} (S) is the string f(f(f( ... f(S) ... ))) obtained by applying f to S 10^{100} times.

Constraints

2 \leq |S| \leq 2\times 10^5

1 \leq l \leq r \leq 10^{18}

S is an even string consisting of lowercase English letters.

l and r are integers.

Input

Input is given from Standard Input in the following format:

S
l r

Output

Print 26 integers in a line with spaces in between.
The i-th integer should be the number of the occurrences of the i-th letter in the lowercase English alphabet from the l-th character through the r-th character of f^{10^{100}} (S).

Sample Input 1

abaaba
6 10

Sample Output 1

3 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Since f(abaaba)=abaababaab, the first ten characters in f^{10^{100}}(S) is also abaababaab. Thus, the sixth through the tenth characters are abaab. In this string, a appears three times, b appears twice and no other letters appear, and thus the output should be 3 and 2 followed by twenty-four 0s.

Sample Input 2

xx
1 1000000000000000000

Sample Output 2

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1000000000000000000 0 0

Sample Input 3

vgxgpuamkvgxgvgxgpuamkvgxg
1 1000000000000000000

Sample Output 3

87167725689669676 0 0 0 0 0 282080685775825810 0 0 0 87167725689669676 0 87167725689669676 0 0 87167725689669676 0 0 0 0 87167725689669676 141040342887912905 0 141040342887912905 0 0

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
string trans(string s) {
    for (int i = s.size() - 1; i >= 0; i--) {
        if (s.substr(0, i) == s.substr(s.size() - i, i)) {
            string b = s.substr(0, s.size() - i);
            return s + b;
        }
    }
    assert(false);
    return "";
}
void stupid() {
    while (true) {
        string s;
        int p = rand() % 7 + 2;
        for (int i = 0; i < p; i++) {
            s += (char) (rand() % 2 + 'a');
        }
        string ns = trans(s);
        int blen = ns.size() - s.size();
        int slen = s.size() - blen;
//        if (blen <= slen) continue;
        bool f1 = (slen == 0);
        bool f2 = (s.size() % blen == 0);//(blen <= slen);
        if (blen <= slen && !f2) {
            s = ns;
            ns = trans(s);
            blen = ns.size() - s.size();
            slen = s.size() - blen;
            assert(blen > slen);
        }
        string init = s;
        s = ns;
        for (int step = 0; step < 10; step++) {
            string ns = trans(s);
            int hisb = ns.size() - s.size();
            int hiss = s.size() - hisb;
            if (f1) {
                assert(hisb == blen);
            }
            else if (f2) {
                assert(hisb == blen);
            }
            else {
//            if (hiss != blen) {
//                cout << init << " GG " << s << " " << ns << " " << hiss << " " << blen << endl;
//            }
                assert(hiss == blen);
            }
            blen = hisb;
            slen = hiss;
//            cout << s << " -> " << ns << endl;
            s = ns;
        }
    }
}
string s;
ll l, r;
vector < int > z_function(string& s) {
    vector < int > z(s.size());
    int l = 0;
    int r = 0;
    for (int i = 1; i < s.size(); i++) {
        if (r < i) {
            l = r = i;
        }
        z[i] = min(r - i, z[i - l]);
        while (i + z[i] < s.size() && s[z[i]] == s[i + z[i]]) z[i]++;
        if (i + z[i] > r) {
            l = i;
            r = i + z[i];
        }
    }
    return z;
}
ll ans[26];
ll len[100];
ll lenB[100];
ll lenS[100];
const ll INF = 1e18 + 2;
const int maxN = 2e5 + 10;
int pref[26][maxN];
int prefS[26][maxN];
ll calcB(ll r, int c, int who);
ll calcS(ll r, int c, int who);
ll calc(ll r, int c, int who);
map < pair < pair < ll, int >, int >, ll > mp, mpB, mpS;
ll calc(ll r, int c, int who) {
    if (who == 0) return pref[c][r];
    if (mp.find({{r, c}, who}) != mp.end()) return mp[{{r, c}, who}];
    ll& d = mp[{{r, c}, who}];
    if (r <= lenB[who]) {
        return d = calc(r, c, who - 1);
    }
    return d = calc(lenB[who] - 1, c, who - 1) + calcB(r - lenB[who], c, who - 1);
}
ll calcB(ll r, int c, int who) {
    if (who == 0) return pref[c][r];
    if (mpB.find({{r, c}, who}) != mpB.end()) return mpB[{{r, c}, who}];
    ll& d = mpB[{{r, c}, who}];
    if (r <= lenB[who]) {
        return d = calcB(r, c, who - 1);
    }
    return d = calcB(lenB[who] - 1, c, who - 1) + calcS(r - lenB[who], c, who - 1);
}
ll calcS(ll r, int c, int who) {
    if (who == 0) return pref[c][r];
    if (mpS.find({{r, c}, who}) != mpS.end()) return mpS[{{r, c}, who}];
    ll& d = mpS[{{r, c}, who}];
    return d = calcB(r, c, who - 1);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> s;
    s = s.substr(0, s.size() / 2);
    cin >> l >> r;
    l--;
    r--;
    auto zz = z_function(s);
    int n = s.size();
    int blen = 0;
    int slen = 0;
    for (int i = 1; i < n; i++) {
        if (zz[i] == n - i) {
            blen = i;
            slen = n - i;
            break;
        }
    }
    if (blen == 0 && slen == 0) {
        blen = n;
    }
    if (n % blen == 0) {
        string f = s.substr(0, blen);
        for (int i = 0; i < f.size(); i++) {
            // blen * k + i >= l
            // blen * k + i <= r
            ll at_least = max(0LL, (l - i + blen - 1) / blen);
            ll at_most = (i > r ? -1 : (r - i) / blen);
            ans[f[i] - 'a'] += at_most - at_least + 1;
        }
        for (int i = 0; i < 26; i++) cout << ans[i] << " ";
    }
    else {
        for (int j = 0; j < 26; j++) {
            for (int i = 0; i < n; i++) {
                pref[j][i] = ((s[i] - 'a') == j);
                if (i) pref[j][i] += pref[j][i - 1];
            }
        }
        string ns = s.substr(0, slen);
        for (int j = 0; j < 26; j++) {
            for (int i = 0; i < ns.size(); i++) {
                prefS[j][i] = ((ns[i] - 'a') == j);
                if (i) prefS[j][i] += prefS[j][i - 1];
            }
        }
        len[0] = s.size();
        lenB[0] = blen;
        lenS[0] = slen;
        int who = -1;
        for (int i = 1; i < 100; i++) {
            if (len[i - 1] - 1 >= r) {
                who = i - 1;
                break;
            }
            lenS[i] = lenB[i - 1];
            lenB[i] = len[i - 1];
            len[i] = lenB[i] + lenS[i];
        }
        assert(who != -1);
        for (int i = 0; i < 26; i++) {
            ans[i] = calc(r, i, who);
            if (l) ans[i] -= calc(l - 1, i, who);
            cout << ans[i] << " ";
        }
    }
    return 0;
}