#include <bits/stdc++.h>
using namespace std;
const int N = 11000;
vector<int> adj[2 * N];
int chk[2 * N], ans[N], p[2 * N], deg[2 * N], x[10], y[10];
int check_star(vector<int> &A, int *x) {
  int flg = 0;
  int n = A.size();
  for (int u : A) {
    if (deg[u] == n - 2) {
      x[0] = u;
      flg = 1;
      for (int v : A) {
        if (v == u) continue;
        if (deg[v] == 2) {
          x[1] = v;
          for (int w : adj[v]) {
            if (w == u) continue;
            x[2] = w;
            break;
          }
          break;
        }
      }
      break;
    }
  }
  return flg;
}
void solve_star(vector<int> &B, int *y) {
  for (int u : B) {
    if (deg[u] == 1) {
      y[0] = u;
      int w = adj[u][0];
      y[2] = w;
      for (int v : B) chk[v] = (v == w);
      for (int v : adj[w]) chk[v] = 1;
      for (int v : B) {
        if (!chk[v]) {
          y[1] = v;
          break;
        }
      }
      return;
    }
  }
}
void solve_path(vector<int> &A, int *x) {
  for (int u : A) {
    if (deg[u] == 1) {
      x[0] = u;
      break;
    }
  }
  for (int i = 1; i < A.size(); i++) {
    int u = x[i - 1];
    for (int v : adj[u]) {
      if (i >= 2 && v == x[i - 2]) continue;
      x[i] = v;
      break;
    }
  }
}
void find_leaf(vector<int> &A, int *x) {
  x[0] = 0;
  for (int u : A) {
    if (deg[u] == 1) {
      p[u] = adj[u][0];
      if (!x[0] || deg[p[x[0]]] < deg[p[u]]) x[0] = u;
    }
  }
  for (int u : A) {
    if (deg[u] == 1) {
      if (p[u] != p[x[0]]) {
        x[1] = u;
        return;
      }
    }
  }
}
void solve(vector<int> &A, vector<int> &B) {
  int flg = 0;
  if (check_star(A, x))
    solve_star(B, y), flg = 1;
  else if (check_star(B, y))
    solve_star(A, x), flg = 1;
  if (flg) {
    for (int i = 0; i < 3; i++) ans[x[i]] = y[i];
    for (int i = 0; i < 3; i++) {
      A.erase(lower_bound(A.begin(), A.end(), x[i]));
      B.erase(lower_bound(B.begin(), B.end(), y[i]));
    }
    for (int i = 0; i < A.size(); i++) ans[A[i]] = B[i];
    return;
  }
  int n = A.size();
  if (n < 6) {
    solve_path(A, x);
    solve_path(B, y);
    for (int i = 0; i < n / 2; i++) ans[x[i]] = y[2 * i + 1];
    for (int i = n / 2; i < n; i++) ans[x[i]] = y[2 * (i - n / 2)];
    return;
  }
  find_leaf(A, x);
  find_leaf(B, y);
  int _x[2], _y[2];
  for (int i = 0; i < 2; i++) {
    _x[i] = x[i], _y[i] = y[i];
    A.erase(lower_bound(A.begin(), A.end(), x[i]));
    B.erase(lower_bound(B.begin(), B.end(), y[i]));
    adj[x[i]].clear();
    deg[x[i]] = 0;
    adj[p[x[i]]].erase(find(adj[p[x[i]]].begin(), adj[p[x[i]]].end(), x[i]));
    deg[p[x[i]]]--;
    adj[y[i]].clear();
    deg[y[i]] = 0;
    adj[p[y[i]]].erase(find(adj[p[y[i]]].begin(), adj[p[y[i]]].end(), y[i]));
    deg[p[y[i]]]--;
  }
  solve(A, B);
  for (int i = 0; i < 2; i++) {
    int u = _x[i], v = _y[i];
    if (ans[p[u]] == p[v]) {
      for (int j = 0; j < 2; j++) ans[_x[j]] = _y[j ^ 1];
      return;
    }
    ans[u] = v;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < 2 * n - 1; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
    deg[u]++, deg[v]++;
  }
  for (int i = 1; i <= n; i++)
    if (deg[i] == n - 1 || deg[n + i] == n - 1) return puts("No"), 0;
  vector<int> A, B;
  for (int i = 1; i <= n; i++) A.push_back(i), B.push_back(n + i);
  solve(A, B);
  puts("Yes");
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  return 0;
}
