LUCC Party Check-in

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Time Limit: 1.0 s

Memory Limit: 512.0 MB

Description

The Leading University Computer Club (LUCC) is hosting an exclusive party for its top performers. Security is tight, and there's a bouncer at the door with a digital guest list. Your job is to create the software for the bouncer's check-in device.
The check-in logic must follow these three rules:

  1. When a person arrives, if their name is on the guest list and they have not yet entered, they are allowed in. The system should respond: Welcome!
  2. If their name is not on the guest list, they are denied entry. The system should respond: Sorry, not on the list.
  3. If their name is on the guest list but they have already entered, they are reminded of this. The system should respond: Already inside!
    You will be given the initial guest list and the sequence of people arriving at the door. You must process each arrival and output the correct response.

Input

The first line contains a single integer \(M (1 <= M <= 100)\), the number of guests on the invitation list.
● The next M lines each contain a single string, the name of an invited guest.
● The next line contains a single integer \(N (1 <= M <= 1000)\), the number of people who will arrive at the party.
● The next N lines each contain a single string, the name of a person arriving at the door, in the order they arrive.
● All names consist only of lowercase English letters and have a length between 1 and 20.

Output

For each of the N arrivals, print the system's response on a new line.

Sample

Input Output
3
alice
bob
charlie
5
bob
dave
alice
eve
bob
Welcome!
Sorry, not on the list.
Welcome!
Sorry, not on the list.
Already inside!

Testing - Intra LU Programming contest 25

Not Attended
Status
Done
Rule
ACM/ICPC
Problem
9
Start at
2025-08-29 17:15
End at
2025-09-04 23:15
Duration
150.0 hour(s)
Host
Partic.
5