North and South

 

Program NORTH.C, NORTH.CPP, NORTH.PAS

Gainesville is a well known stop on Interstate 75, a north south route. But it is far from the only town along the highway. This problem asks you to look at a number of towns and determine their relative positions.

Input and Output

The input for this problem comes in two sets. The first part of the input gives the relative positions of towns. There will be 0 or more lines in this set, each of which has a pair of city names. In this input, the city listed first is to the south of the city listed second. So, the line:

City_1 City_2

represents the fact "City_1 is south of City_2."

The list of relative positions will end with a line containing just a single # sign.

After the pound signs will be questions about the data in the format:

City_1 City_2

This represents the question: What is the position of City_1 relative to City_2? Your program should print one of the following lines of output for each question:

City_1 is north of City_2.

City_1 is south of City_2.

The relative positioning of City_1 and City_2 is unknown.

Where the appropriate city names are substituted into the output. Have one blank line after each line of output.

The list of questions will be ended by a line containing a single # sign.

In both sections, each name is a string of up to 11 letters, and the names will be separated by at least one blank. Any blanks before or after a name should be ignored. Case is significant in names, so Gainesville and GAINESVILLE should be considered different cities by your program. There are not more than 100 cities on the highway.

Recall, "is north of" is a transitive relationship, so if City_1 is north of City_2 and City_2 is north of City_3, you may conclude City_1 is north of City_3. You may assume the input is consistent, that is, there will be no information that indicates a city is north of itself.

Sample Input
Gainesville Valdosta
Valdosta Atlanta
LakeCity Valdosta
#
Gainesville Atlanta
Tampa Gainesville
Atlanta Valdosta
LakeCity Gainesville
#

Sample Output
Gainesville is south of Atlanta.

The relative positioning of Tampa and Gainesville is unknown.

Atlanta is north of Valdosta.

The relative positioning of LakeCity and Gainesville is unknown.