#include <bits/stdc++.h>
using namespace std;
mt19937_64 rnd;
const long long maxn = 2e5 + 10;
const long long mod = 1e9 + 7;
const long long base = 3e18;
struct mincostflow {
  struct edge {
    int v;
    long long c;
    long long w;
    int r;
  };
  vector<vector<edge>> G;
  mincostflow(int n) : G(n) {}
  void add_edge(int u, int v, long long c, long long w) {
    swap(c, w);
    int i = G[u].size();
    int j = G[v].size();
    G[u].push_back({v, c, w, j});
    G[v].push_back({u, 0, -w, i});
  }
  long long run(int s, int t, long long f) {
    const int N = G.size();
    long long res = 0;
    vector<long long> H(N, 0);
    vector<long long> D(N);
    const long long INF = 1e18;
    vector<int> PE(N), PV(N);
    while (f > 0) {
      priority_queue<pair<long long, int>> q;
      fill(D.begin(), D.end(), INF);
      D[s] = 0;
      q.emplace(0, s);
      while (!q.empty()) {
        long long d = -q.top().first;
        int u = q.top().second;
        q.pop();
        if (D[u] < d) continue;
        for (int i = 0; i < G[u].size(); i++) {
          edge e = G[u][i];
          if (e.c > 0 && D[e.v] > D[u] + e.w + H[u] - H[e.v]) {
            D[e.v] = D[u] + e.w + H[u] - H[e.v];
            q.emplace(-D[e.v], e.v);
            PV[e.v] = u;
            PE[e.v] = i;
          }
        }
      }
      if (D[t] == INF) return -base;
      for (int i = 0; i < N; i++) {
        H[i] += D[i];
      }
      long long d = f;
      for (int i = t; i != s; i = PV[i]) {
        d = min(d, G[PV[i]][PE[i]].c);
      }
      f -= d;
      res += d * H[t];
      for (int i = t; i != s; i = PV[i]) {
        edge &e = G[PV[i]][PE[i]];
        e.c -= d;
        G[i][e.r].c += d;
      }
    }
    return res;
  }
};
vector<long long> adj[maxn][2];
long long par[maxn][2];
long long a[maxn];
long long val[maxn][2];
long long val1[maxn][2];
void dfs(long long u, long long par1, long long t) {
  par[u][t] = par1;
  for (auto to : adj[u][t]) {
    if (to == par1) continue;
    dfs(to, u, t);
  }
}
bool dd[maxn];
long long col[maxn][2];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  if (fopen("t.inp", "r")) {
    freopen("test.inp", "r", stdin);
    freopen("test.out", "w", stdout);
  }
  long long n, x, y;
  cin >> n >> x >> y;
  mincostflow man(2 * n + 2);
  long long second = 0, tt = 2 * n + 1;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int t = 0; t < 2; t++) {
    for (int i = 1; i <= n - 1; i++) {
      long long x, y;
      cin >> x >> y;
      adj[x][t].push_back(y);
      adj[y][t].push_back(x);
    }
  }
  dfs(x, 0, 0);
  dfs(y, 0, 1);
  for (int t = 0; t < 2; t++) {
    long long q;
    cin >> q;
    while (q--) {
      long long k, x;
      cin >> x >> k;
      val[x][t] = k;
    }
  }
  for (int t = 0; t < 2; t++) {
    for (int i = 1; i <= n; i++) {
      if (t == 0 && i == x) continue;
      if (t == 1 && i == y) continue;
      if (!val[i][t]) continue;
      long long h = par[i][t];
      while (!val[h][t]) h = par[h][t];
      val1[h][t] += val[i][t];
    }
  }
  for (int t = 0; t < 2; t++) {
    for (int i = 1; i <= n; i++) {
      long long h = i;
      while (!val[h][t]) h = par[h][t];
      col[i][t] = h;
      if (!val[i][t]) continue;
      if (val[i][t] < val1[i][t]) {
        cout << -1;
        return 0;
      }
      if (t == 0)
        man.add_edge(second, i, 0, val[i][t] - val1[i][t]);
      else
        man.add_edge(i + n, tt, 0, val[i][t] - val1[i][t]);
    }
  }
  for (int i = 1; i <= n; i++) {
    man.add_edge(col[i][0], col[i][1] + n, -a[i], 1);
  }
  if (val[x][0] != val[y][1]) {
    cout << -1;
    return 0;
  }
  long long h = man.run(second, tt, val[x][0]);
  if (h == -base) {
    cout << -1;
    return 0;
  }
  cout << -h << endl;
}
