SAC '22 Code Challenge 2 P1 - Calendar Management

View as PDF

Submit solution

Points: 5
Time limit: 1.0s
Memory limit: 256M

Problem type

Since Zain is a busy student, he keeps a calendar with all his important upcoming assessments. However, Zain keeps forgetting to check his calendar and occasionally checks it!

Given this information, Zain wants you to tell him the assessments he has today or has had since his last check (if it is his first check, assume it started before the first assessment in his calendar).

Currently, Zain has A upcoming assessments throughout the month, each having a day they are completed, D_i, and name.

Zain will check his calendar a total of K times and tell you the current day, C_i.

Can you help him?

Input Specification

The first line will contain A (1 \le A \le 100) and K (1 \le K \le 30), the number of assessments in the month and the number of checks.

The next A lines will contain the day, D_i (1 \le D_i \le 30), and name of the i^\text{th} assessment.

The name of an assessment will be at most 15 characters long and only contain lowercase letters, uppercase letters, and _.

The next K lines will contain a day Zain checks the calendar, C_i (1 \le C_i \le 30, C_{i - 1} < C_i for all i > 1).

Note: The assessments for a given check should be output in the order given in the input.

Output Specification

For each check, output all the assessments between the last check and the current day on different lines (including the current day).

Sample Input

3 5
3 Physics
6 English
5 Rock_throwing

Sample Output


Explanation for Sample Output

The first check has no assessments, the second check has Physics, the third check has English and Rock_throwing (note the order they were output), and every other check has no assessments.


There are no comments at the moment.