#include<stdio.h>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int test = 16;
struct color{
int RGB[3];
};
bool comp(float d1, float d2){
return (d1<d2);
}
double count(color& colorDic, color& c){
double R = abs(colorDic.RGB[0] - c.RGB[0]);
double G = abs(colorDic.RGB[1] - c.RGB[1]);
double B = abs(colorDic.RGB[2] - c.RGB[2]);
return sqrt( R*R + G*G +B*B );
}
int main(){
int n, len;
vector<color> vc;
vector<float> r;
int r1, r2, r3;
scanf("%d%d%d",&r1, &r2,&r3);
while(-1 != r1 && -1 != r2 && -1 !=r3){
color c;
c.RGB[0] = r1;
c.RGB[1] = r2;
c.RGB[2] = r3;
vc.push_back(c);
scanf("%d%d%d",&r1, &r2,&r3);
}
for (int i =test; i < vc.size(); i++)
{
for (int j =0 ; j< test;j++)
{
float res =count(vc[j],vc[i] );
r.push_back(res);
}
vector<float>::iterator rr = min_element(r.begin(), r.end(), comp);
int dd = rr - r.begin();
printf("(%d,%d,%d) maps to (%d,%d,%d)\n", vc[i].RGB[0], vc[i].RGB[1],vc[i].RGB[2],
vc[dd].RGB[0], vc[dd].RGB[1], vc[dd].RGB[2]
);
r.clear();
}
return 0;
}