You're working on a financial reporting platform. Your task is to calculate earnings obtained during certain time ranges, based on the salary information of different jobs. You'll be given N jobs and Q queries. Each query has a range of dates [L, R] and you must calculate the total earnings obtained in that range among all job salaries.
Each job has the following data:
If there's no end date, it means the job is still ongoing.
If there's an end date, and it falls within a query range, payments made on, or before that end date are included in the total.
If a payment is made a day after the end date, it's not included in the total.
In the first line of input, there will be two integers N, Q $$$(1 \leq N \leq 10^3; ~1 \leq Q \leq 10^5)$$$, representing the number of jobs in the database, and the number of queries, respectively.
The next N lines will contain the data of one job in the format: "Amount StartDate EndDate Type" without the double quotes, where Amount is an integer $$$(1 \leq Amount \leq 10^9)$$$, StartDate and EndDate are in the format: DD/MM/YYYY $$$(01 \leq DD \leq 31; ~01 \leq MM \leq 12; ~2000 \leq YYYY \leq 9999)$$$, Type will be a string representing one of the salary types described before.
The EndDate could be "None", indicating that the job is still ongoing.
Afterward, there are Q lines, each with a query in the format: DD/MM/YYYY DD/MM/YYYY.
For each query, print in a single line the total earnings obtained in that range among all job salaries.
3 2 2 01/10/8467 25/09/9231 monthly 5 13/06/7064 08/01/7520 weekly 4 01/05/6875 None bi-weekly 01/01/2000 31/12/9999 22/07/8260 28/01/9241
437152 112462
A year is a leap year if it satisfies the following conditions: The year is evenly divisible by 4; and, If the year can be evenly divided by 100, it is NOT a leap year, unless; The year is also evenly divisible by 400. Then it is a leap year.
The 1st of January 2000 fell on a Saturday.