#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int inf = 1 << 30;
const int maxn = 1005;
inline void fastio() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
int n, x, y, a[maxn], ned[2][maxn], up[2][maxn], has[2][maxn];
int s, t, head[maxn], tot, last[maxn], pre[maxn], flow[maxn], dis[maxn],
    vis[maxn];
vector<int> g[2][maxn];
vector<int> vec[2][maxn];
struct edge {
  int u, v, w, c, nxt;
} es[maxn << 4];
void addedge(int u, int v, int w, int c) {
  es[++tot] = (edge){u, v, w, c, head[u]};
  head[u] = tot;
}
void add(int u, int v, int w, int c) {
  addedge(u, v, w, c);
  addedge(v, u, 0, -c);
}
int dfs(int u, int f, int o) {
  vec[o][u].push_back(u);
  int sum = 0;
  for (int v : g[o][u])
    if (v != f) {
      sum += dfs(v, u, o);
      for (int x : vec[o][v]) vec[o][u].push_back(x);
    }
  if (ned[o][u]) {
    if (ned[o][u] < sum) {
      cout << -1 << endl;
      exit(0);
    }
    if (!o)
      add(s, u, ned[o][u] - sum, 0);
    else
      add(u + n, t, ned[o][u] - sum, 0);
    for (int x : vec[o][u]) up[o][x] = u;
    vec[o][u].clear();
    return ned[o][u];
  } else
    return sum;
}
bool spfa() {
  memset(dis, -0x3f, sizeof(dis));
  memset(flow, 0x3f, sizeof(flow));
  memset(vis, 0, sizeof(vis));
  queue<int> q;
  q.push(s);
  vis[s] = 1;
  dis[s] = 0;
  pre[t] = -1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    vis[u] = 0;
    for (int i = head[u]; i != -1; i = es[i].nxt) {
      int v = es[i].v, w = es[i].w, c = es[i].c;
      if (w && dis[v] < dis[u] + c) {
        dis[v] = dis[u] + c;
        flow[v] = min(flow[u], w);
        pre[v] = u;
        last[v] = i;
        if (!vis[v]) {
          q.push(v);
          vis[v] = 1;
        }
      }
    }
  }
  return ~pre[t];
}
pair<int, int> MCMF() {
  pair<int, int> res = make_pair(0, 0);
  while (spfa()) {
    int now = t;
    res.first += flow[t];
    res.second += flow[t] * dis[t];
    while (now != s) {
      es[last[now]].w -= flow[t];
      es[last[now] ^ 1].w += flow[t];
      now = pre[now];
    }
  }
  return res;
}
int main() {
  fastio();
  int u, v, q;
  memset(head, -1, sizeof(head));
  tot = -1;
  cin >> n >> x >> y;
  for (int i = (1); i <= (n); i++) cin >> a[i];
  for (int i = (1); i <= (n - 1); i++) {
    cin >> u >> v;
    g[0][u].push_back(v);
    g[0][v].push_back(u);
  }
  for (int i = (1); i <= (n - 1); i++) {
    cin >> u >> v;
    g[1][u].push_back(v);
    g[1][v].push_back(u);
  }
  cin >> q;
  while (q--) {
    cin >> u;
    cin >> ned[0][u];
  }
  cin >> q;
  while (q--) {
    cin >> u;
    cin >> ned[1][u];
  }
  if (ned[0][x] != ned[1][y]) return cout << -1 << endl, 0;
  s = 0, t = 2 * n + 1;
  dfs(x, 0, 0);
  dfs(y, 0, 1);
  for (int i = (1); i <= (n); i++) {
    add(up[0][i], up[1][i] + n, 1, a[i]);
  }
  pair<int, int> res = MCMF();
  if (res.first < ned[0][x] || res.first < ned[1][y]) {
    cout << -1 << endl;
  } else
    cout << res.second << endl;
  return 0;
}
