You are given a string S\[1…n]. We denote its substrings as S\[l…r], and when l>r, such substring is defined to be an empty string. Let f(i, j) = \max \left\\{k\~|\~0 \leq k \leq j-i,\~S\[i \ldots i+k-1] = S\[j-k+1 \ldots j]\right\\} \text{.}
Output ∑_1≤i<j≤nf(i,j).
The string S is generated in the following way. The values n and seed are the parameters of the generator.
long long seed;
for (int i = 1; i <= n; i++) {
seed = (seed * 13331 + 23333) % 1000000007;
s[i] = 'a' + (seed & 1);
}
The first line contains two integers: n and seed (1≤n≤106, 0≤seed≤109+6).
Output the answer.