This page is still under construction.

Parts of this page are still being built. What you see may change.

A + B = C

Time limit2sMemory limit1024 MB

Summary
Count ordered pairs of n-digit beautiful numbers (no two equal consecutive digits, nonzero leading digit) that sum to a given n-digit number C, modulo 1e9+7.
Level

Medium7 of 10

Topics
Dynamic programming, Math, Implementation, Combinatorics
Solved
No attempts yet

Problem

Practice contests at informatics olympiads often include an "A + B" problem, where the task is to find the sum of given integers AA and BB.

While preparing a city informatics olympiad, the chair of the judging committee decided to make the tests for such a problem himself. He used his own method: first choose the intended correct answers, then construct the input data that matches those answers.

Suppose the chair chose a number CC with nn decimal digits whose first digit is not zero. He now wants to find positive integers AA and BB such that their sum is CC, and each of them also has nn decimal digits with a nonzero first digit. In addition, the chair wants both AA and BB to be beautiful. In his view, a number is beautiful if its decimal representation contains no two equal consecutive digits. For example, 12721272 is beautiful, while 12271227 is not.

Given a positive integer CC, write a program that counts the pairs of beautiful positive integers AA and BB whose sum is CC. Since the count can be large, output the remainder of this count modulo 109+710^9+7.

Input

The input file contains a single positive integer CC. CC does not start with zero. The number of digits of CC is at most 10 00010\,000.

Output

The output file must contain a single integer: the remainder of the number of desired pairs of beautiful numbers AA and BB modulo 109+710^9+7.

Notes

2222 can be written as a sum of two-digit numbers in three ways: 10+1210 + 12, 11+1111 + 11, 12+1012 + 10. The way 11+1111 + 11 does not qualify because 1111 is not beautiful. Therefore the answer for 2222 is 22.

200200 can be written as a sum of three-digit numbers in only one way: 100+100100 + 100. This way does not qualify, so the answer for 200200 is 00.

10001000 cannot be written as a sum of four-digit numbers, so the answer for 10001000 is also 00.

Examples4

  1. Example 1

    Input
    22
    
    Expected output
    2
    
  2. Example 2

    Input
    200
    
    Expected output
    0
    
  3. Example 3

    Input
    1000
    
    Expected output
    0
    
  4. Example 4

    Input
    239
    
    Expected output
    16