import java.io.*;
import java.util.*;

public class highways_petr {
    static final double ROTATE_ANGLE = 0.89759721981;

    class City {
        public double x;
        public double y;
        public String name;

        public City(double x, double y, String name) {
            this.x = x;
            this.y = y;
            this.name = name;
        }

        public void Rotate(double alpha) {
            double nx = x * Math.cos(alpha) - y * Math.sin(alpha);
            double ny = x * Math.sin(alpha) + y * Math.cos(alpha);

            x = nx;
            y = ny;
        }
    }

    class Vertex {
        public ArrayList<Vertex> neighbours;
        public City match;
        public int amount;

        public Vertex() {
            neighbours = new ArrayList<Vertex>();
            match = null;
            amount = 0;
        }
    }

    class CenteredComparer implements Comparator<City> {
        City center;

        public CenteredComparer(City center) {
            this.center = center;
        }

        public int compare(City city1, City city2) {
            if (city1 == city2)
                return 0;
            if (city1 == center)
                return -1;
            if (city2 == center)
                return 1;

            double x1 = city1.x - center.x;
            double y1 = city1.y - center.y;
            double x2 = city2.x - center.x;
            double y2 = city2.y - center.y;

            return Double.compare(x1 * y2 - x2 * y1, 0);
        }
    }

    City[] cities;
    Vertex[] vertices;
    Vertex root;

    void readInput() throws FileNotFoundException {
        Scanner scanner = new Scanner(new File("highways.in"), "ISO-8859-1");

        int numCities = scanner.nextInt();
        scanner.nextLine();

        cities = new City[numCities];

        for (int i = 0; i < numCities; ++i) {
            String name = scanner.nextLine();
            double x = scanner.nextInt();
            double y = scanner.nextInt();
            scanner.nextLine();
            City city = new City(x, y, name);
            city.Rotate(ROTATE_ANGLE);
            cities[i] = city;
        }

        vertices = new Vertex[numCities];
        for (int i = 0; i < numCities; ++i)
            vertices[i] = new Vertex();

        for (int i = 0; i < numCities - 1; ++i) {
            int a = scanner.nextInt() - 1;
            int b = scanner.nextInt() - 1;
            Vertex vertexA = vertices[a];
            Vertex vertexB = vertices[b];
            vertexA.neighbours.add(vertexB);
            vertexB.neighbours.add(vertexA);
        }

        root = vertices[0];
    }

    void writeOutput() throws FileNotFoundException, UnsupportedEncodingException {
        PrintWriter writer = new PrintWriter("highways.out", "ISO-8859-1");
        for (Vertex vertex : vertices)
            writer.println(vertex.match.name);
        writer.close();
    }

    void fillAmount(Vertex start, Vertex parent) {
        start.amount = 1;
        for (Vertex neighbour : start.neighbours) {
            if (neighbour != parent) {
                fillAmount(neighbour, start);
                start.amount += neighbour.amount;
            }
        }
    }

    void buildIt(Vertex root, Vertex parent, City[] cities) {
        assert(root.amount == cities.length);

        City topMost = null;
        for (City city : cities)
            if (topMost == null || city.y > topMost.y)
                topMost = city;

        root.match = topMost;

        Arrays.sort(cities, new CenteredComparer(topMost));

        int id = 0;

        for (Vertex neighbour : root.neighbours) {
            if (neighbour != parent) {
                City[] childCities = new City[neighbour.amount];

                for (int i = 0; i < neighbour.amount; ++i) {
                    if (cities[id] == topMost) ++id;
                    childCities[i] = cities[id];
                    ++id;
                }

                buildIt(neighbour, root, childCities);
            }
        }
    }

    void solve() {
        fillAmount(root, null);
        buildIt(root, null, cities);
    }

    void run() throws FileNotFoundException, UnsupportedEncodingException {
        readInput();
        solve();
        writeOutput();
    }

    public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException {
        new highways_petr().run();
    }
}
