#include <bits/stdc++.h>
using namespace std;
const int N = 505, M = 1000005;
int n, m, x, y, z, in, ou, v[N], S, T, ans, rta, rtb, tg[N << 1], tp[N << 1],
    he[N << 1], to[M], ne[M], w[M], c[M], cnt, dis[N << 1], pp[N << 1],
    pe[N << 1], inq[N << 1];
void fk() {
  printf("-1");
  exit(0);
}
void add(int u, int v, int f, int s) {
  to[++cnt] = v;
  ne[cnt] = he[u];
  he[u] = cnt;
  w[cnt] = f;
  c[cnt] = s;
  to[++cnt] = u;
  ne[cnt] = he[v];
  he[v] = cnt;
  w[cnt] = 0;
  c[cnt] = -s;
}
int dfs(int x, int fa, int tpo) {
  int t, re = 0;
  if (tg[x]) tpo = x;
  tp[x] = tpo;
  for (int i = he[x]; i; i = ne[i])
    if (to[i] != fa) re += dfs(to[i], x, tpo);
  if (tg[x]) {
    t = tg[x];
    tg[x] -= re;
    if (tg[x] < 0) fk();
    re = t;
  }
  return re;
}
struct nod {
  int id, v;
  bool operator<(const nod& g) const { return v < g.v; }
};
queue<int> q;
int spfa() {
  memset(dis, 0x3f, sizeof(dis));
  dis[S] = 0;
  q.push(S);
  inq[S] = 1;
  for (; q.size();) {
    int x = q.front();
    q.pop();
    for (int i = he[x], y; i; i = ne[i]) {
      y = to[i];
      if ((!w[i]) || dis[y] <= dis[x] + c[i]) continue;
      dis[y] = dis[x] + c[i];
      pp[y] = x;
      pe[y] = i;
      if (!inq[y]) q.push(y), inq[y] = 1;
    }
    inq[x] = 0;
  }
  return (dis[T] < 1e9);
}
int main() {
  scanf("%d%d%d", &n, &rta, &rtb);
  S = (n << 1) + 1;
  T = S + 1;
  rtb += n;
  for (int i = 1; i <= n; ++i) scanf("%d", &v[i]);
  for (int i = 1; i < n; ++i) scanf("%d%d", &x, &y), add(x, y, 0, 0);
  for (int i = 1; i < n; ++i) scanf("%d%d", &x, &y), add(x + n, y + n, 0, 0);
  for (scanf("%d", &z); z; --z) scanf("%d%d", &x, &y), tg[x] = y;
  for (scanf("%d", &z); z; --z) scanf("%d%d", &x, &y), tg[x + n] = y;
  dfs(rta, 0, rta);
  dfs(rtb, 0, rtb);
  memset(he, 0, sizeof(he));
  cnt = 1;
  for (int i = 1; i <= n; ++i)
    if (tg[i]) add(S, i, tg[i], 0), in += tg[i];
  for (int i = n + 1; i <= n + n; ++i)
    if (tg[i]) add(i, T, tg[i], 0), ou += tg[i];
  if (in != ou) fk();
  for (int i = 1; i <= n; ++i) add(tp[i], tp[i + n], 1, -v[i]);
  for (z = 1e9; spfa();) {
    for (int x = T; x != S; x = pp[x]) z = min(z, w[pe[x]]);
    for (int x = T; x != S; x = pp[x]) w[pe[x]] -= z, w[pe[x] ^ 1] += z;
    ans -= z * dis[T];
    in -= z;
  }
  if (in != 0) fk();
  printf("%d", ans);
}
