Date

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

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

  • y1,2,y ∈ \\{1, 2, \dots\\}.
  • m1,,12m ∈ \\{1, \dots , 12\\}.
  • If m1,3,5,7,8,10,12m ∈ \\{1, 3, 5, 7, 8, 10, 12\\}, then d1,,31d ∈ \\{1, \dots , 31\\}.
  • If m4,6,9,11m ∈ \\{4, 6, 9, 11\\}, then d1,,30d ∈ \\{1, \dots , 30\\}.
  • If m=2m = 2 and yy is either a not a multiple of 44, or both a multiple of 100100 and not a multiple of 400400, then d1,,28d ∈ \\{1, \dots , 28\\}.
  • If m=2m = 2 and yy is a multiple of 44, and either not a multiple of 100100 or a multiple of 400400, then d1,,29d ∈ \\{1, \dots , 29\\}.

For example, 2022/2/142022/2/14, 2024/2/292024/2/29 and 2000/2/292000/2/29 are valid dates; whereas 2022/02/142022/02/14, 2022/2/292022/2/29 and 2100/2/292100/2/29 are not valid dates.

Fujiwara-san has recently received a sequence of symbols s_1,,s_ns\_1, \dots , s\_n, where s_i0,1,,9,/s\_i ∈ \\{0, 1, \dots , 9, /\\}. She now wants to ask: how many sequences of indices 1i_1<<i_kn1 ≤ i\_1 < \dots < i\_k ≤ n exist such that s_i_1,,s_i_ks\_{i\_1} , \dots , s\_{i\_k} are a valid date?

입력

The first line of the input contains the integer nn. The second line contains the symbols s_1,,s_ns\_1, \dots , s\_n, not separated by spaces.

출력

Output the answer modulo 109+710^9 + 7.

제한

  • 1n100,0001 ≤ n ≤ 100\\,000.