func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename T>   T gcd(T x, T y) {     if (x < y) swap(x, y);     while (y > 0) {       T f = x % y;       x = y;       y = f;     }     return x;   }   const int maxn = 200005;   int n;   int a[maxn];   int dp[maxn];   vector<int> adj[maxn];   void dfs(int u, int p, set<int> gcd0, set<int> gcd1) {     dp[u] = *gcd0.rbegin();     if (!gcd1.empty()) {       dp[u] = max(dp[u], *gcd1.rbegin());     }     for (int v : adj[u]) {       if (v != p) {         set<int> g0;         set<int> g1 = gcd0;         for (auto x : gcd0) g0.insert(gcd(x, a[v]));         for (auto x : gcd1) g1.insert(gcd(x, a[v]));         dfs(v, u, g0, g1);       }     }   }   int main(int argc, char *argv[]) {     std::cin.sync_with_stdio(false);     std::cin.tie(nullptr);     cin >> n;     {       for (int i = 1; i <= n; i++) cin >> a[i], dp[i] = i;       for (int i = 1; i < n; i++) {         int x, y;         cin >> x >> y;         adj[x].push_back(y);         adj[y].push_back(x);       }       set<int> gcd0;       set<int> gcd1;       gcd0.insert(a[1]);       gcd1.insert(0);       dfs(1, 0, gcd0, gcd1);       for (int i = 1; i <= n; i++) {         cout << dp[i] << (i == n ?   n  :    );       }     }     return 0;   }   