#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int MX = 1000 + 7;
const int ME = 1e4 + 5;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
struct MCMF {
  int S, T;
  int tot, n;
  int st, en, maxflow, mincost;
  bool vis[MX];
  int head[MX], cur[MX], dis[MX];
  queue<int> Q;
  struct Edge {
    int v, cap, cost, nxt, flow;
    Edge() {}
    Edge(int a, int b, int c, int d) {
      v = a, cap = b, cost = c, nxt = d, flow = 0;
    }
  } E[ME], SE[ME];
  void init(int _n) {
    n = _n, tot = 0;
    for (int i = 0; i <= n; i++) head[i] = -1;
  }
  void edge_add(int u, int v, int cap, int cost) {
    E[tot] = Edge(v, cap, cost, head[u]);
    head[u] = tot++;
    E[tot] = Edge(u, 0, -cost, head[v]);
    head[v] = tot++;
  }
  bool adjust() {
    int v, min = INF;
    for (int i = 0; i <= n; i++) {
      if (!vis[i]) continue;
      for (int j = head[i]; ~j; j = E[j].nxt) {
        v = E[j].v;
        if (E[j].cap - E[j].flow) {
          if (!vis[v] && dis[v] - dis[i] + E[j].cost < min) {
            min = dis[v] - dis[i] + E[j].cost;
          }
        }
      }
    }
    if (min == INF) return false;
    for (int i = 0; i <= n; i++) {
      if (vis[i]) {
        cur[i] = head[i];
        vis[i] = false;
        dis[i] += min;
      }
    }
    return true;
  }
  int augment(int i, int flow) {
    if (i == en) {
      mincost += dis[st] * flow;
      maxflow += flow;
      return flow;
    }
    vis[i] = true;
    for (int j = cur[i]; j != -1; j = E[j].nxt) {
      int v = E[j].v;
      if (E[j].cap == E[j].flow) continue;
      if (vis[v] || dis[v] + E[j].cost != dis[i]) continue;
      int delta = augment(v, std::min(flow, E[j].cap - E[j].flow));
      if (delta) {
        E[j].flow += delta;
        E[j ^ 1].flow -= delta;
        cur[i] = j;
        return delta;
      }
    }
    return 0;
  }
  void spfa() {
    int u, v;
    for (int i = 0; i <= n; i++) {
      vis[i] = false;
      dis[i] = INF;
    }
    Q.push(st);
    dis[st] = 0;
    vis[st] = true;
    while (!Q.empty()) {
      u = Q.front(), Q.pop();
      vis[u] = false;
      for (int i = head[u]; ~i; i = E[i].nxt) {
        v = E[i].v;
        if (E[i].cap == E[i].flow || dis[v] <= dis[u] + E[i].cost) continue;
        dis[v] = dis[u] + E[i].cost;
        if (!vis[v]) {
          vis[v] = true;
          Q.push(v);
        }
      }
    }
    for (int i = 0; i <= n; i++) {
      dis[i] = dis[en] - dis[i];
    }
  }
  int zkw(int s, int t, int &ret_flow) {
    st = s, en = t;
    spfa();
    mincost = maxflow = 0;
    for (int i = 0; i <= n; i++) {
      vis[i] = false;
      cur[i] = head[i];
    }
    do {
      while (augment(st, INF)) {
        memset(vis, false, n * sizeof(bool));
      }
    } while (adjust());
    ret_flow = maxflow;
    return mincost;
  }
} F;
int n, x, y;
int val[MX];
bool flag;
vector<int> G[MX];
int limt[MX], pre[MX];
int dfs(int u, int fa, int f) {
  if (limt[u]) f = u;
  pre[u] = f;
  int res = 0, now = limt[u];
  for (auto v : G[u]) {
    if (v == fa) continue;
    res += dfs(v, u, f);
  }
  if (limt[u]) {
    if (limt[u] < res) flag = 0;
    limt[u] -= res;
    res = now;
  }
  return res;
}
int main() {
  scanf("%d%d%d", &n, &x, &y);
  for (int i = 1; i <= n; i++) scanf("%d", &val[i]);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u + n].push_back(v + n);
    G[v + n].push_back(u + n);
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int k, x;
    scanf("%d%d", &k, &x);
    limt[k] = x;
  }
  scanf("%d", &q);
  while (q--) {
    int k, x;
    scanf("%d%d", &k, &x);
    limt[k + n] = x;
  }
  flag = 1;
  dfs(x, 0, x);
  dfs(y + n, 0, y + n);
  int S = 0, T = 2 * n + 1;
  F.init(2 * n + 2);
  int sum1 = 0, sum2 = 0;
  for (int i = 1; i <= n; i++)
    if (limt[i]) F.edge_add(S, i, limt[i], 0), sum1 += limt[i];
  for (int i = 1; i <= n; i++)
    if (limt[i + n]) F.edge_add(i + n, T, limt[i + n], 0), sum2 += limt[i + n];
  for (int i = 1; i <= n; i++) F.edge_add(pre[i], pre[i + n], 1, -val[i]);
  int flow;
  int ans = -F.zkw(S, T, flow);
  if (sum1 != sum2 || flow != sum1) flag = 0;
  if (!flag)
    puts("-1");
  else
    printf("%d\n", ans);
  return 0;
}
