Abigail and Madeline are now in their second year of elementary school and have been developing their mathematical knowledge. They are pretty good at counting, but still struggle with writing numbers 1. They know the digits 1, 2, 3, and 4 pretty well. Unfortunately, they sometimes don't realize 4 is different from 1, so they think that 4 is just another way to write 1.2

To practice their number writing, Abigail and Madeline play a little game where they makes numbers with the four digits they know and sums the values. For example:

132     = 1 + 3 + 2 = 6
112314  = 1 + 1 + 2 + 3 + 1 + 1 = 9     # Remember that 4 = 1

Abigail and Madeline now want to know how many such numbers can they create whose sum is a number n. For n = 2, they can make 5 numbers:

11, 14, 41, 44, 2

For n > 2, they are having trouble forming the numbers, so Abigail and Madeline need your help.

Input

The input will consist of an arbitrary number of integers n such that 1 <= n <= 1000.

Example Input

2
3

Output

For each integer read, output an single integer stating how many numbers Abigail and Madeline can make such that the sum of the digits is equal to n.

Example Output

5
13

Note: The counts will get very large and will require BigNum support which C++ does not have built-in. Because of this, it is recommended that you use Python to implement your solution.

Programming Challanges

This is based on 10198 - Counting problem on the UVa Online Judge.

Algorithmic Complexity

For each input test case, your solution should have the following targets:

Time Complexity O(N), where N is the target number.
Space Complexity O(N), where N is the target number.

Your solution may be below the targets, but it should not exceed them.

Submission

To submit your work, follow the same procedure you used for Reading 01:

$ cd path/to/cse-34872-su21-assignments     # Go to assignments repository
$ git checkout master                       # Make sure we are on master
$ git pull --rebase                         # Pull any changes from GitHub

$ git checkout -b challenge10               # Create and checkout challenge10 branch

$ $EDITOR challenge10/program.py            # Edit your code

$ git add challenge10/program.py            # Stage your changes
$ git commit -m "challenge10: done"         # Commit your changes

$ git push -u origin challenge10            # Send changes to GitHub

To check your code, you can use the .scripts/check.py script or curl:

$ .scripts/check.py
Checking challenge10 program.py ...
  Result Success
    Time 0.03
   Score 6.00 / 6.00

$ curl -F source=@challenge10/program.py https://dredd.h4x0r.space/code/cse-34872-su21/challenge10
{"result": "Success", "score": 6, "time": 0.032058000564575195, "value": 6, "status": 0}

Pull Request

Once you have commited your work and pushed it to GitHub, remember to create a pull request and assign it to the teaching assistant.


  1. Like father, like daughters. 

  2. Not true, but I needed a story.