#K37032. Bib Number Checker

    ID: 25886 Type: Default 1000ms 256MiB

Bib Number Checker

Bib Number Checker

You are given a list of race bib numbers and a list of disallowed words. The task is to determine whether each bib number is valid or invalid based on whether it contains any of the disallowed words as a substring.

A bib number is considered Invalid if it contains any disallowed word; otherwise, it is considered Valid.

Note: All matching is case-sensitive.

The answer should read input from standard input and write the results to standard output.

inputFormat

The first line of input contains two integers n and m separated by a space, where n is the number of bib numbers and m is the number of disallowed words.

The second line contains n bib numbers separated by spaces. If n is 0, this line will be empty.

The third line contains m disallowed words separated by spaces. If m is 0, this line will be empty.

For example:

2 1
12BAD56 GOOD123
BAD

outputFormat

Output exactly n lines. Each line should contain either Valid or Invalid corresponding to each bib number in the order they were given. A bib number is Invalid if it contains any disallowed word; otherwise, it is Valid.

For the example above, the output should be:

Invalid
Valid
## sample
2 1
12BAD56 GOOD123
BAD
Invalid

Valid

</p>