#include <bits/stdc++.h>
using namespace std;
int tmm = 1, b[100010], f[100010], st[100010], en[100010], idx[100010], sq,
    pres[100010] = {0};
int par[100010][18], d[100010] = {0};
long long num[100010][2], res[100010];
vector<int> base, adj[100010];
map<int, int> mp;
pair<int, int> q[100010];
void dfs(int v, int p) {
  st[v] = tmm++;
  d[v] = d[p] + 1;
  base.push_back(v);
  par[v][0] = p;
  for (int i = 1; i < 18; ++i) {
    if ((1 << i) <= d[v])
      par[v][i] = par[par[v][i - 1]][i - 1];
    else
      par[v][i] = 0;
  }
  for (int i = 0; i < adj[v].size(); ++i) {
    int t = adj[v][i];
    if (t == p) continue;
    dfs(t, v);
  }
  base.push_back(v);
  en[v] = tmm++;
}
int LCA(int u, int v) {
  if (d[u] < d[v]) swap(u, v);
  int diff = d[u] - d[v];
  for (int i = 0; (1 << i) <= diff; ++i) {
    if (diff & (1 << i)) {
      u = par[u][i];
    }
  }
  if (u == v) return u;
  for (int i = 18 - 1; i >= 0; --i) {
    if (par[u][i] != par[v][i]) {
      u = par[u][i];
      v = par[v][i];
    }
  }
  return par[u][0];
}
bool compr(int i, int j) {
  if (q[i].first / sq != q[j].first / sq)
    return (q[i].first / sq < q[j].first / sq);
  return q[i].second < q[j].second;
}
int main() {
  base.push_back(0);
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", b + i);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", f + i);
    mp[f[i]];
  }
  int k = 1;
  for (map<int, int>::iterator it = mp.begin(); it != mp.end(); ++it) {
    it->second = k++;
  }
  for (int i = 1; i <= n; ++i) {
    f[i] = mp[f[i]];
  }
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  d[0] = -1;
  dfs(1, 0);
  sq = sqrt(base.size() - 1);
  int Q;
  scanf("%d", &Q);
  for (int i = 0; i < Q; ++i) {
    scanf("%d %d", &q[i].first, &q[i].second);
    if (st[q[i].first] > st[q[i].second]) swap(q[i].first, q[i].second);
    q[i].first =
        (en[q[i].first] < st[q[i].second]) ? en[q[i].first] : st[q[i].first];
    q[i].second = st[q[i].second];
    idx[i] = i;
  }
  sort(idx, idx + Q, compr);
  int currL = 1, currR = 0;
  long long ans = 0;
  for (int i = 0; i < Q; ++i) {
    int u = q[idx[i]].first, v = q[idx[i]].second;
    int lca = LCA(base[u], base[v]);
    while (currR < v) {
      ++currR;
      int no = base[currR];
      int cnt = ++pres[no];
      if (cnt & 1) {
        ans += num[f[no]][b[no] ^ 1];
        ++num[f[no]][b[no]];
      } else {
        ans -= num[f[no]][b[no] ^ 1];
        --num[f[no]][b[no]];
      }
    }
    while (currR > v) {
      int no = base[currR];
      int cnt = --pres[no];
      if (cnt & 1) {
        ans += num[f[no]][b[no] ^ 1];
        ++num[f[no]][b[no]];
      } else {
        ans -= num[f[no]][b[no] ^ 1];
        --num[f[no]][b[no]];
      }
      --currR;
    }
    while (currL > u) {
      --currL;
      int no = base[currL];
      int cnt = ++pres[no];
      if (cnt & 1) {
        ans += num[f[no]][b[no] ^ 1];
        ++num[f[no]][b[no]];
      } else {
        ans -= num[f[no]][b[no] ^ 1];
        --num[f[no]][b[no]];
      }
    }
    while (currL < u) {
      int no = base[currL];
      int cnt = --pres[no];
      if (cnt & 1) {
        ans += num[f[no]][b[no] ^ 1];
        ++num[f[no]][b[no]];
      } else {
        ans -= num[f[no]][b[no] ^ 1];
        --num[f[no]][b[no]];
      }
      ++currL;
    }
    res[idx[i]] = ans + ((lca != base[u]) ? num[f[lca]][b[lca] ^ 1] : 0);
  }
  for (int i = 0; i < Q; ++i) printf("%lld\n", res[i]);
  return 0;
}
