#include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<algorithm> #include<queue> using namespace std; const double eps = 1e-8; const double PI = acos(-1.0); const double INF = 100000000.000000; struct Point{ int index; double x,y; Point(double x=0, double y=0) : x(x),y(y){ } //构造函数 }; typedef Point Vector; Vector operator + (Vector A , Vector B){return Vector(A.x+B.x,A.y+B.y);} Vector operator - (Vector A , Vector B){return Vector(A.x-B.x,A.y-B.y);} Vector operator * (Vector A , double p){return Vector(A.x*p,A.y*p);} Vector operator / (Vector A , double p){return Vector(A.x/p,A.y/p);} bool operator < (const Point& a,const Point& b){ return a.y < b.y ||( a.y == b.y && a.x < b.x); } int dcmp(double x){ if(fabs(x) < eps) return 0; else return x < 0 ? -1 : 1; } bool operator == (const Point& a, const Point& b){ return dcmp(a.x - b.x) == 0 && dcmp(a.y - b.y) == 0; } ///向量(x,y)的极角用atan2(y,x); double Dot(Vector A, Vector B){ return A.x*B.x + A.y*B.y; } double Length(Vector A) { return sqrt(Dot(A,A)); } double Angle(Vector A, Vector B) { return acos(Dot(A,B) / Length(A) / Length(B)); } double Cross(Vector A, Vector B) { return A.x*B.y - A.y * B.x; } Vector Rotate(Vector A, double rad) { return Vector(A.x*cos(rad)-A.y*sin(rad),A.x*sin(rad)+A.y*cos(rad)); } double Area(Point A,Point B,Point C) { return Cross(B-A,C-A); } Point read_point(){ Point A; scanf("%d %lf %lf",&A.index,&A.x,&A.y); return A; } /*************************************分 割 线*****************************************/ Point P[105]; int pos; bool cmp(Point A,Point B){ double num = Cross(A-P[pos],B-P[pos]); if(dcmp(num) == 0){ return Length(A-P[pos]) < Length(B-P[pos]); } else if(dcmp(num) < 0) return false; else return true; } int main() { //freopen("E:\acm\input.txt","r",stdin); int T; cin>>T; int N; while(T--){ cin>>N; for(int i=1;i<=N;i++){ P[i] = read_point(); if(P[i] < P[1]){ swap(P[i],P[1]); } } pos = 1; for(int i=1;i<=N;i++){ sort(P+i,P+N+1,cmp); pos++; } printf("%d",N); for(int i=1;i<=N;i++) printf(" %d",P[i].index); printf(" "); } }