End of the Trip

View as PDF

Submit solution


Points: 1
Time limit: 1.0s
Memory limit: 128M

Author:
Problem type
Allowed languages
Python

Description

Speeding Air-Line (SAL) has multiple air-routes available, each is a one-way flight from city C_{from} to C_{to}.

Now SAL launched a new offer, selling N tickets in one, leaving from C_a, travel through multiple cities, and finally stay at C_b.

Given the (C_{from}, C_{to}) of these N air-routes, find which city is the end of the trip (C_b)

Limits

  • number of air-routes: 1 \le N \le 10^6
  • leaving and staying: C_a \ne C_b
  • take-off and landing: C_{from} \ne C_{to}
  • city visits count: \(Visit(\space C_a \space) = Visit(\space C_b \space) = 1\)

Input

First line contains a positive interger N, following by the (C_{from}, C_{to}) of these N air-routes.

Each air-routes is given by 2 lines of input:

  1. the first line is C_{from}, representing take-off city.
  2. the second line is C_{to}, representing landing city.

Sample IO

Example 1
Input
3
London
New York
New York
Lima
Lima
Sao Paulo
Output
Sao Paulo
Example 2
Input
11
Berlin
Rio de Janeiro
Sydney
Rome
New York
Tokyo
Beijing
Berlin
Moscow
Los Angeles
Tokyo
Paris
Rome
Beijing
Paris
London
Cairo
Moscow
London
Sydney
Rio de Janeiro
Cairo
Output
Los Angeles

Comments

There are no comments at the moment.