Hide

Problem H
Icky Words

Emilie and Poppy are enjoying their book club. But sometimes they disagree on what would be the next book they should read. Emilie has a very peculiar problem. She just cannot bare to look at certain words. Whenever she sees these specific words, she’ll either run for the hills or hide under the table. To avoid this, Poppy has agreed to filter out these books. No one wants a panicked Emilie.

Input

The first line of the input consists of two integers, $I$, number of icky words, $1 \leq I \leq 10^3$ words, and $N$, the number of books, $1 \leq N \leq 10^5$ lines. This is followed by the list of the icky words, then the list of the books. Each book is denoted by the authors name, $a = M$, and the title of the book, $b = M$, $1 \leq M\leq 10^3$ words, separated by a comma.

Icky words can occur both in the title and in the authors names. There can be repetitions in the input. Multiple authors can write books of the same name. If the title or the name contains a compound of the icky word, the book should not be discarded.

Output

The output should consist of the accepted books in lexicographical order, followed by a statement of how many books were discarded, with correct grammar.

Sample Input 1 Sample Output 1
3 7
luring
stampers
subcultural
Bassam Tareq, kneaded
Iyona Ronnika, enlivens divisional
Vanisha Janiqua, garages
Han Kang, projectors luring
Jojo Janita, recedes interpretable
Dontee Cecillia, restlessly
Desira Emmeline, pinestampers
Bassam Tareq, kneaded
Desira Emmeline, pinestampers
Dontee Cecillia, restlessly
Iyona Ronnika, enlivens divisional
Jojo Janita, recedes interpretable
Vanisha Janiqua, garages
1 book was discarded.
Sample Input 2 Sample Output 2
3 7
houseboats
fortified
worn
Delmas Jordanne, asphyxiate
Guillermina Lekita, utilitarians filtrate
Tyla Jerald, fortified glowed undeserving
Han Kang, crossexamines fortified
Sarae Elchonon, path
Mical Javed, unimplemented
Kenzie Sendy, cropped sorceress
Delmas Jordanne, asphyxiate
Guillermina Lekita, utilitarians filtrate
Kenzie Sendy, cropped sorceress
Mical Javed, unimplemented
Sarae Elchonon, path
2 books were discarded.

Please log in to submit a solution to this problem

Log in