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: Accepted)

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

/*
 * Z algorithm. Calculates an array a[i] = |lcp(s, s[i...|s|])|,
 * where s is the given string.
 * If n = s.length(), the returned array has length n + 1.
 * E.g. z_algorithm("ababa") = {5, 0, 3, 0, 1, 0}
 * Reference: http://snuke.hatenablog.com/entry/2014/12/03/214243
 * Header Requirement: vector, string
 * Verified by: AtCoder ARC055-C (http://arc055.contest.atcoder.jp/submissions/950597)
 */
std::vector<int> z_algorithm(const std::string &s) {
  int n = s.length();
  std::vector<int> ret(n + 1);
  ret[0] = n;
  for (int i = 1, j = 0; i < n;) {
    for (; i + j < n && s[j] == s[i + j]; ++j) {}
    ret[i] = j;
    if (j == 0) { ++i; continue; }
    int k = 1;
    for (; i + k < n && k + ret[k] < j; ++k) {
      ret[i + k] = ret[k];
    }
    i += k; j -= k;
  }
  return ret;
}


void experiment(string s) {
  REP(i, 0, 10) {
    int n = s.length();
    int v = -1;
    REP(i, (n + 2) / 2, n + 1) {
      if (s.substr(i) == s.substr(0, n - i)) {
	v = i;
	break;
      }
    }
    assert (v >= 0);
    s = s + s.substr(n - v, v - (n - v));
    cerr << "[" << n - v << ", " << v << ")" << endl;
    cerr << "len " << n << " -> " << 2 * v << endl;
  }
}
VL rec(const string &sa, const string &sb, VL &fib, VL &lfib, int v,
       ll x, ll &a, ll &b) {
  if (lfib[v] <= x) {
    a += fib[v];
    b += fib[v + 1];
    return VL(26, 0);
  }
  VL ret(26, 0);
  if (v <= 1) {
    const string &s = v == 0 ? sa : sb;
    REP(i, 0, x) {
      ret[s[i] - 'a'] += 1;
    }
    return ret;
  }
  if (x < lfib[v - 1]) {
    return rec(sa, sb, fib, lfib, v - 1, x, a, b);
  }
  rec(sa, sb, fib, lfib, v - 1, x, a, b); // no return
  return rec(sa, sb, fib, lfib, v - 2, x - lfib[v - 1], a, b);
}


VL calc(const string &s, ll x) {
  VI zarr = z_algorithm(s);
  int n = s.length();
  int k = n; // period
  REP(i, 1, n) {
    if (zarr[i] + i >= n) {
      k = i;
      break;
    }
  }
  if (n % k == 0) {
    VL ret(26, 0);
    REP(i, 0, k) {
      ll dup = x / k + (i < x % k ? 1 : 0);
      ret[s[i] - 'a'] += dup;
    }
    return ret;
  }
  ll a = 0, b = 0;
  VL fib(2, 0), lfib;
  {
    lfib.push_back(k);
    lfib.push_back(n);
    fib[0] = 1;
    while (true) {
      int len = fib.size();
      fib.push_back(fib[len - 2] + fib[len - 1]);
      lfib.push_back(lfib[len - 2] + lfib[len - 1]);
      if (lfib[len] >= x) {
	break;
      }
    }
    fib.push_back(fib[fib.size() - 2] + fib[fib.size() - 1]); // additional elem
  }
  VL ret = rec(s.substr(0, k), s.substr(0, n), fib, lfib, max(lfib.size() - 1, 1UL), x,
	       a, b);
  
  REP(i, 0, k) {
    ret[s[i] - 'a'] += a;
  }
  REP(i, 0, n) {
    ret[s[i] - 'a'] += b;
  }
  return ret;
}

int main(void){
  string s;
  cin >> s;
  ll l, r;
  cin >> l >> r;
  l--;
  {
    VI zarr = z_algorithm(s);
    int n = s.length();
    int v = n;
    REP(i, (s.length() + 2) / 2, s.length() + 1) {
      if (zarr[i] + i >= (int) s.length()) {
	v = i;
	break;
      }
    }
    s = s.substr(0, v);
  }
  VL t1 = calc(s, r);
  if (l >= 1) {
    VL t2 = calc(s, l);
    REP(i, 0, 26) {
      t1[i] -= t2[i];
    }
  }
  REP(i, 0, 26) {
    cout << t1[i] << (i == 25 ? "\n" : " ");
  }
}