#include <bits/stdc++.h>
using namespace std;
char buf[1 << 20], *p1, *p2;
template <class T>
inline void read(T &n) {
  char ch =
      (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2)
           ? 0
           : *p1++);
  T w = 1, x = 0;
  while (!isdigit(ch)) {
    if (ch == '-') w = -1;
    ch =
        (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2)
             ? 0
             : *p1++);
  }
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch =
        (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2)
             ? 0
             : *p1++);
  }
  n = x * w;
}
const int maxn = 1005;
int n, m, rt1, rt2, W[maxn], num[maxn];
vector<int> out[maxn];
int bel[maxn];
int dfs(int x, int fa) {
  if (num[x])
    bel[x] = x;
  else
    bel[x] = bel[fa];
  int tot = 0;
  for (auto v : out[x])
    if (v != fa) tot += dfs(v, x);
  if (!num[x]) return tot;
  if (num[x] < tot) puts("-1"), exit(0);
  num[x] -= tot;
  return num[x] + tot;
}
int last[maxn], Next[maxn << 3], to[maxn << 3], w[maxn << 3], dis[maxn << 3],
    cnt = 1;
inline void addedge(int x, int y, int z, int d) {
  Next[++cnt] = last[x], last[x] = cnt;
  to[cnt] = y, w[cnt] = z, dis[cnt] = d;
}
inline void add(int x, int y, int z, int d) {
  addedge(x, y, z, d), addedge(y, x, 0, -d);
}
int st, ed, Dis[maxn], flow[maxn], pre[maxn], vis[maxn];
const int inf = 0x3f3f3f3f;
queue<int> Q;
bool spfa() {
  memset(Dis, -0x3f, sizeof(Dis));
  Dis[st] = pre[ed] = 0;
  flow[st] = inf;
  Q.push(st);
  while (!Q.empty()) {
    int u = Q.front();
    vis[u] = 0, Q.pop();
    for (int i = last[u]; i; i = Next[i]) {
      int v = to[i];
      if (w[i] && Dis[v] < Dis[u] + dis[i]) {
        Dis[v] = Dis[u] + dis[i];
        flow[v] = min(flow[u], w[i]);
        if (!vis[v]) vis[v] = 1, Q.push(v);
        pre[v] = i;
      }
    }
  }
  return pre[ed];
}
int EK() {
  int res = 0;
  while (spfa()) {
    res += flow[ed] * Dis[ed];
    for (int i = ed; i != st; i = to[pre[i] ^ 1]) {
      w[pre[i]] -= flow[ed];
      w[pre[i] ^ 1] += flow[ed];
    }
  }
  for (int i = last[st]; i; i = Next[i])
    if (w[i]) puts("-1"), exit(0);
  for (int i = last[ed]; i; i = Next[i])
    if (w[i ^ 1]) puts("-1"), exit(0);
  return res;
}
int main() {
  read(n), read(rt1), read(rt2), rt2 += n;
  for (int i = 1; i <= n; i++) read(W[i]);
  for (int i = 1, x, y; i < n; i++) {
    read(x), read(y);
    out[x].push_back(y);
    out[y].push_back(x);
  }
  for (int i = 1, x, y; i < n; i++) {
    read(x), read(y);
    out[x + n].push_back(y + n);
    out[y + n].push_back(x + n);
  }
  read(m);
  for (int i = 1, x; i <= m; i++) read(x), read(num[x]);
  read(m);
  for (int i = 1, x; i <= m; i++) read(x), read(num[x + n]);
  dfs(rt1, 0), dfs(rt2, 0);
  ed = n * 2 + 1;
  for (int i = 1; i <= n; i++)
    if (num[i]) add(st, i, num[i], 0);
  for (int i = 1; i <= n; i++)
    if (num[i + n]) add(i + n, ed, num[i + n], 0);
  for (int i = 1; i <= n; i++)
    if (bel[i] && bel[i + n]) add(bel[i], bel[i + n], 1, W[i]);
  cout << EK() << endl;
  return 0;
}
