시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB255420.000%

문제

Fujiwara-san loves dates! She calls a date a string of form $y/m/d$ where $d$, $m$ and $y$ are positive integers without leading zeroes that represent a calendar date ($d$ is the day, $m$ is the month, $y$ is the year). The precise rules for a valid date is the following:

  • $y ∈ \{1, 2, \dots\}$.
  • $m ∈ \{1, \dots , 12\}$.
  • If $m ∈ \{1, 3, 5, 7, 8, 10, 12\}$, then $d ∈ \{1, \dots , 31\}$.
  • If $m ∈ \{4, 6, 9, 11\}$, then $d ∈ \{1, \dots , 30\}$.
  • If $m = 2$ and $y$ is either a not a multiple of $4$, or both a multiple of $100$ and not a multiple of $400$, then $d ∈ \{1, \dots , 28\}$.
  • If $m = 2$ and $y$ is a multiple of $4$, and either not a multiple of $100$ or a multiple of $400$, then $d ∈ \{1, \dots , 29\}$.

For example, $2022/2/14$, $2024/2/29$ and $2000/2/29$ are valid dates; whereas $2022/02/14$, $2022/2/29$ and $2100/2/29$ are not valid dates.

Fujiwara-san has recently received a sequence of symbols $s_1, \dots , s_n$, where $s_i ∈ \{0, 1, \dots , 9, /\}$. She now wants to ask: how many sequences of indices $1 ≤ i_1 < \dots < i_k ≤ n$ exist such that $s_{i_1} , \dots , s_{i_k}$ are a valid date?

입력

The first line of the input contains the integer $n$. The second line contains the symbols $s_1, \dots , s_n$, not separated by spaces.

출력

Output the answer modulo $10^9 + 7$.

제한

  • $1 ≤ n ≤ 100\,000$.

서브태스크

번호배점제한
112

$n ≤ 15$

27

$n ≤ 1\,000$, $s_i ∈ \{5, /\}$

38

$s_i ∈ \{5, /\}$

47

$s_i = /$ or $s_i ≥ 5$

58

$s_i \ne 0$, $s_i \ne 2$

69

$n ≤ 1000$, $s_i \ne 2$

711

$s_i \ne 2$

838

No further restrictions.

예제 입력 1

8
55/55/55

예제 출력 1

12

$5/5/5$ appears $8$ times within the input, and $55/5/5$ appears $4$ times.

예제 입력 2

7
44/2/29

예제 출력 2

9

$4/2/2$, $4/2/9$, $4/2/29$ all appear $2$ times, and $44/2/2$, $44/2/9$, $44/2/29$ all appear once.

예제 입력 3

8
11/11/31

예제 출력 3

24

$1/1/1$, $1/1/3$, $1/1/31$ appear $4$ times each, $1/11/1$, $1/11/3$, $11/1/1$, $11/1/3$, $11/1/31$ appear $2$ times each, and $11/11/1$, $11/11/3$ appear once.

예제 입력 4

22
11/2/43432/534/123/234

예제 출력 4

66078

채점 및 기타 정보

  • 예제는 채점하지 않는다.