#include <bits/stdc++.h>
using namespace std;
const int max_n = 1500;
const int inv = numeric_limits<int>::max();
int n;
vector<int> adjl[max_n];
vector<int> chl[max_n];
bool visited[max_n] = {0};
int nvt[max_n] = {0};
void DFS(int vt) {
  visited[vt] = true;
  nvt[vt] = 1;
  int vtnbr;
  for (int i = 0; i < adjl[vt].size(); ++i) {
    vtnbr = adjl[vt][i];
    if (!visited[vtnbr]) {
      chl[vt].push_back(vtnbr);
      DFS(vtnbr);
      nvt[vt] += nvt[vtnbr];
    }
  }
}
struct point {
  int qx, qy;
  int ix;
  point(){};
  point(int cqx, int cqy, int cix) {
    qx = cqx;
    qy = cqy;
    ix = cix;
  }
};
point L[max_n][max_n];
int Lsz[max_n] = {0};
int xc[max_n];
int yc[max_n];
int f[max_n];
struct point_cmp : public binary_function<point, point, bool> {
  bool operator()(const point &a, const point &b) {
    return ((long long)(a.qy) * (long long)(b.qx) >
            (long long)(a.qx) * (long long)(b.qy));
  }
};
void place(int vt) {
  if (chl[vt].size() == 0) return;
  int xcp = inv, ycp = inv, ixp;
  for (int i = 0; i < n; ++i) {
    if (f[i] == vt) {
      if (xc[i] < xcp or (xc[i] == xcp and yc[i] < ycp)) {
        xcp = xc[i];
        ycp = yc[i];
        ixp = i;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    if (i != ixp and f[i] == vt) {
      L[vt][Lsz[vt]] = point(xc[i] - xcp, yc[i] - ycp, i);
      ++Lsz[vt];
    }
  }
  sort(L[vt], L[vt] + Lsz[vt], point_cmp());
  int chix = 0;
  int ch = chl[vt][0];
  int ct = 0;
  for (int i = 0; i < Lsz[vt]; ++i) {
    f[L[vt][i].ix] = ch;
    ++ct;
    if (ct == nvt[ch]) {
      ct = 0;
      ++chix;
      ch = chl[vt][chix];
    }
  }
  assert(ct == 0 and chix == chl[vt].size());
  for (int i = 0; i < chl[vt].size(); ++i) place(chl[vt][i]);
  return;
}
int main() {
  scanf("%d", &n);
  int tu, tv;
  for (int i = 0; i < n - 1; ++i) {
    scanf("%d %d", &tu, &tv);
    --tu;
    --tv;
    adjl[tu].push_back(tv);
    adjl[tv].push_back(tu);
  }
  DFS(0);
  for (int i = 0; i < n; ++i) {
    f[i] = 0;
    scanf("%d %d", &xc[i], &yc[i]);
  }
  place(0);
  for (int i = 0; i < n; ++i) printf("%d ", f[i] + 1);
  printf("\n");
  return 0;
}

### Prompt

Generate a Cpp solution to the following problem:

You are given a tree with n vertexes and n points on a plane, no three points lie on one straight line.

Your task is to paint the given tree on a plane, using the given points as vertexes. 

That is, you should correspond each vertex of the tree to exactly one point and each point should correspond to a vertex. If two vertexes of the tree are connected by an edge, then the corresponding points should have a segment painted between them. The segments that correspond to non-adjacent edges, should not have common points. The segments that correspond to adjacent edges should have exactly one common point.

Input

The first line contains an integer n (1 ≤ n ≤ 1500) — the number of vertexes on a tree (as well as the number of chosen points on the plane).

Each of the next n - 1 lines contains two space-separated integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the numbers of tree vertexes connected by the i-th edge.

Each of the next n lines contain two space-separated integers xi and yi ( - 109 ≤ xi, yi ≤ 109) — the coordinates of the i-th point on the plane. No three points lie on one straight line.

It is guaranteed that under given constraints problem has a solution.

Output

Print n distinct space-separated integers from 1 to n: the i-th number must equal the number of the vertex to place at the i-th point (the points are numbered in the order, in which they are listed in the input).

If there are several solutions, print any of them.

Examples

Input

3
1 3
2 3
0 0
1 1
2 0


Output

1 3 2


Input

4
1 2
2 3
1 4
-1 -2
3 5
-3 3
2 0


Output

4 2 1 3

Note

The possible solutions for the sample are given below.

<image> <image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int max_n = 1500;
const int inv = numeric_limits<int>::max();
int n;
vector<int> adjl[max_n];
vector<int> chl[max_n];
bool visited[max_n] = {0};
int nvt[max_n] = {0};
void DFS(int vt) {
  visited[vt] = true;
  nvt[vt] = 1;
  int vtnbr;
  for (int i = 0; i < adjl[vt].size(); ++i) {
    vtnbr = adjl[vt][i];
    if (!visited[vtnbr]) {
      chl[vt].push_back(vtnbr);
      DFS(vtnbr);
      nvt[vt] += nvt[vtnbr];
    }
  }
}
struct point {
  int qx, qy;
  int ix;
  point(){};
  point(int cqx, int cqy, int cix) {
    qx = cqx;
    qy = cqy;
    ix = cix;
  }
};
point L[max_n][max_n];
int Lsz[max_n] = {0};
int xc[max_n];
int yc[max_n];
int f[max_n];
struct point_cmp : public binary_function<point, point, bool> {
  bool operator()(const point &a, const point &b) {
    return ((long long)(a.qy) * (long long)(b.qx) >
            (long long)(a.qx) * (long long)(b.qy));
  }
};
void place(int vt) {
  if (chl[vt].size() == 0) return;
  int xcp = inv, ycp = inv, ixp;
  for (int i = 0; i < n; ++i) {
    if (f[i] == vt) {
      if (xc[i] < xcp or (xc[i] == xcp and yc[i] < ycp)) {
        xcp = xc[i];
        ycp = yc[i];
        ixp = i;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    if (i != ixp and f[i] == vt) {
      L[vt][Lsz[vt]] = point(xc[i] - xcp, yc[i] - ycp, i);
      ++Lsz[vt];
    }
  }
  sort(L[vt], L[vt] + Lsz[vt], point_cmp());
  int chix = 0;
  int ch = chl[vt][0];
  int ct = 0;
  for (int i = 0; i < Lsz[vt]; ++i) {
    f[L[vt][i].ix] = ch;
    ++ct;
    if (ct == nvt[ch]) {
      ct = 0;
      ++chix;
      ch = chl[vt][chix];
    }
  }
  assert(ct == 0 and chix == chl[vt].size());
  for (int i = 0; i < chl[vt].size(); ++i) place(chl[vt][i]);
  return;
}
int main() {
  scanf("%d", &n);
  int tu, tv;
  for (int i = 0; i < n - 1; ++i) {
    scanf("%d %d", &tu, &tv);
    --tu;
    --tv;
    adjl[tu].push_back(tv);
    adjl[tv].push_back(tu);
  }
  DFS(0);
  for (int i = 0; i < n; ++i) {
    f[i] = 0;
    scanf("%d %d", &xc[i], &yc[i]);
  }
  place(0);
  for (int i = 0; i < n; ++i) printf("%d ", f[i] + 1);
  printf("\n");
  return 0;
}

```