func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long INF = 1LL << 60;   int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }   int lcm(int a, int b) { return a * b / gcd(a, b); }   const int N = 2e5 + 5;   int v[N], in[N];   vector<int> e[N];   bool cmp(int a, int b) { return in[a] < in[b]; }   void solve() {     int n;     cin >> n;     for (auto &li : e) li.clear();     for (int i = (0); i < (n - 1); ++i) {       int x, y;       cin >> x >> y;       x--, y--;       e[x].push_back(y);       e[y].push_back(x);     }     vector<int> ch, gen;     for (int i = (0); i < (n); ++i) {       v[i] = 0;       int z;       cin >> z;       in[--z] = i;       ch.push_back(z);     }     for (int i = (0); i < (n); ++i) sort((e[i]).begin(), (e[i]).end(), cmp);     queue<int> q;     q.push(0);     v[0] = 1;     while (!q.empty()) {       int t = q.front();       q.pop();       gen.push_back(t);       for (auto to : e[t]) {         if (v[to]) continue;         v[to] = 1;         q.push(to);       }     }     for (int i = (0); i < (n); ++i)       if (gen[i] != ch[i]) {         puts( No );         return;       }     puts( Yes );   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     solve();     return 0;   }   