#include <bits/stdc++.h>
using namespace std;
const int N = 10086;
int n, S, T, sf, ans, fa1[N], fa2[N], c1[N], c2[N], d1[N], d2[N], dis[N],
    flow[N], pre[N], e[N], f1[N], f2[N];
vector<int> g1[N], g2[N], to[N], pr[N], cap[N], c[N];
void add(int u, int v, int w, int cc) {
  pr[u].push_back(to[v].size()), pr[v].push_back(to[u].size());
  to[u].push_back(v), to[v].push_back(u);
  cap[u].push_back(w), cap[v].push_back(0);
  c[u].push_back(cc), c[v].push_back(-cc);
}
bool SPFA() {
  memset(dis, 1, sizeof dis);
  memset(flow, 0, sizeof flow);
  queue<int> q;
  q.push(S), flow[S] = 1e9;
  dis[S] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < to[u].size(); i++)
      if (cap[u][i] && dis[u] + c[u][i] < dis[to[u][i]]) {
        q.push(to[u][i]);
        dis[to[u][i]] = dis[u] + c[u][i];
        flow[to[u][i]] = min(flow[u], cap[u][i]);
        pre[to[u][i]] = u, e[to[u][i]] = i;
      }
  }
  if (!flow[T]) return 0;
  return 1;
}
void solve() {
  int u = T, x, y;
  sf += flow[T];
  ans += flow[T] * dis[T];
  while (u != S)
    y = pre[u], x = e[u], cap[y][x] -= flow[T], cap[u][pr[y][x]] += flow[T],
    u = y;
}
void dfs1(int u, int fa, int f) {
  f1[u] = fa;
  if (c1[u] == -1) {
    add(f + 500, u + 500, 1, 0);
    for (int i = 0; i < g1[u].size(); i++)
      if (g1[u][i] != fa) dfs1(g1[u][i], u, f);
  } else {
    d1[u] = c1[u], d1[f] -= c1[u];
    if (d1[f] < 0) puts("-1"), exit(0);
    add(f, u, c1[u], 0);
    for (int i = 0; i < g1[u].size(); i++)
      if (g1[u][i] != fa) dfs1(g1[u][i], u, u);
    add(u, u + 500, d1[u], 0);
  }
}
void dfs2(int u, int fa, int f) {
  f2[u] = fa;
  if (c2[u] == -1) {
    add(u + 500, f + 500, 1, 0);
    for (int i = 0; i < g2[u].size(); i++)
      if (g2[u][i] != fa) dfs2(g2[u][i], u, f);
  } else {
    d2[u] = c2[u], d2[f] -= c2[u];
    if (d2[f] < 0) puts("-1"), exit(0);
    add(u, f, c2[u], 0);
    for (int i = 0; i < g2[u].size(); i++)
      if (g2[u][i] != fa) dfs2(g2[u][i], u, u);
    add(u + 500, u, d2[u], 0);
  }
}
int main() {
  int x, y, u, v, Q;
  cin >> n >> u >> v;
  S = 2001, T = 2002;
  v += 1000, d1[2001] = d2[2002] = 2e9;
  for (int i = 1; i <= n; i++)
    cin >> x, add(i + 500, i + 1500, 1, -x), c1[i] = c2[i + 1000] = -1;
  for (int i = 1; i < n; i++)
    cin >> x >> y, g1[x].push_back(y), g1[y].push_back(x);
  for (int i = 1; i < n; i++)
    cin >> x >> y, x += 1000, y += 1000, g2[x].push_back(y), g2[y].push_back(x);
  cin >> Q;
  while (Q--) cin >> x >> y, c1[x] = y;
  cin >> Q;
  while (Q--) cin >> x >> y, c2[x + 1000] = y;
  dfs1(u, 2001, 2001), dfs2(v, 2002, 2002);
  while (SPFA()) solve();
  if (sf != c1[u] || sf != c2[v])
    cout << -1;
  else
    cout << -ans;
}
