#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18 + 7;
const long long MAXN = 1e6 + 7;
const double EPS = 1e-8;
struct Edge {
  long long v, c, f, w, rev;
};
long long n, s, t;
vector<vector<Edge> > gr;
void addEdge(long long v, long long u, long long c, long long w) {
  gr[v].push_back({u, c, 0, w, (long long)gr[u].size()});
  gr[u].push_back({v, 0, 0, -w, (long long)gr[v].size() - 1});
}
vector<long long> pi;
void FordBellman() {
  pi.assign(n, INF);
  pi[s] = 0;
  for (long long i = 0; i < n; i++) {
    for (long long v = 0; v < n; v++) {
      for (auto &e : gr[v]) {
        if (e.c - e.f == 0) continue;
        pi[e.v] = min(pi[e.v], pi[v] + e.w);
      }
    }
  }
}
bool Dijkstra() {
  vector<long long> d(n, INF);
  vector<pair<int, int> > pr(n);
  d[s] = 0;
  set<pair<long long, long long> > q;
  q.insert({d[s], s});
  while (!q.empty()) {
    long long v = q.begin()->second;
    q.erase(q.begin());
    for (auto &e : gr[v]) {
      if (e.c - e.f == 0) continue;
      if (d[e.v] > d[v] + pi[v] - pi[e.v] + e.w) {
        q.erase({d[e.v], e.v});
        d[e.v] = d[v] + pi[v] - pi[e.v] + e.w;
        pr[e.v] = {e.v, e.rev};
        q.insert({d[e.v], e.v});
      }
    }
  }
  if (d[t] == INF) return false;
  for (long long i = 0; i < n; i++) {
    pi[i] += d[i];
  }
  long long sum = 0;
  long long now = t;
  while (now != s) {
    auto &e = gr[pr[now].first][pr[now].second];
    e.f--;
    gr[e.v][e.rev].f++;
    sum -= e.w;
    now = e.v;
  }
  return true;
}
long long m;
long long MinCost() {
  FordBellman();
  while (Dijkstra()) {
  }
  long long res = 0;
  for (long long v = 0; v < n; v++) {
    for (auto e : gr[v]) {
      if (e.f < 0) continue;
      if (v == s && e.f != e.c) {
        cout << "-1\n";
        exit(0);
      }
      res += e.f * e.w;
    }
  }
  return res;
}
vector<long long> a;
vector<vector<long long> > ngr;
vector<long long> val;
vector<pair<long long, vector<long long> > > all;
long long dfs(long long v, long long p, vector<long long> &now) {
  long long sum = 0;
  now.push_back(v);
  for (long long u : ngr[v]) {
    if (u == p) continue;
    vector<long long> nxt;
    sum += dfs(u, v, nxt);
    if (now.size() < nxt.size()) swap(now, nxt);
    for (long long x : nxt) {
      now.push_back(x);
    }
  }
  if (val[v] == -1) {
    return sum;
  }
  if (val[v] - sum > now.size() || sum > val[v]) {
    cout << "-1\n";
    exit(0);
  }
  all.push_back({val[v] - sum, now});
  now.clear();
  return val[v];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long cap[2];
  cin >> m >> cap[0] >> cap[1];
  a.resize(m, 0);
  cap[0]--, cap[1]--;
  s = 0, t = 1;
  n = 2 * m + 2;
  gr.resize(n);
  for (long long i = 0; i < m; i++) {
    cin >> a[i];
  }
  vector<pair<long long, long long> > edges[2];
  for (long long it = 0; it < 2; it++) {
    for (long long i = 1; i < m; i++) {
      long long v, u;
      cin >> v >> u;
      v--, u--;
      edges[it].push_back({v, u});
    }
  }
  for (long long i = 0; i < m; i++) {
    addEdge(i + 2, i + m + 2, 1, -a[i]);
  }
  vector<long long> data;
  for (long long it = 0; it < 2; it++) {
    ngr.clear();
    ngr.resize(m);
    for (auto t : edges[it]) {
      long long v = t.first, u = t.second;
      ngr[v].push_back(u);
      ngr[u].push_back(v);
    }
    val.clear();
    val.resize(m, -1);
    long long q;
    cin >> q;
    for (long long i = 0; i < q; i++) {
      long long v, w;
      cin >> v >> w;
      v--;
      val[v] = w;
    }
    vector<long long> now;
    data.push_back(val[cap[it]]);
    dfs(cap[it], -1, now);
    for (auto elem : all) {
      long long x = elem.first;
      auto p = elem.second;
      gr.push_back({});
      n++;
      if (!it) {
        addEdge(s, n - 1, x, 0);
      } else {
        addEdge(n - 1, t, x, 0);
      }
      for (long long x : p) {
        if (!it) {
          addEdge(n - 1, x + 2, 1, 0);
        } else {
          addEdge(x + m + 2, n - 1, 1, 0);
        }
      }
    }
    all.clear();
  }
  if (data[0] != data[1]) {
    cout << "-1\n";
    exit(0);
  }
  cout << -MinCost();
}
