1 // 叉积判断 POJ1696
2
3 #include <iostream>
4 #include <algorithm>
5 #include <cstring>
6 #include <cstdio>
7 #include <vector>
8 #include <cmath>
9 #include <map>
10 using namespace std;
11 #define LL long long
12 typedef pair<int,int> pii;
13 const double inf = 123456789012345.0;
14 const int MOD = 998244353;
15 const int N = 2e5+10;
16 const int maxx = 200010;
17 #define clc(a,b) memset(a,b,sizeof(a))
18 const double eps = 1e-8;
19 void fre() {freopen("in.txt","r",stdin);}
20 void freout() {freopen("out.txt","w",stdout);}
21 inline int read() {int x=0,f=1;char ch=getchar();while(ch>'9'||ch<'0') {if(ch=='-') f=-1; ch=getchar();}while(ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}return x*f;}
22
23 int sgn(double x){
24 if(fabs(x) < eps)return 0;
25 if(x < 0)return -1;
26 else return 1;
27 }
28
29 struct Point{
30 double x,y;
31 int index;
32 Point(){}
33 Point(double _x,double _y){
34 x = _x;y = _y;
35 }
36 Point operator -(const Point &b)const{
37 return Point(x - b.x,y - b.y);
38 }
39 double operator ^(const Point &b)const{
40 return x*b.y - y*b.x;
41 }
42 double operator *(const Point &b)const{
43 return x*b.x + y*b.y;
44 }
45 };
46
47 double dist(Point a,Point b){
48 return sqrt((a-b)*(a-b));
49 }
50
51 int pos;
52 Point p[110];
53 bool cmp(Point a,Point b){
54 double tmp=(a-p[pos])^(b-p[pos]);
55 if(sgn(tmp)==0){
56 return dist(a,p[pos])<dist(b,p[pos]);
57 }
58 else if(sgn(tmp)<0) return false;
59 else return true;
60 }
61
62 int main(){
63 int T,n;
64 scanf("%d",&T);
65 while(T--){
66 scanf("%d",&n);
67 for(int i=0;i<n;i++){
68 scanf("%d%lf%lf",&p[i].index,&p[i].x,&p[i].y);
69 if(p[i].y<p[0].y||(p[i].y==p[0].y&&p[i].x<p[0].x)){
70 swap(p[i],p[0]);
71 }
72 }
73 pos=0;
74 for(int i=0;i<n;i++){
75 sort(p+i,p+n,cmp);
76 pos++;
77 }
78 printf("%d",n);
79 for(int i=0;i<n;i++)
80 printf(" %d",p[i].index);
81 printf("\n");
82 }
83 return 0;
84 }