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, . . .}.m ∈ {1, . . . , 12- If
m ∈ {1, 3, 5, 7, 8, 10, 12}, thend ∈ {1, . . . , 31}. - If
m ∈ {4, 6, 9, 11}, thend ∈ {1, . . . , 30}. - If
m = 2andyis either a not a multiple of4, or both a multiple of100and not a multiple of400, thend ∈ {1, . . . , 28}. - If
m = 2andyis a multiple of4, and either not a multiple of100or a multiple of400, thend ∈ {1, . . . , 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 , where . She now wants to ask: how many sequences of indices exist such that are a valid date?
Input data
The first line of the input contains the integer n. The second line contains the symbols , not separated by spaces.
Output data
Output the answer modulo .
Restrictions
1 ≤ n ≤ 100 000.
Subtask 1 (12 points)
n ≤ 15
Subtask 2 (7 points)
n ≤ 1 000
Subtask 3 (8 points)
Subtask 4 (7 points)
- or
Subtask 5 (8 points)
Subtask 6 (9 points)
n ≤ 1000
Subtask 7 (11 points)
Subtask 8 (38 points)
- No further restrictions.
Examples
stdin
8
55/55/55
stdout
12
Explanation
5/5/5 appears 8 times within the input, and 55/5/5 appears 4 times.
stdin
7
44/2/29
stdout
9
Explanation
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.
stdin
8
11/11/31
stdout
24
Explanation
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.
stdin
22
11/2/43432/534/123/234
stdout
66078