{$O+,R+,S+,Q+}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $10100000}
{$IMAGEBASE $00400000}
{$APPTYPE console}

uses Math, SysUtils;

const
  nmax = 2000;
  eps = 1e-8;
  cinfile = 'highways.in';
  coutfile = 'highways.out';

type
  int = longint;
  real = extended;
  str = string[70];
  point = record
    name : str;
    x, y : int;
  end;

  tar = array [1..nmax] of point;

  edge = record
    u : int;
    nx : int;
  end;

var
  n : int;
  g : array [1..nmax] of int;
  k : int;
  s : array [1..nmax*2] of edge;
  p, cr : tar;
  nm : array [1..nmax] of int;

  names : array [1..nmax] of string;

procedure go(v, p : int);
var
  x : int;
begin
  x:= g[v];
  nm[v]:= 1;
  while x <> 0 do
  begin
    if s[x].u <> p then
    begin
      go(s[x].u, v);
      inc(nm[v], nm[s[x].u]);
    end;
    x:= s[x].nx;
  end;
end;

function angle(var a, b : point) : real;
begin
  angle:= arctan2(b.y, b.x) - arctan2(a.y, a.x);
end;

function less(var a, b : point) : boolean;
begin
  if (abs(a.x) + abs(a.y) = 0) then less:= true else
    if (abs(b.x) + abs(b.y) = 0) then less:= false else
      less:= angle(a, b) > eps;
end;

procedure sort(var a : tar; n : int);
var
  l, r : int;
  x : point;

  procedure sift;
  var
    i, j : int;
  begin
    x:= a[l];
    i:= l;
    j:= i shl 1;
    if (j < r) and less(a[j], a[j + 1]) then inc(j);
    while (j <= r) and less(x, a[j]) do
    begin
      a[i]:= a[j];
      i:= j;
      j:= i shl 1;
      if (j < r) and less(a[j], a[j + 1]) then inc(j);
    end;
    a[i]:= x;
  end;

begin
  r:= n;
  for l:= n shr 1 downto 1 do
    sift;
  l:= 1;
  for r:= n - 1 downto 1 do
  begin
    x:= a[1];
    a[1]:= a[r + 1];
    a[r + 1]:= x;
    sift;
  end;
end;

procedure change(var c : point; var a : tar; n : int);
begin
  //here we can make our solution wrong :-)
end;

procedure solve(v, p : int; var a : tar; n : int);
var
  x : int;
  c : point;
  i, pt : int;
  b : tar;
begin
  names[v]:= a[1].name;
  c:= a[1];
  for i:= 1 to n do
  begin
    dec(a[i].x, c.x);
    dec(a[i].y, c.y);
  end;
  sort(a, n);
  move(a[2], a[1], sizeof(a[1]) * (n - 1));
  dec(n);
  for i:= 1 to n do
    if angle(a[i], a[i + 1]) > pi - eps then
    begin
      move(a[i + 1], cr[1], sizeof(cr[1]) * (n - i));
      move(a[1], cr[n - i + 1], sizeof(cr[1]) * i);
      a:= cr;
      break;
    end;
  for i:= 1 to n do
  begin
    inc(a[i].x, c.x);
    inc(a[i].y, c.y);
  end;
  x:= g[v];
  pt:= 1;
  while x <> 0 do
  begin
    if s[x].u <> p then
    begin
      for i:= pt to pt + nm[s[x].u] - 1 do
        b[i - pt + 1]:= a[i];
      change(c, b, nm[s[x].u]);
      pt:= pt + nm[s[x].u];
      solve(s[x].u, v, b, nm[s[x].u]);
    end;
    x:= s[x].nx;
  end;
end;

procedure push(x, y : int);
begin
  inc(k);
  s[k].u:= y;
  s[k].nx:= g[x];
  g[x]:= k;
end;

var
  i : int;
  x, y : int;
  minp : int;
  t : point;
begin
  reset(input, cinfile);
  rewrite(output, coutfile);
  fillchar(g, sizeof(g), 0);
  k:= 0;
  readln(n);
  minp := 1;
  for i:= 1 to n do
  begin
    readln(p[i].name);
    readln(p[i].x, p[i].y);
    if (i > 1) and ((p[i].x < p[minp].x) or ((p[i].x = p[minp].x) and (p[i].y < p[minp].y))) then
        minp := i;
  end;
  t := p[minp];
  p[minp] := p[1];
  p[1] := t;
  for i:= 1 to n - 1 do
  begin
    read(x, y);
    push(x, y);
    push(y, x);
  end;
  go(1, -1);
  solve(1, -1, p, n);
  for i:= 1 to n do
    writeln(names[i]);
end.

