#include <bits/stdc++.h>
using namespace std;
const long long Maxn = 505, Inf = 0x3f3f3f3f3f3f3f3f, Sub = 1000000000;
inline long long read() {
  char c;
  long long rec = 0;
  while ((c = getchar()) < '0' || c > '9')
    ;
  while (c >= '0' && c <= '9') rec = rec * 10 + c - '0', c = getchar();
  return rec;
}
long long n, m, val[Maxn];
struct Branch {
  long long next, to;
};
struct Tree {
  long long root, lim[Maxn];
  Branch branch[Maxn << 1];
  long long h[Maxn], cnt;
  inline void add(long long x, long long y) {
    branch[++cnt].to = y;
    branch[cnt].next = h[x];
    h[x] = cnt;
    return;
  }
  long long size[Maxn];
  inline void Dfs(long long v, long long pre) {
    size[v] = 1;
    for (long long i = h[v]; i; i = branch[i].next) {
      long long j = branch[i].to;
      if (j == pre) continue;
      Dfs(j, v);
      size[v] += size[j];
    }
    return;
  }
} rT, bT;
long long ecnt = 0;
struct Edge {
  long long fr, to, l, r, c;
} edge[Maxn * 10];
namespace Mcf {
const long long N = Maxn * 10;
struct Hose {
  long long fr, next, to, flow, cost;
} hose[N << 2];
long long h[N], cnt = 1;
inline void add(long long x, long long y, long long z, long long k) {
  hose[++cnt].to = y;
  hose[cnt].next = h[x];
  h[x] = cnt;
  hose[cnt].flow = z;
  hose[cnt].cost = k;
  hose[cnt].fr = x;
  hose[++cnt].to = x;
  hose[cnt].next = h[y];
  h[y] = cnt;
  hose[cnt].flow = 0;
  hose[cnt].cost = -k;
  hose[cnt].fr = y;
  return;
}
long long redlt = 0;
long long Sz, S, T, st, ed;
void Build_Graph() {
  for (long long i = 1; i <= ecnt; ++i) {
    Edge &e = edge[i];
    if (e.r != e.l) add(e.fr, e.to, e.r - e.l, e.c);
    if (e.l) add(e.fr, e.to, e.l, e.c - Sub);
  }
  return;
}
long long Mxc = 0;
queue<long long> q;
long long dis[N], vis[N], prep[N], pree[N];
inline bool Spfa() {
  memset(dis, 0x3f, sizeof(long long) * Sz);
  memset(prep, 0, sizeof(long long) * Sz);
  memset(vis, 0, sizeof(long long) * Sz);
  dis[st] = 0;
  vis[st] = 1;
  q.push(st);
  while (!q.empty()) {
    long long v = q.front();
    q.pop();
    vis[v] = 0;
    for (long long i = h[v]; i; i = hose[i].next) {
      long long j = hose[i].to;
      if (hose[i].flow && dis[j] > dis[v] + hose[i].cost) {
        prep[j] = v;
        pree[j] = i;
        dis[j] = dis[v] + hose[i].cost;
        if (!vis[j]) {
          vis[j] = 1;
          q.push(j);
        }
      }
    }
  }
  if (dis[ed] == Inf) return 0;
  long long Minn = Inf;
  for (long long i = ed; i != st; i = prep[i])
    Minn = min(Minn, hose[pree[i]].flow);
  Mxc += Minn * dis[ed];
  for (long long i = ed; i != st; i = prep[i])
    hose[pree[i]].flow -= Minn, hose[pree[i] ^ 1].flow += Minn;
  return 1;
}
long long MfMc() {
  while (Spfa())
    ;
  return Mxc + redlt * Sub;
}
void init(long long _st, long long _ed, long long _Sz) {
  Mxc = 0;
  st = _st;
  ed = _ed;
  Sz = _Sz;
  return;
}
}  // namespace Mcf
void Build_first(long long v, long long pre, Tree &T) {
  edge[++ecnt] = (Edge){v, v + n, 0, 1, val[v]};
  for (long long i = T.h[v]; i; i = T.branch[i].next) {
    long long j = T.branch[i].to;
    if (j == pre) continue;
    Build_first(j, v, T);
  }
  if (pre) {
    if (T.lim[v]) {
      edge[++ecnt] = (Edge){pre, v, T.lim[v], T.lim[v], 0};
      Mcf::redlt += T.lim[v];
    } else {
      edge[++ecnt] = (Edge){pre, v, 0, T.size[v], 0};
    }
  }
  return;
}
void Build_second(long long v, long long pre, Tree &T) {
  if (pre) {
    if (T.lim[v]) {
      edge[++ecnt] = (Edge){v + 2 * n, pre + 2 * n, T.lim[v], T.lim[v], 0};
      Mcf::redlt += T.lim[v];
    } else {
      edge[++ecnt] = (Edge){v + 2 * n, pre + 2 * n, 0, T.size[v], 0};
    }
  }
  for (long long i = T.h[v]; i; i = T.branch[i].next) {
    long long j = T.branch[i].to;
    if (j == pre) continue;
    Build_second(j, v, T);
  }
  edge[++ecnt] = (Edge){v + n, v + 2 * n, 0, 1, 0};
  return;
}
int main() {
  n = read();
  rT.root = read();
  bT.root = read();
  for (long long i = 1; i <= n; ++i) val[i] = -read();
  for (long long i = 1; i < n; ++i) {
    long long x = read(), y = read();
    rT.add(x, y);
    rT.add(y, x);
  }
  rT.Dfs(rT.root, 0);
  for (long long i = 1; i < n; ++i) {
    long long x = read(), y = read();
    bT.add(x, y);
    bT.add(y, x);
  }
  bT.Dfs(bT.root, 0);
  m = read();
  for (long long i = 1; i <= m; ++i) {
    long long x = read(), y = read();
    rT.lim[x] = y;
  }
  m = read();
  for (long long i = 1; i <= m; ++i) {
    long long x = read(), y = read();
    bT.lim[x] = y;
  }
  if (rT.lim[rT.root] != bT.lim[bT.root]) {
    puts("-1");
    return 0;
  }
  long long s = 0, t = 3 * n + 1, SZ = t + 1;
  Mcf::init(s, t, SZ);
  Build_first(rT.root, 0, rT);
  edge[++ecnt] = (Edge){s, rT.root, rT.lim[rT.root], rT.lim[rT.root], 0};
  Mcf::redlt += rT.lim[rT.root];
  Build_second(bT.root, 0, bT);
  edge[++ecnt] =
      (Edge){bT.root + n * 2, t, bT.lim[bT.root], bT.lim[bT.root], 0};
  Mcf::redlt += bT.lim[bT.root];
  Mcf::Build_Graph();
  long long ans = Mcf::MfMc();
  if (ans >= 0)
    puts("-1");
  else
    cout << -ans;
  return 0;
}
