atcoder#ARC060D. [ARC060F] 最良表現

[ARC060F] 最良表現

Score : 900900 points

Problem Statement

Let xx be a string of length at least 11. We will call xx a good string, if for any string yy and any integer k(k2)k (k \geq 2), the string obtained by concatenating kk copies of yy is different from xx. For example, a, bbc and cdcdc are good strings, while aa, bbbb and cdcdcd are not.

Let ww be a string of length at least 11. For a sequence F=(f1,f2,...,fm)F=(\,f_1,\,f_2,\,...,\,f_m) consisting of mm elements, we will call FF a good representation of ww, if the following conditions are both satisfied:

  • For any i(1im)i \, (1 \leq i \leq m), fif_i is a good string.
  • The string obtained by concatenating f1,f2,...,fmf_1,\,f_2,\,...,\,f_m in this order, is ww.

For example, when w=w=aabb, there are five good representations of ww:

  • ((aabb))
  • ((a,,abb))
  • ((aab,,b))
  • ((a,,ab,,b))
  • ((a,,a,,b,,b))

Among the good representations of ww, the ones with the smallest number of elements are called the best representations of ww. For example, there are only one best representation of w=w=aabb: ((aabb)).

You are given a string ww. Find the following:

  • the number of elements of a best representation of ww
  • the number of the best representations of ww, modulo 1000000007(=109+7)1000000007 \, (=10^9+7)

(It is guaranteed that a good representation of ww always exists.)

Constraints

  • 1w500000(=5×105)1 \leq |w| \leq 500000 \, (=5 \times 10^5)
  • ww consists of lowercase letters (a-z).

Partial Score

  • 400400 points will be awarded for passing the test set satisfying 1w40001 \leq |w| \leq 4000.

Input

The input is given from Standard Input in the following format:

ww

Output

Print 22 lines.

  • In the first line, print the number of elements of a best representation of ww.
  • In the second line, print the number of the best representations of ww, modulo 10000000071000000007.
aab
1
1
bcbc
2
3
  • In this case, there are 33 best representations of 22 elements:- ((b,,cbc))
    • ((bc,,bc))
    • ((bcb,,c))
  • ((b,,cbc))
  • ((bc,,bc))
  • ((bcb,,c))
ddd
3
1