#include #define ALL(x) (x).begin(), (x).end() #define SZ(x) (int) (x).size() #define pb push_back #define fi first #define se second using namespace std; typedef long long LL; typedef vector VI; typedef pair PII; typedef long double LD; #define x real() #define y imag() #define point complex bool gora(point a) { if(a.y > 0 || (a.y >= 0 && a.x >= 0)) return 1; return 0; } LL wyz(point a, point b, point c) { b -= a; c -= a; return b.x * c.y - b.y * c.x; } int wyzznak(point a, point b, point c) { LL res = wyz(a, b, c); if(res > 0) return 1; if(res < 0) return -1; return 0; } const int maxn = 1e5 + 7; point P[maxn]; int r[maxn]; int num[maxn]; int licz = 1; vector > pod[maxn]; VI wek[maxn]; bool anglecom(pair & a, pair & b) { if(gora(a.se) != gora(b.se)) return gora(b.se) < gora(a.se); return wyzznak(point(0, 0), a.se, b.se) == 1; } bool minc(int a, int b) { if(P[a].x != P[b].x) return (P[a].x < P[b].x); return P[a].y < P[b].y; } void dfs(int ja, int f = -1) { r[ja] = 1; for(auto s : wek[ja]) if(s != f) { dfs(s, ja); pod[ja].pb({s, r[s]}); r[ja] += r[s]; } } void rek(int ja, vector cnt) { vector > cur; for(auto s : cnt) cur.pb({s, P[s] - P[ja]}); sort(ALL(cur), anglecom); for(auto s : pod[num[ja]]) { vector xd; while(SZ(xd) < s.se) { xd.pb(cur.back().fi); cur.pop_back(); } int kto = xd.back(); xd.pop_back(); cout<>n; for(int i = 1;i < n;i++) { int a, b; cin>>a>>b; wek[a].pb(b); wek[b].pb(a); } dfs(0); for(int i = 0;i < n;i++) { int a, b; cin>>a>>b; P[i] = point(a, b); } vector weed; for(int i = 0;i < n;i++) weed.pb(i); sort(ALL(weed), minc); reverse(ALL(weed)); int kto = weed.back(); weed.pop_back(); num[kto] = 0; rek(kto, weed); return 0; }