Through the Grapevine

아직 제출이 없습니다시간 제한4초메모리 제한1024 MB

문제

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: 0<n100,0000 < n \leq 100\\,000, 0<m100,0000 < m \leq 100\\,000, and 0d10,0000 \leq d \leq 10\\,000, where nn is the number of people, mm is the number of connections, and dd is the number of days that elapse.

The next nn lines will each consist of a unique string ss and an integer 0t10000 \leq t \leq 1000 where ss is the name of a person and tt is their level of skepticism. In other words, person ss must hear the rumor from tt distinct other people before ss will begin spreading the rumor.

This is followed by mm lines each consisting of two strings uu and vv which indicates that person uu and person vv know each other.  Each of these lines represents a unique pair of persons.

The final line will contain a single string rr, the name of the person that the rumor originates from. Note that rr is the only person with skepticism t=0t = 0. All strings are between 11 and 2020 characters long and consists only of letters and digits.

출력

Output a single integer: the number of people (not including person rr) that have heard the rumor after dd days.