Anne's Diary

TarifEzaz Criterion 2021 Round 13
Limits 1s, 512 MB

On 12 June 1942, Anne received a diary as a gift. She started writing on it. Later, her diary had become a part of history as it is considered an important document of World War II.

In order to make Anne’s work available online, you will have to write a program that will answer some queries. Initially, you will be given the list of days when Anne wrote on her diary. Based on this given list, you will have to answer some queries. In each query, you will be given two dates and you will have to answer how many days Anne had written in her diary between these two given dates.

Input

The first line of the input will contain an integer NN (1N2001 \leq N \leq 200), the total number of days Anne had written in her diary. In the next NN lines, there will be a day in the format:

Month Day, Year

The values of the Month will be from January, February, March, April, May, June, July, August, September, October, November and December.

The next line will contain an integer QQ (1Q400001 \leq Q \leq 40000), the total number of queries.

Each query will have two valid dates each on a line by itself. The first date will be earlier or equal to the second date.

The value of all the dates can be any valid date from June 12, 1942 to December 31, 1944.

Output

For each query, output one line, the number of days Anne has written in her diary within the given two dates.

Sample

InputOutput
2
June 12, 1942
June 21, 1942
1
June 15, 1942
June 22, 1942
1

Submit

Login to submit.

Statistics

72% Solution Ratio
BigBagEarliest, Apr '21
TurinhstuFastest, 0.0s
BigBagLightest, 131 kB
anonyo.akandShortest, 291B
Toph uses cookies. By continuing you agree to our Cookie Policy.