IntermediateDates & Time25 points

SLA deadline in business days

A support team in Singapore promises customers a fix within a number of business days. Saturdays, Sundays and public holidays do not count. The ticket system needs the exact deadline date.

Counting works like this: the day the ticket is opened is day 0 (it never counts, even if it is a working day). Walk forward one calendar day at a time starting from the next day. A day counts only if it is Monday to Friday and is not in the holiday list. The deadline is the day on which the count reaches the SLA number. With an SLA of 0 days the deadline is the opening date itself.

Task: read the opening date (YYYY-MM-DD) on line 1, the SLA in business days on line 2, the number of holidays h on line 3, then h lines with holiday dates (some may fall on weekends). Print the deadline as YYYY-MM-DD Weekday with the English weekday name, for example 2026-03-06 Friday.

Sample tests

Input

2026-03-02
4
0

Expected output

2026-03-06 Friday

Input

2026-12-22
5
3
2026-12-25
2026-12-26
2027-01-01

Expected output

2026-12-30 Wednesday

Your answer is also checked against 5 hidden tests.

Need a hint?

date.weekday() returns 0 for Monday up to 6 for Sunday.