#include <bits/stdc++.h>
using std::pair;
using std::string;
using std::vector;
template <typename T>
bool chkmax(T& a, T b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
bool chkmin(T& a, T b) {
  return a > b ? a = b, 1 : 0;
}
const int oo = 0x3f3f3f3f;
string procStatus() {
  std::ifstream t("/proc/self/status");
  return string(std::istreambuf_iterator<char>(t),
                std::istreambuf_iterator<char>());
}
template <typename T>
T read(T& x) {
  int f = 1;
  x = 0;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
  return x *= f;
}
const int N = 1500;
const int M = 100000;
int S, T;
namespace costflow {
struct edge {
  int to, nxt, cap, cost;
};
edge e[M + 5];
int st[N + 5], ecnt = 1;
void addedge(int u, int v, int w, int c) {
  e[++ecnt] = (edge){v, st[u], c, w};
  st[u] = ecnt;
  e[++ecnt] = (edge){u, st[v], 0, -w};
  st[v] = ecnt;
}
bool inq[N + 5];
int flow[N + 5], dis[N + 5], pre[N + 5];
bool spfa(int& ans, int& flo) {
  std::queue<int> que;
  memset(dis, ~oo, sizeof dis);
  dis[S] = 0;
  flow[S] = oo;
  que.push(S);
  while (!que.empty()) {
    int x = que.front();
    que.pop();
    inq[x] = false;
    if (x == T) continue;
    for (int i = st[x]; i; i = e[i].nxt)
      if (e[i].cap) {
        int y = e[i].to;
        if (chkmax(dis[y], dis[x] + e[i].cost)) {
          pre[y] = i;
          flow[y] = std::min(flow[x], e[i].cap);
          if (!inq[y]) {
            que.push(y);
            inq[y] = true;
          }
        }
      }
  }
  if (dis[T] <= -oo) return false;
  flo += flow[T];
  ans += flow[T] * dis[T];
  for (int i = T; i != S; i = e[pre[i] ^ 1].to) {
    e[pre[i]].cap -= flow[T];
    e[pre[i] ^ 1].cap += flow[T];
  }
  return true;
}
pair<int, int> mcmf() {
  int ans = 0, flo = 0;
  while (spfa(ans, flo))
    ;
  return std::make_pair(ans, flo);
}
}  // namespace costflow
int w[N + 5];
int n, rta, rtb;
int lima[N + 5], limb[N + 5];
vector<int> GA[N + 5], GB[N + 5];
int dfs1(int x, int f) {
  costflow::addedge(x, x + n, w[x], 1);
  int val = 0;
  for (auto y : GA[x])
    if (y != f) {
      val += dfs1(y, x);
    }
  if (lima[x] == -1)
    costflow::addedge(f, x, 0, oo);
  else {
    if (lima[x] < val) {
      puts("-1");
      exit(0);
    }
    costflow::addedge(S, x, 0, lima[x] - val);
  }
  return (lima[x] >= 0) ? lima[x] : val;
}
int dfs2(int x, int f) {
  int val = 0;
  for (auto y : GB[x])
    if (y != f) {
      val += dfs2(y, x);
    }
  if (limb[x] == -1)
    costflow::addedge(x + n, f + n, 0, oo);
  else {
    if (limb[x] < val) {
      puts("-1");
      exit(0);
    }
    costflow::addedge(x + n, T, 0, limb[x] - val);
  }
  return (limb[x] >= 0) ? limb[x] : val;
}
int main() {
  read(n), read(rta), read(rtb);
  for (int i = 1; i <= n; ++i) read(w[i]);
  for (int i = 1; i < n; ++i) {
    static int u, v;
    read(u), read(v);
    GA[u].push_back(v), GA[v].push_back(u);
  }
  for (int i = 1; i < n; ++i) {
    static int u, v;
    read(u), read(v);
    GB[u].push_back(v), GB[v].push_back(u);
  }
  S = 2 * n + 1, T = S + 1;
  memset(lima, -1, sizeof lima);
  memset(limb, -1, sizeof limb);
  int k, a, b;
  for (read(k); k--;) {
    read(a), read(b);
    lima[a] = b;
  }
  for (read(k); k--;) {
    read(a), read(b);
    limb[a] = b;
  }
  dfs1(rta, 0);
  dfs2(rtb, 0);
  pair<int, int> ans = costflow::mcmf();
  if (ans.second != lima[rta] || ans.second != limb[rtb])
    puts("-1");
  else
    printf("%d\n", ans.first);
  return 0;
}
