#include #include #include using namespace atcoder; using mint = modint; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 2000000000000000005 int main(){ int n; cin>>n; vector x(n),y(n),t(n); rep(i,n){ cin>>x[i]>>y[i]>>t[i]; /* x[i] = 100; y[i] = i; t[i] = i+1; */ } vector d(n,vector(n,Inf64)); rep(i,n)d[i][i] = 0; rep(i,n){ rep(j,n){ if(i==j)continue; if(t[i]==t[j]){ d[i][j] = (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]); } else{ long long X = x[i]*x[i] + y[i]*y[i]; long long Y = x[j]*x[j] + y[j]*y[j]; d[i][j] = ceil(pow(abs(sqrt(X)-sqrt(Y)),2.0));//abs(X-Y)*abs(X-Y); //cout<