![]() |
||||||||||
|
||||||||||
As the Crow FliesTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 275 Accepted Submission(s): 11 Problem Description ![]() As president of a startup airline company, you have started a frequent flier program that rewards customers for every mile they travel. As a for-profit company, you have a vested interest in minimizing the number of frequent flier miles that a person can earn on any one trip. To get an idea of how many miles a customer could earn flying the existing network, you've decided to write a program. Assumptions:
Input The first line contains a single integer n indicating the number of data sets. Each data set will be formatted according to the following description: A single data set has 3 components: 1. Header Line - A single line, "X Y", where X is the number of cities and Y is the number of flight legs in the airline's network. Both will be positive integers less than 100. 2. City List - A list of cities and their locations, one city per line. The line will be of the format "C LA NS LO EW" where:
3. Flight List - A list of city pairs of the format "B C" representing different cities that are directly connected by flight legs, one pair per line. Note that "B C" is equivalent to "C B". Note:
Output For each data set, output the two cities that are farthest from each other (farthest in the sense that the shortest route between them is the longest of any city pair). You are guaranteed that there will be no ties. Display the city names on the same line, separated by a single space, sorted in dictionary order. Sample Input
Sample Output
| ||||||||||
|