#include<iostream>
#include<cmath>
#include<iomanip>
#include<algorithm>
using namespace::std;
typedef struct {double xx,yy,zz;}poi;
void swap(int *x, int *y)
{
int temp;
temp=*x;
*x=*y;
*y=temp;
}
void mpao(poi*a,double n)
{
int i,j;
for(i=0;i<n-1;i++)
{
for(j=i+1;j>0&&a[j].zz>a[j-1].zz;j--)
swap(a[j],a[j-1]);
}
}
int qw=0;
double jia(poi q,poi w)
{
return sqrt((q.xx-w.xx)*(q.xx-w.xx)+(q.yy-w.yy)*(q.yy-w.yy)+(q.zz-w.zz)*(q.zz-w.zz));
}
main()
{
poi a[100];
int n,k,i;
int t;
cin>>n;
t=n*(n+1)/2;
for(i=0;i<n;i++)
{
cin>>a[i].xx>>a[i].yy>>a[i].zz;
}
double b[t];
poi w[t];
for(i=0;i<n;i++)
for(k=i+1;k<n;k++)
{
b[qw]=jia(a[i],a[k]);
w[qw].zz=b[qw];
w[qw].xx=i;
w[qw].yy=k;
qw++;
}
sort(b,b+qw);
mpao(w,qw);
for(i=qw-1;i>=0;i--) cout<<"{"<<(int)a[(int)w[i].xx].xx<<","<<(int)a[(int)w[i].xx].yy<<","<<(int)a[(int)w[i].xx].zz<<"}"
<<"-"<<"{"<<(int)a[(int)w[i].yy].xx<<","<<(int)a[(int)w[i].yy].yy<<","<<(int)a[(int)w[i].yy].zz<<"}"<<"="
<<fixed<<setprecision(2)<<b[i]<<endl;
return 0;
}