All for Nine and Nine for All
Difficulty: Hard

<img src="https://s3.amazonaws.com/hr-challenge-images/3090/1472582116-bf126e51f6-lunctimesurprise.jpg" title="lunctimesurprise.jpg" />

Everyone's favorite noontime show, _Lunchtime Surprise_, launched a new game recently. They called it: _All for Nine and Nine for All_. There would be $N$ boxes, each containing a single digit from `0` to `9`, lined up and the team of nine contestants would have to decide which boxes to open. After opening the boxes, we can read the resulting number from left to right. If this number is positive and can be divided evenly by 9, then they either win that amount of money (in pesos) or 99999 pesos, whichever is lower. However, if the resulting number has leading zeros (e.g. reading the number from left to right results in `00144`), it is considered an invalid number. Hence, the contetants lose in that case.

After a few episodes, they realized that winning was relatively easy. The researchers needed to revise the rules. In their proposed set of rules, contestants must choose a set of _consecutive boxes_ instead of any set of boxes. All the other original rules apply.

Now, the researchers needed some kind of report that shows that there are less ways to win using their proposed rules, as compared to the original. They shall give examples of box arrangements and show how many ways one can win using the original set of rules, and how many ways to win using their proposed rules.

**Input Format**  
The first line contains a single integer, which is $N$.
The second line contains a string of length $N$, consisting of digits `0`-`9`, describing a box arrangement.

**Output Format**  
Output exactly two lines.
The first line should contain an integer indicating the number of ways (modulo $10^9$) one can win using the original set of rules.
The second line should contain an integer indicating the number of ways (modulo $10^9$) one can win using the proposed set of rules.


**Constraints**  
$1 \le N \le 10^6$  

**Sample Input**  

    5
    33931

**Sample Output**  

    3
    2

**Explanation**  
For the original set of rules, there are three ways.

1. The contestants can open boxes $1$, $2$ and $4$. Reading it from left to right, our contestants go home with 333 pesos!

2. The contestants can open box $3$ only. Reading it from left to right, our contestants go home with 9 pesos!

3. The contestants can open boxes $1$, $2$, $3$ and $4$. Reading it from left to right, our contestants go home with 3393 pesos!

For the second method, there are two ways. These two ways are the cases illustrated as #2 and #3 above.

Input Format:

Output Format:

Sample Input:

Sample Output:

Python 3 starter code:


Reference solution (C++):
    #include <stdio.h>
    #include <stdlib.h>
    #define ll long long
    #define mod 1000000000
    #define alok(n,t) ((t*)malloc((n)*sizeof(t)))

    char S[1111111];
    int *F = alok(9, int);
    int *G = alok(9, int);
    int *H = alok(9, int);
    int *nF = alok(9, int);
    int *nG = alok(9, int);
    int *nH = alok(9, int);

    int main() {
        int N;
        scanf("%d%s", &N, S);
        for (int i = 0; i < N; i++) S[i] -= '0';
        ll ans1 = 0, ans2 = 0;
        for (int i = N; i >= 0; i--) {
            for (int m = 0; m < 9; m++) {
                if (i == N) {
                    nF[m] = 0;
                    nG[m] = 0;
                    nH[m] = 0;
                } else {
                    nF[m] = (F[(m-S[i]+9)%9] + (S[i] % 9 == m)) % mod;
                    nG[m] = (H[(m-S[i]+9)%9] + (S[i] % 9 == m)) % mod;
                    nH[m] = (nG[m] + H[m]) % mod;
                }
            }
            int *t;
            t = nF; nF = F; F = t;
            t = nG; nG = G; G = t;
            t = nH; nH = H; H = t;
            if (S[i] != 0) {
                ans1 = (ans1 + G[0]) % mod;
                ans2 = (ans2 + F[0]) % mod;
            }
        }
        printf("%lld\n%lld\n", ans1, ans2);
    }