Date
시간 제한1초메모리 제한1024 MB
숫자와 슬래시로 이루어진 문자열에서 앞에 0이 없는 y/m/d 형태의 올바른 날짜가 되는 부분수열의 개수를 10^9+7로 나눈 나머지로 구한다.
문제
Fujiwara-san loves dates! She calls a date a string of form where , and are positive integers without leading zeroes that represent a calendar date ( is the day, is the month, is the year). The precise rules for a valid date is the following:
- .
- .
- If , then .
- If , then .
- If and is either a not a multiple of , or both a multiple of and not a multiple of , then .
- If and is a multiple of , and either not a multiple of or a multiple of , then .
For example, , and are valid dates; whereas , and 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?
입력
The first line of the input contains the integer . The second line contains the symbols , not separated by spaces.
출력
Output the answer modulo .
제한
- .