#include <bits/stdc++.h>
const int N = 1e5 + 5, M = 1e5;
using namespace std;
long long myrand() {
  return ((long long)(rand() & 65535) << 32) + ((long long)rand() << 16) +
         rand();
}
pair<int, pair<long long, int> > st1[N], st2[N];
int vis[N], dis[N], off, pre[N], n, deg[N], deg2[N], u, v, ret[N];
vector<int> e[N], e2[N];
bitset<10100> adj[10100];
set<pair<int, pair<long long, int> > > hs;
pair<int, int> E[N];
void del(int u) {
  off += 1;
  dis[u] = 1;
  hs.erase(st1[u]);
  for (auto v : e[u])
    if (!dis[v]) {
      hs.erase(st1[v]);
      st1[v].first++;
      hs.insert(st1[v]);
    }
}
bool gao0() {
  random_shuffle(pre + 1, pre + n + 1);
  for (int i = 1; i < n; ++i)
    if (adj[pre[E[i].first]][pre[E[i].second]]) return 0;
  for (int i = 1; i < n + 1; ++i) ret[pre[i]] = i;
  puts("Yes");
  for (int i = 1; i < n + 1; ++i) printf("%d ", ret[i] + n);
  puts("");
  return 1;
}
bool gao() {
  hs.clear();
  off = 0;
  for (int i = 1; i < n + 1; ++i) {
    st1[i] = make_pair(deg[i], make_pair(myrand(), i));
    st2[i] = make_pair(deg2[i], make_pair(myrand(), i));
    hs.insert(st1[i]);
    vis[i] = 0;
    dis[i] = 0;
  }
  for (int i = 1; i < n + 1; ++i) pre[i] = 0;
  pair<int, pair<long long, int> > val = st2[1];
  for (int i = 2; i < n + 1; ++i) val = min(val, st2[i]);
  priority_queue<pair<int, pair<long long, int> >,
                 vector<pair<int, pair<long long, int> > >,
                 greater<pair<int, pair<long long, int> > > >
      q;
  q.push(val);
  pre[val.second.second] = hs.begin()->second.second;
  vis[val.second.second] = 1;
  del(hs.begin()->second.second);
  while (!q.empty()) {
    pair<int, pair<long long, int> > st = q.top();
    q.pop();
    int u = st.second.second;
    int w = pre[u];
    for (auto v : e2[u])
      if (!vis[v]) {
        st2[v].first--;
        vis[v] = 1;
        vector<pair<int, pair<long long, int> > > tmp;
        while (1) {
          auto it =
              hs.lower_bound(make_pair(st2[v].first + off, make_pair(-1, -1)));
          if (it == hs.end()) return 0;
          if (adj[w][it->second.second]) {
            tmp.push_back(*it);
            hs.erase(it);
          } else {
            pre[v] = it->second.second;
            for (auto p : tmp) hs.insert(p);
            del(it->second.second);
            q.push(st2[v]);
            break;
          }
        }
      }
  }
  for (int i = 1; i < n + 1; ++i) ret[pre[i]] = i;
  puts("Yes");
  for (int i = 1; i < n + 1; ++i) printf("%d ", ret[i] + n);
  puts("");
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n + 1; ++i) deg[i] = n - 1;
  for (int i = 1; i < n; ++i) {
    scanf("%d%d", &u, &v);
    e[u].push_back(v), e[v].push_back(u);
    adj[u][v] = adj[v][u] = 1;
    deg[u]--;
    deg[v]--;
  }
  for (int i = 1; i < n; ++i) {
    scanf("%d%d", &u, &v);
    u -= n;
    v -= n;
    e2[u].push_back(v);
    e2[v].push_back(u);
    E[i] = make_pair(u, v);
    deg2[u]++;
    deg2[v]++;
  }
  for (int i = 1; i < n + 1; ++i)
    if (deg[i] == 0 || deg2[i] == n - 1) {
      puts("No");
      return 0;
    }
  while (clock() <= 2.5 * CLOCKS_PER_SEC) {
    if (gao()) return 0;
  }
  for (int i = 1; i < n + 1; ++i) pre[i] = i;
  while (clock() <= 3.5 * CLOCKS_PER_SEC) {
    if (gao0()) return 0;
  }
  puts("No");
}
