Problem:
Score : 900 points

Problem Statement

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

Let w be a string of length at least 1.
For a sequence F=(\,f_1,\,f_2,\,...,\,f_m) consisting of m elements,
we will call F a good representation of w, if the following conditions are both satisfied:

For any i \, (1 \leq i \leq m), f_i is a good string.

The string obtained by concatenating f_1,\,f_2,\,...,\,f_m in this order, is w.

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

(aabb)

(a,abb)

(aab,b)

(a,ab,b)

(a,a,b,b)

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

You are given a string w. Find the following:

the number of elements of a best representation of w

the number of the best representations of w, modulo 1000000007 \, (=10^9+7)

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

Constraints

1 \leq |w| \leq 500000 \, (=5 \times 10^5)

w consists of lowercase letters (a-z).

Partial Score

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

Input

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

w

Output

Print 2 lines.

In the first line, print the number of elements of a best representation of w.

In the second line, print the number of the best representations of w, modulo 1000000007.

Sample Input 1

aab

Sample Output 1

1
1

Sample Input 2

bcbc

Sample Output 2

2
3

In this case, there are 3 best representations of 2 elements:

(b,cbc)

(bc,bc)

(bcb,c)

Sample Input 3

ddd

Sample Output 3

3
1

Solution in C++14 (GCC 5.4.1) (judge verdict: Time Limit Exceeded)

 #include <bits/stdc++.h>
using namespace std;

char w[500005];

const long long MOD = 1e9+7;

bool isGood(int s, int e){
    int M = (e-s+1);
    //printf("M=%d\n", M);
    for(int k = 1; k < M; k ++){
        bool valid = true;
        if(M%k == 0){
            // repeating string length
            for(int i = 0; i < k; i ++){
                // index of repeating string
                for(int j = s+i; j <= e; j += k){
                    if(w[j] != w[s+i]){
                        valid = false;
                        break;
                    }
                }
                if(!valid){
                    break;
                }
            }
            if(valid){
                // There is a repeating string
                //printf("Repeating length of %d exists\n", k);
                return false;
            }
        }
    }
    return true;
}

bool repeat1[500005];
bool repeatPrefix[500005]; // first n characters, where n is index of array
bool repeatSuffix[500005]; // last n characters, where n is suffix of array

int N;

void checkPrefix(int k){
    // k is the repeat string length
    bool possible = true;
    int p = 0; // number of characters processed
    for(int i = 1; (i+1)*k <= N; i ++){
        p += k;
        for(int j = 0; j < k; j ++){
            if(w[p+j] != w[j]){
                return;
            }
        }
        // check passed
        repeat1[p+k] = true; // the string consisting of the first p+k characters is bad
    }
}

int main(){
    scanf(" %s", w);

    N = strlen(w);
    //printf("N=%d\n", N);

    // Editorial says the length of best representation is either 1, 2 or N

    // If and only if all characters are the same, the first answer is N
    bool answerIsN = true;
    for(int i = 0; i < N; i ++){
        if(w[i] != w[0]){
            answerIsN = false;
            break;
        }
    }

    // If first answer is N, there is only 1 partition
    if(answerIsN){
        printf("%d\n1\n", N);
        return 0;
    }

    // To check if answer is 1, the whole string must be good
    bool stringIsGood = isGood(0, N-1);

    // If first answer is N, there is only 1 partition
    if(stringIsGood){
        printf("1\n1\n");
        return 0;
    }

    // Otherwise, the string is bad, with the smallest repeating length at least 2.
    // If we take the first character, and the remaining string (without the first character),
    // this forms a good representation since the existing concatenation will be destroyed.
    printf("2\n");

    // There are at most N ways to partition, hence the mod step is essentially useless.
    // One can check every single possible prefix and suffix and check whether the substring is good.
    // This yields a slightly worse than quadratic solution.

    /*int ans = 0;
    for(int i = 1; i < N; i ++){
        ans += (isGood(0, i-1) && isGood(i, N-1));
    }

    printf("%d\n", ans);*/

    memset(repeat1, false, sizeof(repeat1));
    for(int k = 1; k < N; k ++){
        if(!repeat1[k]){
            checkPrefix(k);
        }
    }

    for(int i = 1; i <= N; i ++){
        repeatPrefix[i] = repeat1[i];
        //printf("repeatPrefix[%d]: %d\n", i, repeat1[i]);
    }

    reverse(w, w+N);
    memset(repeat1, false, sizeof(repeat1));
    for(int k = 1; k < N; k ++){
        if(!repeat1[k]){
            checkPrefix(k);
        }
    }

    //printf("%s\n", w);
    for(int i = 1; i <= N; i ++){
        repeatSuffix[i] = repeat1[i];
        //printf("repeatSuffix[%d]: %d\n", i, repeat1[i]);
    }

    int ans2 = 0;
    for(int i = 1; i < N; i ++){
        ans2 += !repeatPrefix[i] && !repeatSuffix[N-i];
    }

    printf("%d\n", ans2);
    return 0;
}