Through the Grapevine
면접 대비시간 제한4초메모리 제한1024 MB
각 사람이 서로 다른 이웃 t명에게 소문을 들은 뒤에야 퍼뜨리기 시작하는 그래프에서 d일 후 소문을 아는 사람 수를 센다.
문제
According to Wikipedia, to hear something "through the grapevine" is to learn of something informally and unofficially by means of gossip or rumor. In this problem, you are tasked with determining how many people will hear about a particular rumor "through the grapevine" after a certain number of days.
Rumors are always started by a single person. On any given day, a person who knows the rumor can spread it by telling the people that they know. Upon hearing of the rumor, that person must wait until the following day before they can begin to spread it themselves. Furthermore, some people are skeptical and will only spread the rumor once they've heard it from a number of distinct sources. However once a person has heard the rumor from enough people, they will always try to spread the rumor to as many people as possible.
입력
The first line will contain three integers: , , and , where is the number of people, is the number of connections, and is the number of days that elapse.
The next lines will each consist of a unique string and an integer where is the name of a person and is their level of skepticism. In other words, person must hear the rumor from distinct other people before will begin spreading the rumor.
This is followed by lines each consisting of two strings and which indicates that person and person know each other. Each of these lines represents a unique pair of persons.
The final line will contain a single string , the name of the person that the rumor originates from. Note that is the only person with skepticism . All strings are between and characters long and consists only of letters and digits.
출력
Output a single integer: the number of people (not including person ) that have heard the rumor after days.