Closest Web Color Name

No attempts yetTime limit2sMemory limit256 MB

Problem

Web colors are the colors used to display web pages. A single color is given either as an RGB triple or as the English name of that color. A color is set by the intensity of its red, green and blue components, and each component takes eight bits, so one web color needs 24 bits and there are 16,777,216 web colors in total. The HTML 4 specification names only the 16 colors in the table below.

Mapping an arbitrary color to one of the named HTML colors is a common task. This problem asks for that mapping in RGB space.

The color closest to a given color is the one at the smallest Euclidean distance. If the color to map is (r,g,b)(r, g, b) and the 16 HTML colors are (R1,G1,B1)(R_1, G_1, B_1) through (R16,G16,B16)(R_{16}, G_{16}, B_{16}), the closest color minimizes

d=(Rir)2+(Gig)2+(Bib)2d = \sqrt{(R_i - r)^2 + (G_i - g)^2 + (B_i - b)^2}

where ii is an integer from 1 to 16.

#NameRedGreenBlue
1White255255255
2Silver192192192
3Gray128128128
4Black000
5Red25500
6Maroon12800
7Yellow2552550
8Olive1281280
9Lime02550
10Green01280
11Aqua0255255
12Teal0128128
13Blue00255
14Navy00128
15Fuchsia2550255
16Purple1280128

Input

The input holds several test cases. Each test case is one line with three integers rr, gg, bb (0r,g,b2550 \le r, g, b \le 255), the red, green and blue intensities of a color.

The last line of the input is -1 -1 -1 and is not processed.

Output

For each test case, print on its own line the name of the HTML color closest to the given color, spelled as in the table. If two or more colors are equally close, print the name of the one with the smaller number in the table.