#K82762. Spam Email Classifier

    ID: 36048 Type: Default 1000ms 256MiB

Spam Email Classifier

Spam Email Classifier

You are given a list of spam words and several email messages. Your task is to determine whether an email should be classified as Spam or Not Spam based on how many spam words it contains.

Specifically, for each email, count the number of words (case-insensitive) that exactly match any of the provided spam words. An email is classified as Spam if the total count is at least \(K\), and Not Spam otherwise. Formally, if \(\text{count} \geq K\), the email is Spam; otherwise, it is Not Spam.

inputFormat

The input is read from standard input (stdin) in the following format:

  1. The first line contains two integers: T (the number of emails) and K (the threshold for spam classification).
  2. The second line contains an integer N representing the number of spam words.
  3. The third line contains N spam words separated by spaces.
  4. The next T lines each contain an email message.

outputFormat

For each email message, output a single line to standard output (stdout) containing either Spam or Not Spam according to the classification rule.

## sample
2 3
4
viagra buy cheap free
Buy now! Cheap viagra available online.
This is a free discount card for you.
Spam

Not Spam

</p>