Sometimes, you may want to print a color image in grayscale mode, either because you want to save ink or your printer can only do so. However, when you do that, you may encounter a problem: some colors that are distinct in the color image may become indistinguishable in the grayscale image. This is the information loss caused by the grayscale conversion.

Of course, a good conversion from RGB (Red, Green, Blue) to Grayscale is not unique. Here, we define a property that a good conversion must satisfy: if a color
(r,g,b)(r, g, b)(r,g,b) is strictly less than
(r′,g′,b′)(r', g', b')(r′,g′,b′):
r<r′,g<g′,b<b′r < r', g < g', b < b'r<r′,g<g′,b<b′, then the conversion
fff must hold that
f(r,g,b)<f(r′,g′,b′)f(r, g, b) < f(r', g', b')f(r,g,b)<f(r′,g′,b′). It means that the strict partial order on color space should be preserved.
Xiao Fan is given an RGB image and you want to convert it to a grayscale image. However, Xiao Fan also want to confuse Xiao Shi by intentionally mapping two specified colors to the same grayscale value, while keeping the order of the colors. Can you help Xiao Fan to find a good conversion that confuses two given colors from
nnn given colors?