PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000248. Mật khẩu có tổng chữ số nguyên tố (Primewords Revisit)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Mật khẩu có tổng chữ số nguyên tố (Primewords Revisit)

Primewords Revisit

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

A password consists of exactly nn decimal digits, each independently chosen from 00 through 99, including the first digit. It is called a prime-word if the sum of every four consecutive digits is prime.

For instance, the five-digit password 53419 is valid: 5+3+4+1=135+3+4+1=13 and 3+4+1+9=173+4+1+9=17 are prime.

Count all valid passwords of length nn modulo 109+710^9+7. When n<4n<4, there are no blocks of four consecutive digits, and every such password is valid.

Input

The only line contains integer nn, the password length.

Output

Print a single integer: the number of length-nn passwords whose every block of four consecutive digits has prime sum, modulo 109+710^9+7.

Subtasks

  • Subtask 1 (20 points): 1≤n≤201\le n\le20; each digit is in [0,9][0,9], including the leading digit.
  • Subtask 2 (30 points): 1≤n≤20001\le n\le2000; each digit is in [0,9][0,9], including the leading digit.
  • Subtask 3 (50 points): 1≤n≤5⋅1041\le n\le5\cdot10^4; each digit is in [0,9][0,9], including the leading digit.

Examples

Input

4

Output

3010

Explanation

For n=4n=4, there is only one block of four consecutive digits. The valid prime sums from 00 through 3636 are 2,3,5,7,11,13,17,19,23,29,312,3,5,7,11,13,17,19,23,29,31. The counts of four-digit tuples achieving those sums are respectively 10,20,56,120,348,480,660,660,480,120,5610,20,56,120,348,480,660,660,480,120,56. Summing gives 30103010. Leading zeros are allowed, so a password such as 0002 is counted.