Under construction

Still being built. Things may change

E-Mail Snooping

Time limit1sMemory limit128 MB

Summary
Count how many listed keywords appear as whole words in the email and raise an alarm when the count reaches the threshold.
Level

Easy3 of 10

Topics
String, Hash map
Solved
No attempts yet

Problem

An intelligence agency stores far more e-mail than any team of people could read, so the first pass is done by a program. Here you write a very simple version of that first pass.

Assume every e-mail consists only of words made up of lowercase letters, together with commas, periods, and whitespace (space, tab, newline). A word is a maximal run of lowercase letters. The agency keeps a list of keywords that raise alarms. If at least a certain number of distinct keywords from that list occur in the text, each at least once, the e-mail raises an alarm.

Write a program that determines which e-mails raise alarms.

Input

The first line is the number KK of data sets, followed by the KK data sets, each of the following form.

The first line contains three integers nn, kk, tt, separated by spaces. 1≤n≤1001 \le n \le 100 is the number of words that raise alarms, 1≤k≤1001 \le k \le 100 is the number of lines in the e-mail that follows, and 1≤t≤1001 \le t \le 100 is the number of keywords that need to occur to raise an alarm.

This is followed by nn lines, each containing a word of at most 20 lowercase letters and no other characters. Next come kk lines, each containing at most 80 characters, a mix of lowercase letters, commas, periods, and different forms of spaces. No word breaks across lines: a newline character ends a word, and a new word starts on the next line. Only exact matches count, so contest and contests do not match.

Output

For each data set, print Data Set x: on a line by itself, where xx is the number of the data set, starting at 1. On the next line print Alarm if the number of distinct keywords found in the e-mail is at least tt, and No Alarm otherwise. Print an empty line after each data set.

Examples1

  1. Example 1

    Input
    2
    5 1 3
    ack
    bruin
    ucla
    drone
    evade
    ack bruin ack me you .,bruins ack usc ackack .. bruin
    4 2 3
    ack
    bruin
    ucla
    drone
    ack bruin me ack you .,bruins ack usc, hello world
    ucla ackack .. bruin attack
    
    Expected output
    Data Set 1:
    No Alarm
    
    Data Set 2:
    Alarm