Globetrotter

No attempts yetTime limit1sMemory limit128 MB

Problem

As a member of an ACM programming team, you will soon find yourself traveling all over the world: Zürich, Philadelphia, San José, Atlanta, and so on. The contest site changes every year, and some years the finals are even held on a different continent, so one year you might end up in Japan or Australia.

At the contest site it would be interesting to know how far you are from home. Your job is to write a program that computes the geographical distance between two given locations on the Earth's surface.

Assume that the Earth is a perfect sphere with a radius of exactly $6378$ km. The geographical distance between $A$ and $B$ is the length of the geodetic line segment connecting $A$ and $B$. The geodetic line segment between two points on a sphere is the shortest connecting curve that lies entirely on the surface of the sphere.

The value of $\pi$ is approximately $3.141592653589793$.

Input

The input consists of two parts: a list of cities and a list of queries.

City list

  • The city list has up to $100$ lines, one line per city. Each line contains a string $c_i$ and two real numbers $lat_i$ and $long_i$, giving the city name, its latitude, and its longitude, respectively.
  • Each city name is shorter than $30$ characters and contains no white-space characters.
  • The latitude is between $-90$ (South Pole) and $+90$ (North Pole). The longitude is between $-180$ and $+180$, where negative values denote locations west of the prime meridian and positive values denote locations east of it. (The prime meridian passes through Greenwich, London.)
  • The city list is terminated by a line containing a single #.

Query list

  • Each line contains two city names $A$ and $B$.
  • The query list is terminated by the line # #.

Output

For each query, first print a line A - B, where $A$ and $B$ are replaced by the city names. Then print a line x km, where $x$ is the geographical distance (in km) between the two cities, rounded to the nearest integer.

If either city in the query does not appear in the city list, print Unknown instead. Print a blank line between consecutive queries.