func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, q, fa[50005], ff[50005], h[50005], tot, e[50005 << 1], nxt[50005 << 1],       mx[50005][256], cnt[50005][256], Ans[50005][256], ans, val[50005],       dep[50005];   template <class T>   inline void read(T &x) {     x = 0;     bool emm = 1;     char c;     for (c = getchar(); c <  0  || c >  9 ; c = getchar())       if (c ==  - ) emm = -1;     for (; c >=  0  && c <=  9 ; c = getchar()) x = (x << 1) + (x << 3) + c -  0 ;     x *= emm;   }   inline void add(int x, int y) { e[++tot] = y, nxt[tot] = h[x], h[x] = tot; }   inline void dfs(int x) {     dep[x] = dep[fa[x]] + 1;     int i;     if (dep[x] >= 256) {       int l, r, mid, s;       for (i = x; dep[x] - dep[i] < 256; i = fa[i]) {         mx[x][val[i] >> 8] =             max(mx[x][val[i] >> 8], (dep[x] - dep[i] ^ val[i]) & 255);         cnt[x][val[i] >> 8]++;       }       ff[x] = i;       for (i = 1; i < 256; i++) cnt[x][i] += cnt[x][i - 1];       for (i = 0; i <= (n - 1) / 256; i++) {         for (l = s = 0, r = 256, mid = r >> 1; l < r - 1; mid = l + r >> 1) {           if ((s ^ i) < mid) {             if (cnt[x][r - 1] > cnt[x][mid - 1])               s |= r - mid, l = mid;             else               r = mid;           } else {             if (cnt[x][mid - 1] > ((l) ? cnt[x][l - 1] : 0))               s |= r - mid, r = mid;             else               l = mid;           }         }         Ans[x][i] = (s << 8) | mx[x][l];       }     }     for (i = h[x]; i; i = nxt[i])       if (e[i] != fa[x]) fa[e[i]] = x, dfs(e[i]);   }   int main() {     read(n), read(q);     for (int i = 1; i <= n; i++) read(val[i]);     for (int x, y, i = 1; i < n; i++) read(x), read(y), add(x, y), add(y, x);     for (dfs(1); q--;) {       int u, v, dis;       read(u), read(v);       for (dis = ans = 0; dep[v] - dep[u] >= 256; v = ff[v], dis++)         ans = max(ans, Ans[v][dis]);       for (dis <<= 8; v != fa[u]; v = fa[v], dis++) ans = max(ans, dis ^ val[v]);       printf( %d n , ans);     }     return 0;   }   