#include <bits/stdc++.h>
template <class T>
inline void read(T &res) {
  char ch;
  bool flag = false;
  res = 0;
  while (ch = getchar(), !isdigit(ch) && ch != '-')
    ;
  ch == '-' ? flag = true : res = ch ^ 48;
  while (ch = getchar(), isdigit(ch)) res = res * 10 + ch - 48;
  flag ? res = -res : 0;
}
using std::vector;
const int N = 1005;
const int M = 1e6 + 5;
const int Maxn = 0x3f3f3f3f;
int T = 1, n, src, des, ans, Q1, Q0, rtx, rty;
bool vis[N], walk[N];
int fa1[N], fa2[N], w[N], dis[N];
int h[M], lim1[N], lim2[N];
int tag1[N], tag2[N], lst[N], nxt[M], cst[M], to[M], flw[M];
vector<int> v1[N], v2[N];
inline void Link(int x, int y, int z, int w) {
  nxt[++T] = lst[x];
  lst[x] = T;
  to[T] = y;
  flw[T] = z;
  cst[T] = w;
  nxt[++T] = lst[y];
  lst[y] = T;
  to[T] = x;
  flw[T] = 0;
  cst[T] = -w;
}
inline bool SPFA() {
  for (int i = 1; i <= des; ++i) dis[i] = Maxn, walk[i] = false;
  dis[h[1] = src] = 0;
  int t = 0, w = 1, x, y;
  while (t < w) {
    vis[x = h[++t]] = false;
    for (int e = lst[x]; e; e = nxt[e])
      if (y = to[e], flw[e] > 0 && dis[y] > dis[x] + cst[e]) {
        dis[y] = dis[x] + cst[e];
        if (!vis[y]) vis[h[++w] = y] = true;
      }
  }
  return dis[des] < Maxn;
}
template <class T>
inline T Min(T x, T y) {
  return x < y ? x : y;
}
inline int Dinic(int x, int flow) {
  if (x == des) {
    ans += flow * dis[des];
    return flow;
  }
  walk[x] = true;
  int y, del, res = 0;
  for (int e = lst[x]; e; e = nxt[e])
    if (y = to[e], !walk[y] && flw[e] > 0 && dis[y] == dis[x] + cst[e]) {
      del = Dinic(y, Min(flow - res, flw[e]));
      if (del) {
        flw[e] -= del;
        flw[e ^ 1] += del;
        res += del;
        if (flow == res) break;
      }
    }
  return res;
}
inline void MCMF() {
  int res = 0;
  while (SPFA()) res += Dinic(src, Maxn);
}
inline void Dfs1(int x) {
  int tot = 0;
  for (int i = 0, im = v1[x].size(); i < im; ++i) {
    int y = v1[x][i];
    if (y == fa1[x]) continue;
    fa1[y] = x;
    Dfs1(y);
  }
}
inline void Dfs2(int x) {
  for (int i = 0, im = v2[x].size(); i < im; ++i) {
    int y = v2[x][i];
    if (y == fa2[x]) continue;
    fa2[y] = x;
    Dfs2(y);
  }
}
inline void Dfs3(int x, int &v) {
  for (int i = 0, im = v1[x].size(); i < im; ++i) {
    int y = v1[x][i];
    if (y == fa1[x]) continue;
    if (tag1[y] != Maxn) {
      v -= tag1[y];
      continue;
    }
    Dfs3(y, v);
  }
}
inline void Dfs4(int x, int &v) {
  for (int i = 0, im = v2[x].size(); i < im; ++i) {
    int y = v2[x][i];
    if (y == fa2[x]) continue;
    if (tag2[y] != Maxn) {
      v -= tag2[y];
      continue;
    }
    Dfs4(y, v);
  }
}
int main() {
  read(n);
  read(rtx);
  read(rty);
  src = n << 1 | 1;
  des = src + 1;
  for (int i = 1; i <= n; ++i) read(w[i]);
  for (int i = 1, x, y; i < n; ++i) {
    read(x);
    read(y);
    v1[x].push_back(y);
    v1[y].push_back(x);
  }
  for (int i = 1, x, y; i < n; ++i) {
    read(x);
    read(y);
    v2[x].push_back(y);
    v2[y].push_back(x);
  }
  for (int i = 1; i <= n; ++i) tag1[i] = tag2[i] = Maxn;
  read(Q0);
  for (int i = 1, x, y; i <= Q0; ++i) {
    read(x);
    read(y);
    tag1[x] = y;
  }
  read(Q1);
  for (int i = 1, x, y; i <= Q1; ++i) {
    read(x);
    read(y);
    tag2[x] = y;
  }
  Dfs1(rtx);
  Dfs2(rty);
  for (int i = 1; i <= n; ++i) lim1[i] = tag1[i], lim2[i] = tag2[i];
  for (int i = 1; i <= n; ++i)
    if (lim1[i] != Maxn) Dfs3(i, lim1[i]);
  for (int i = 1; i <= n; ++i)
    if (lim2[i] != Maxn) Dfs4(i, lim2[i]);
  for (int i = 1; i <= n; ++i)
    if (lim1[i] < 0 || lim2[i] < 0) return puts("-1"), 0;
  for (int i = 1; i <= n; ++i) {
    int u, v;
    for (u = i; tag1[u] == Maxn; u = fa1[u])
      ;
    for (v = i; tag2[v] == Maxn; v = fa2[v])
      ;
    Link(u, v + n, 1, -w[i]);
  }
  for (int i = 1; i <= n; ++i)
    if (lim1[i] != Maxn) Link(src, i, lim1[i], 0);
  for (int i = 1; i <= n; ++i)
    if (lim2[i] != Maxn) Link(i + n, des, lim2[i], 0);
  MCMF();
  bool flag = false;
  for (int e = lst[src]; e; e = nxt[e])
    if (flw[e] > 0) {
      flag = true;
      break;
    }
  for (int e = lst[des]; e; e = nxt[e])
    if (flw[e ^ 1] > 0) {
      flag = true;
      break;
    }
  printf("%d\n", flag ? -1 : -ans);
  return 0;
}
