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: Wrong Answer)

#include <bits/stdc++.h>

#define mp make_pair
#define pb push_back
#define se second
#define fi first

typedef long long ll;
using namespace std;
const int NUM = 1e5 + 5;
const int mod = 1e9 + 7;
int INF = 2e9;
pair <int ,int> pinf = {INF, INF};

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    string s;
    cin >> s;
    int n = s.length();
    int z[n];
    z[0] = 0;
    int l = 0, r = 0;
    for (int i = 1; i < n; i++){
        z[i] = 0;
        if (r >= i)
            z[i] = min(r - i + 1, z[i - l]);
        while (i + z[i] < n && s[i + z[i]] == s[z[i]])
            z[i]++;
        if (i + z[i] - 1 > r){
            l = i;
            r = i + z[i] - 1;
        }
    }
    int t = -1;
    for (int i = 1; i < n; i++)
        if (z[i] == n - i && n % i == 0){
            t = i;
            break;
        }
    if (t == -1){
        cout << 1 << endl << 1;
        return 0;
    }
    if (t == 1){
        cout << n << endl << 1;
        return 0;
    }
    int ans = 0;
    int p[n], pr[n];
    p[0] = 0;
    pr[0] = 0;
    for (int i = 1; i < n; i++){
        int k = p[i - 1];
        while (k  != -1){
            if (s[k + 1] == s[i + 1])
                break;
            k = (k == 0 ? -1 : p[k - 1]);
        }
        p[i] = k + 1;
    }
    string sr;
    sr = s;
    for (int i = 0; i < n; i++)
        sr[i] = s[n - i - 1];
    for (int i = 1; i < n; i++){
        int k = pr[i - 1];
        while (k  != -1){
            if (sr[k + 1] == sr[i + 1])
                break;
            k = (k == 0 ? -1 : pr[k - 1]);
        }
        pr[i] = k + 1;
    }
    for (int i = 0; i < n - 1; i++)
        if ((2 * p[i] < i + 1 || (i + 1) % (i - p[i] + 1) != 0)  && (2 * pr[n - i - 2] < n - i - 1 || (n - i - 1) % (n - i - 1 - pr[n - i - 2])))
            ans++;
    cout << 2 << endl << ans;
    return 0;
}