func_code_string: #include <bits/stdc++.h>   using namespace std;   void boost() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);   }   const int N = 2e5 + 5;   int arr[N], ans[N];   vector<int> adj[N];   vector<int> factor[2][N];   bool avail[N];   void dfs(int u, int p, int d) {     if (u != 1) {       for (auto x : factor[0][p])         if (arr[u] % x == 0)           factor[0][u].push_back(x);         else           factor[1][u].push_back(x);       for (auto x : factor[1][p])         if (arr[u] % x == 0) factor[1][u].push_back(x);     }     if (d == 2) {       for (int i = 1; i * i <= arr[u]; i++) {         if (arr[u] % i == 0) {           if (!avail[i]) factor[1][u].push_back(i);         }         if (i * i != arr[u] && (arr[u] % (arr[u] / i)) == 0) {           if (!avail[arr[u] / i]) {             factor[1][u].push_back(arr[u] / i);           }         }       }     }     for (auto x : factor[0][u]) ans[u] = max(ans[u], x);     for (auto x : factor[1][u]) ans[u] = max(ans[u], x);     for (auto v : adj[u]) {       if (v != p) dfs(v, u, d + 1);     }   }   void solve() {     int n;     cin >> n;     for (int i = 1; i < n + 1; ++i) {       cin >> arr[i];     }     int u, v;     for (int i = 0; i < n - 1; ++i) {       cin >> u >> v;       adj[u].push_back(v);       adj[v].push_back(u);     }     for (int i = 1; i * i <= arr[1]; i++) {       if (arr[1] % i == 0) {         factor[0][1].push_back(i);         avail[i] = true;       }       if (i * i != arr[1] && (arr[1] % (arr[1] / i)) == 0) {         factor[0][1].push_back(arr[1] / i);         avail[arr[1] / i] = true;       }     }     dfs(1, 0, 1);     for (int i = 1; i < n + 1; ++i) {       cout << ans[i] <<    ;     }     return;   }   int main() {     boost();     int tc = 1;     while (tc--) solve();     return 0;   }   