#include <bits/stdc++.h>
using namespace std;
const int MN = 1005;
const int ME = 45005;
const int INF = 0x3f3f3f3f;
int n, m, tot;
int inl, outl;
struct lp {
  int u, v, w, c, nex, f;
  lp() {}
  lp(int a, int b, int c, int d, int e, int f)
      : u(a), v(b), w(c), c(d), nex(e), f(f) {}
} cw[ME];
int vis[MN], dis[MN], pre[MN], head[MN], aa[MN];
void add_edge(int x, int y, int z, int f) {
  cw[++tot] = lp(x, y, z, f, head[x], 0);
  head[x] = tot;
  cw[++tot] = lp(y, x, -z, 0, head[y], 0);
  head[y] = tot;
}
bool spfa(int vs, int vt) {
  memset(vis, 0, sizeof(vis));
  memset(dis, 0x3f, sizeof(dis));
  memset(pre, -1, sizeof(pre));
  queue<int> Q;
  Q.push(vs);
  dis[vs] = 0;
  aa[vs] = INF;
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    vis[u] = 0;
    for (int i = head[u]; i != -1; i = cw[i].nex) {
      int v = cw[i].v, w = cw[i].w;
      if (cw[i].c > cw[i].f && dis[v] > dis[u] + w) {
        dis[v] = dis[u] + w;
        pre[v] = i;
        aa[v] = min(cw[i].c - cw[i].f, aa[u]);
        if (!vis[v]) {
          vis[v] = 1;
          Q.push(v);
        }
      }
    }
  }
  return dis[vt] != INF;
}
int MCMF(int vs, int vt) {
  int maxFlow = INF, maxCost = 0, Sum = 0;
  maxFlow = aa[vt];
  for (int i = pre[vt]; i != -1; i = pre[cw[i].u]) {
    cw[i].f += maxFlow;
    cw[i ^ 1].f -= maxFlow;
    Sum += maxFlow * cw[i].w;
  }
  inl -= maxFlow;
  maxCost = dis[vt] * maxFlow;
  return maxCost;
}
std::vector<int> mp[505][2];
int nd[505][2], disc[505][2];
int ar[505];
int flag = 1, vs, vt;
int dfs(int rt, int u, int ba, int last) {
  int sum = 0;
  disc[u][rt] = last;
  if (nd[u][rt]) disc[u][rt] = u;
  for (auto v : mp[u][rt]) {
    if (v == ba) continue;
    sum += dfs(rt, v, u, disc[u][rt]);
  }
  if (nd[u][rt]) {
    if (sum > nd[u][rt]) flag = 0;
    if (rt == 0)
      add_edge(vs, u, 0, nd[u][rt] - sum), inl += nd[u][rt] - sum;
    else
      add_edge(u + n, vt, 0, nd[u][rt] - sum), outl += nd[u][rt] - sum;
    sum = nd[u][rt];
  }
  return sum;
}
void solve() {
  tot = -1;
  memset(head, -1, sizeof(head));
  int x, y;
  scanf("%d%d%d", &n, &x, &y);
  vs = 2 * n + 1, vt = 2 * n + 2;
  for (int i = 1; i <= n; ++i) scanf("%d", &ar[i]);
  for (int i = 1, a, b; i < n; ++i) {
    scanf("%d%d", &a, &b);
    mp[a][0].push_back(b);
    mp[b][0].push_back(a);
  }
  for (int i = 1, a, b; i < n; ++i) {
    scanf("%d%d", &a, &b);
    mp[a][1].push_back(b);
    mp[b][1].push_back(a);
  }
  int k1, k2;
  scanf("%d", &k1);
  while (k1--) {
    int t, p;
    scanf("%d%d", &t, &p);
    nd[t][0] = p;
  }
  scanf("%d", &k2);
  while (k2--) {
    int t, p;
    scanf("%d%d", &t, &p);
    nd[t][1] = p;
  }
  dfs(0, x, 0, 0);
  dfs(1, y, 0, 0);
  for (int i = 1; i <= n; ++i) {
    add_edge(disc[i][0], disc[i][1] + n, -ar[i], 1);
  }
  if (inl != outl) flag = 0;
  long long ans = 0;
  while (spfa(vs, vt)) ans += MCMF(vs, vt);
  if (inl) flag = 0;
  if (flag == 0)
    printf("-1\n");
  else
    printf("%lld\n", -ans);
}
int main() {
  solve();
  return 0;
}
