#include <bits/stdc++.h>
const int maxN = 505, maxV = maxN + maxN + 5, maxE = 1000005;
struct edge_t {
  int to, i, w;
  edge_t *next;
} * Head[maxV], edgeBuf[maxE], *edgeCur(edgeBuf);
int edgeCnt, Cap[maxE], S, T;
inline void __addEdge(int u, int v, int c, int w) {
  *edgeCur = (edge_t){v, edgeCnt, w, Head[u]};
  Head[u] = edgeCur++;
  Cap[edgeCnt++] = c;
}
inline void addEdge(int u, int v, int c, int w) {
  __addEdge(u, v, c, w);
  __addEdge(v, u, 0, -w);
}
int Dis[maxV], From[maxV], Pre[maxV];
bool Inq[maxV];
bool SPFA() {
  std::queue<int> q;
  std::fill(Dis, Dis + T + 1, -0x3F3F3F3F);
  Dis[S] = 0, q.push(S), Inq[S] = true;
  while (!q.empty()) {
    int i = q.front();
    q.pop(), Inq[i] = false;
    for (edge_t *j = Head[i]; j; j = j->next)
      if (Dis[j->to] < Dis[i] + j->w && Cap[j->i]) {
        Dis[j->to] = Dis[i] + j->w;
        From[j->to] = j->i, Pre[j->to] = i;
        if (!Inq[j->to]) Inq[j->to] = true, q.push(j->to);
      }
  }
  return Dis[T] != -0x3F3F3F3F;
}
int N, X, Y, W[maxN], Q;
std::vector<int> G1[maxN], G2[maxN];
int Cnt1[maxN], Cnt2[maxN];
void DFS1(int i, int f, int top) {
  if (Cnt1[i] != 0x7F7F7F7F) {
    Cnt1[top] -= Cnt1[i];
    top = i;
  }
  addEdge(top, i, 1, 0);
  for (auto to : G1[i])
    if (to != f) DFS1(to, i, top);
}
void DFS2(int i, int f, int top) {
  if (Cnt2[i] != 0x7F7F7F7F) {
    Cnt2[top] -= Cnt2[i];
    top = i;
  }
  addEdge(i + N, top + N, 1, 0);
  for (auto to : G2[i])
    if (to != f) DFS2(to, i, top);
}
int main() {
  scanf("%d%d%d", &N, &X, &Y);
  for (int i = 1; i <= N; ++i) scanf("%d", W + i);
  for (int u, v, i = 1; i != N; ++i) {
    scanf("%d%d", &u, &v);
    G1[u].push_back(v), G1[v].push_back(u);
  }
  for (int u, v, i = 1; i != N; ++i) {
    scanf("%d%d", &u, &v);
    G2[u].push_back(v), G2[v].push_back(u);
  }
  memset(Cnt1, 0x7F, sizeof(Cnt1));
  memset(Cnt2, 0x7F, sizeof(Cnt2));
  scanf("%d", &Q);
  for (int a, b; Q--;) {
    scanf("%d%d", &a, &b);
    assert(1 <= a && a <= N);
    assert(0 <= b && b <= N);
    Cnt1[a] = b;
  }
  scanf("%d", &Q);
  for (int a, b; Q--;) {
    scanf("%d%d", &a, &b);
    assert(1 <= a && a <= N);
    assert(0 <= b && b <= N);
    Cnt2[a] = b;
  }
  S = 0, T = 2 * N + 1;
  DFS1(X, 0, 0);
  DFS2(Y, 0, 0);
  for (int i = 1; i <= N; ++i) {
    addEdge(i, i + N, 1, W[i]);
    if (Cnt1[i] != 0x7F7F7F7F) {
      if (Cnt1[i] < 0) {
        puts("-1");
        return 0;
      }
      addEdge(S, i, Cnt1[i], 0);
    }
    if (Cnt2[i] != 0x7F7F7F7F) {
      if (Cnt2[i] < 0) {
        puts("-1");
        return 0;
      }
      addEdge(i + N, T, Cnt2[i], 0);
    }
  }
  int ans = 0;
  while (SPFA()) {
    int flow = 0x7F7F7F7F;
    for (int i = T; i != S; i = Pre[i]) flow = std::min(flow, Cap[From[i]]);
    ans += Dis[T] * flow;
    for (int i = T; i != S; i = Pre[i])
      Cap[From[i]] -= flow, Cap[From[i] ^ 1] += flow;
  }
  for (edge_t *j = Head[S]; j; j = j->next)
    if (Cap[j->i]) {
      puts("-1");
      return 0;
    }
  for (edge_t *j = Head[T]; j; j = j->next)
    if (Cap[j->i ^ 1]) {
      puts("-1");
      return 0;
    }
  printf("%d\n", ans);
  return 0;
}
