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)

// see https://github.com/LumaKernel/vimfiles/tree/master/snippets/cp-cpp/temp.snip
const bool DEBUG = 0;
/// --- .lumrc Template {{{ ///
#include <iostream>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>
#include <cassert>
#include <functional>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = tuple<ll, ll>;
using P3 = tuple<ll, ll, ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VP = vector<P>;
using VS = vector<string>;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define FOR(i,a,b) for(int i=int(a);i<int(b);++i)
#define FORI(i,a,b) for(int i=int(a);i<=int(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REPI(i,n) FORI(i,0,n)
#define RFOR(i,a,b) for(int i=int(b)-1;i>=int(a);--i)
#define RFORI(i,a,b) for(int i=int(b);i>=int(a);--i)
#define RREP(i,n) RFOR(i,0,n)
#define RREPI(i,n) RFORI(i,0,n)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique(ALL(a)),(a).end())
#define PB push_back
#define EACH(i,c) REP(i,(c).size())
#define REACH(i,c) RREP(i,(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))

#define BR cout<<"\n";

#define dump(x) if(DEBUG) cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)<<"\n";
#define dump2(x,y) if(DEBUG) cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)\
  <<" , "<<#y<<"="<<(y)<<"\n";
#define dump3(x,y,z) if(DEBUG)cerr<<"["<<__LINE__<<"] "<<#x<<"="<<(x)\
  <<" , "<<#y<<"="<<(y)\
<<" , "<<#z<<"="<<(z)<<"\n";

#define SAY(x) if(DEBUG) cerr<<"["<<__LINE__<< "] "<<(x)<<"\n";

#define YES(x) cout<<((x)?"YES":"NO")<<"\n";
#define Yes(x) cout<<((x)?"Yes":"No")<<"\n";
#define yes(x) cout<<((x)?"yes":"no")<<"\n";

inline int omajinai_int_in(){omajinai;int n;cin>>n;return n;}
inline ll omajinai_ll_in(){omajinai;ll n;cin>>n;return n;}
inline string omajinai_string_in(){omajinai;string n;cin>>n;return n;}
inline int int_in(){int n;cin>>n;return n;}
inline ll ll_in(){ll n;cin>>n;return n;}
inline string string_in(){string n;cin>>n;return n;}
#define oini omajinai_int_in()
#define oinl omajinai_ll_in()
#define oins omajinai_string_in()
#define ini int_in()
#define inl ll_in()
#define ins string_in()

#define isInside(y,x) (0<=(y)&&(y)<h&&0<=(x)&&(x)<w)

#define fi(x) (get<0>(x))
#define se(x) (get<1>(x))
#define th(x) (get<2>(x))
#define fo(x) (get<3>(x))
#define fif(x) (get<4>(x))

template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; EACH(i, v) o << v[i] << (i != v.size()-1 ? ", " : ""); o << "]";  return o; }

template <typename T> inline void smax(T &a, T b) { a = a > b ? a : b; }
template <typename T> inline void smin(T &a, T b) { a = a < b ? a : b; }

/// }}}--- ///

constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr int MOD = 1e9+7;

string s = ins;
int n = s.size() / 2;

ll ans;
int k = 0;
const int N = 1e5 + 10;
array<ll, 27> cnt[N];
const int MAXS = 300;
array<ll, 27> SS[300];
int SSLength;

array<ll, 27> add(array<ll, 27> a, array<ll, 27> b, bool minus = false) {
  REP(i, 27) {
    a[i] += b[i] * (minus ? -1 : 1);
  }
  return a;
}

array<ll, 27> solve(ll x) {
  array<ll,27> res;
  if(x <= n) {
    return cnt[x];
  }
  array<ll,27> search;
  search[0] = x;
  search[1] = LINF;

  int p = lower_bound(SS, SS + SSLength, search) - SS;
  p--;
  assert(p>=0);
  // dump2(x, SS[p][0]);
  // dump2(p, SSLength);
  return add(SS[p], solve(x - SS[p][0]));
}

ull upow(ull a, ull b) {
  ull res = 1;
  while(b) {
    if(b&1) res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}

int main() {
  // ローリングハッシュ法で前半k文字と後半k文字で一致する
  // ような最大のkを求める
  dump(2);
  ull backHash = 0;
  ull forwardHash = 0;
  REP(i, n-1) {
    backHash *= 26;
    backHash += s[i]-'a';
    forwardHash += upow(26, i) * (s[n-1-i]-'a');
    if(backHash == forwardHash) k = i + 1;
  }
  dump(k);
  
  dump(3);
  ll l=inl, r=inl;
  dump2(l, s);
  
  FOR(i, 1, n+1) {
    cnt[i] = cnt[i-1];
    cnt[i][0]++;
    cnt[i][1+s[i-1]-'a']++;
  }
  REP(i, n-k) {
    SS[0][0]++;
    SS[0][1+s[i]-'a']++;
  }
  FOR(i, n-k, n) {
    SS[1][0]++;
    SS[1][1+s[i]-'a']++;
  }
  dump(4);
  SSLength = MAXS;
  FOR(i, 2, MAXS) {
    REP(j, i-2+1) {
      SS[i] = add(SS[i], SS[j]);
      if(SS[i][0]>LINF) {
        SSLength = i;
        break;
      }
    }
    if(SSLength!=MAXS) break;
  }
  
  dump(1);
  dump(r);
  auto ans = add(solve(r), solve(l-1), true);
  

  dump(7);
  REP(i, 26) {
    cout << ans[i+1] << (i!=int(ans.size()-1)?" ":"\n");
  }
}

//