#include #include #include #include #define x first #define y second using namespace std; typedef pair pii; typedef long long ll; int n,odw_t[1001],odw_p[1001],end_num[1001]; pair p[1001]; vector v[1001]; pii operator- (pii a, pii b) { return make_pair(a.x-b.x,a.y-b.y); } ll wek(pii a,pii b) { return (ll)a.x*b.y-(ll)a.y*b.x; } int dupa=0; int odwr[1001]; void dfs(int a,int np) { end_num[a]=p[np].second; odwr[p[np].second]=a; odw_t[a]=1; odw_p[np]=1; vector vv; for (int i=1; i<=n; i++) if (!odw_p[i]) vv.push_back(i); dupa=np; sort(vv.begin(),vv.end(),[](int a,int b) { return wek(p[a].first-p[dupa].first,p[b].first-p[dupa].first)>0; }); int poz=0; for (int s:v[a]) if (!odw_t[s]) { while (odw_p[vv[poz]]) poz++; dfs(s,vv[poz]); } vv.clear(); } int main() { scanf("%d",&n); for (int i=1; iend_num[i]) printf("%d %d\n",end_num[i]-1,end_num[s]-1); } }