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>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
seed_seq seq {
    (uint64_t) chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count(),
    (uint64_t) __builtin_ia32_rdtsc(),
    (uint64_t) (uintptr_t) make_unique<char>().get()
};
mt19937 rng(seq);
struct hash_struct {
    struct hash_parameters {
        const uint64_t M, X;
        const function<uint64_t(uint64_t, uint64_t)> add, sub, mul;
        vector<uint64_t> mpow;
        void resize(int n) {
            if(mpow.size() < n) {
                mpow.resize(n);
                for(int i = 0; i < n; i++) {
                    mpow[i] = i ? mul(mpow[i - 1], X) : 1;
                }
            }
        }
    };
    hash_parameters& h;
    vector<uint64_t> rolling;
    hash_struct(hash_parameters& h, const string& s)
    : h(h), rolling(s.size() + 1) {
        h.resize(s.size() + 1);
        for(int i = int(s.size()) - 1; i >= 0; i--) {
            rolling[i] = h.add(h.mul(rolling[i + 1], h.X), s[i]);
        }
    }
    uint64_t query(int L, int R) {
        assert(L <= R);
        return h.sub(rolling[L], h.mul(rolling[R], h.mpow[R - L]));
    }
};
hash_struct hash1(const string& s) {
    constexpr uint64_t M = (1ull << 61) - 1;
    static uint64_t X = uniform_int_distribution<uint64_t>(256, M - 1)(rng);
    static constexpr auto add = [](uint64_t a, uint64_t b) { return a + b >= M ? a + b - M : a + b; };
    static constexpr auto sub = [](uint64_t a, uint64_t b) { return add(a, M - b); };
    static constexpr auto mul = [](uint64_t a, uint64_t b) {
        uint64_t l1 = (uint32_t)a, h1 = a >> 32, l2 = (uint32_t)b, h2 = b >> 32;
        uint64_t l = l1 * l2, m = l1 * h2 + l2 * h1, h = h1 * h2;
        uint64_t ret = (l & M) + (l >> 61) + (h << 3) + (m >> 29) + (m << 35 >> 3) + 1;
        ret = (ret & M) + (ret >> 61);
        ret = (ret & M) + (ret >> 61);
        return ret - 1;
    };
    static hash_struct::hash_parameters h = {M, X, add, sub, mul};
    return hash_struct(h, s);
}
hash_struct hash2(const string& s) {
    constexpr uint64_t M = (1ull << 31) - 1;
    static uint64_t X = uniform_int_distribution<uint64_t>(256, M - 1)(rng);
    static constexpr auto add = [](uint64_t a, uint64_t b) { return a + b >= M ? a + b - M : a + b; };
    static constexpr auto sub = [](uint64_t a, uint64_t b) { return add(a, M - b); };
    static constexpr auto mul = [](uint64_t a, uint64_t b) {
        uint64_t ret = a * b + 1;
        ret = (ret & M) + (ret >> 31);
        ret = (ret & M) + (ret >> 31);
        return ret - 1;
    };
    static hash_struct::hash_parameters h = {M, X, add, sub, mul};
    return hash_struct(h, s);
}
int find_period(string& s, int L, int R) {
    static auto h1 = hash1(s), h2 = hash2(s);
    int len = R - L;
    for(int k = 1; k < len; k++) {
        if(len % k == 0) {
            bool can = true;
            for(int i = k; i < len and can; i += k) {
                can &= h1.query(L, L + k) == h1.query(L + i, L + i + k)
                    and h2.query(L, L + k) == h2.query(L + i, L + i + k);
            }
            if(can) {
                return k;
            }
        }
    }
    return len;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int p = find_period(s, 0, s.size());
    if(p == s.size()) {
        cout << 1 << endl;
        cout << 1 << endl;
    } else if(p == 1) {
        cout << s.size() << endl;
        cout << 1 << endl;
    } else {
        cout << 2 << endl;
        int ans = 0;
        for(int i = 1; i < s.size(); i++) {
            ans += find_period(s, 0, i) == i and find_period(s, i, s.size()) == s.size() - i;
        }
        cout << ans << endl;
    }
    return 0;
}