#C11200. Vasya's Books
Vasya's Books
Vasya's Books
Vasya is an avid reader with a specific taste in genres. Given his list of favorite genres and a list of books (each with a title and a genre), your task is to determine the first book that Vasya will read which falls under one of his favorite genres. If none of the books are to his taste, output None
.
You are given two lists: one containing Vasya's favorite genres and one containing a list of books. The books are provided in the order they are available. Formally, if the list of favorite genres is \(F\) and the list of books is \(B = [(t_1, g_1), (t_2, g_2), \dots, (t_m, g_m)]\), find the smallest index \(i\) such that \(g_i \in F\). If there is no such \(i\), return None
.
inputFormat
The first line contains two integers (n) and (m) where (n) is the number of favorite genres and (m) is the number of books. The second line contains (n) strings representing Vasya's favorite genres. Each of the next (m) lines contains two strings: the title of a book and its genre, separated by a space.
outputFormat
Output a single line containing the title of the first book that matches one of Vasya's favorite genres. If no such book exists, output (None).## sample
3 5
fiction mystery drama
book1 mystery
book2 sci-fi
book3 drama
book4 romance
book5 fiction
book1