#include <bits/stdc++.h>
using namespace std;
const int N = 505;
const int FN = N * 2 + 2;
const int INF = 0x66666666;
const int VALUE = -1e8;
struct Edge {
  int s, t, cp, fl;
  long long co;
};
struct MCMF {
  int n, m, s, t;
  vector<Edge> edges;
  vector<int> G[FN + 1];
  int inq[FN + 1], p[FN + 1], f[FN + 1];
  long long d[FN + 1];
  void Init(int n) {
    assert(n <= FN);
    this->n = n;
    for (int i = 0; i <= n; ++i) {
      G[i].clear();
    }
    edges.clear();
  }
  void AddEdge(int s, int t, int cp, long long co) {
    assert(0 <= s && s <= n);
    assert(0 <= t && t <= n);
    edges.push_back((Edge){s, t, cp, 0, co});
    G[s].push_back(edges.size() - 1);
    edges.push_back((Edge){t, s, 0, 0, -co});
    G[t].push_back(edges.size() - 1);
  }
  bool Check() {
    for (int i = 0; i < edges.size(); ++i, ++i) {
      if (edges[i].co && edges[i].co > VALUE) {
        assert(edges[i].s <= n / 2 && edges[i].t > n / 2);
      }
      if (edges[i].cp != INF && edges[i].co == VALUE) {
        if (edges[i].cp != edges[i].fl) {
          return false;
        }
      }
    }
    return true;
  }
  bool Augmentation(int s, int t, int &fl, long long &co) {
    for (int i = 0; i <= n; ++i) {
      d[i] = INF;
    }
    memset(inq, 0, sizeof(inq));
    d[s] = 0, inq[s] = 1, p[s] = -1, f[s] = INF;
    queue<int> Q;
    Q.push(s);
    while (!Q.empty()) {
      int u = Q.front();
      Q.pop();
      inq[u] = 0;
      for (auto id : G[u]) {
        Edge &e = edges[id];
        if (e.cp > e.fl && d[e.t] > d[u] + e.co) {
          d[e.t] = d[u] + e.co;
          p[e.t] = id;
          f[e.t] = min(f[u], e.cp - e.fl);
          if (!inq[e.t]) {
            Q.push(e.t);
            inq[e.t] = 1;
          }
        }
      }
    }
    if (d[t] == INF) {
      return false;
    }
    fl += f[t];
    co += d[t] * f[t];
    int u = t;
    while (u != s) {
      edges[p[u]].fl += f[t];
      edges[p[u] ^ 1].fl -= f[t];
      u = edges[p[u]].s;
    }
    return true;
  }
  long long Run() {
    int fl = 0;
    long long co = 0;
    while (Augmentation(0, n, fl, co)) {
    }
    cerr << co << endl;
    return co;
  }
} mcmf;
vector<int> tree[2][N];
int root[2], demand[2][N], value[2][N];
int n, src, snk;
void DFS(int rt, int p, int id) {
  if (p < 0) {
    if (id == 0) {
      mcmf.AddEdge(src, rt, demand[id][rt], value[id][rt]);
    } else {
      mcmf.AddEdge(rt + n, snk, demand[id][rt], value[id][rt]);
    }
  } else {
    if (id == 0) {
      mcmf.AddEdge(p, rt, demand[id][rt], value[id][rt]);
    } else {
      mcmf.AddEdge(rt + n, p + n, demand[id][rt], value[id][rt]);
    }
  }
  for (auto nx : tree[id][rt]) {
    if (nx == p) {
      continue;
    }
    DFS(nx, rt, id);
  }
}
int main() {
  ios::sync_with_stdio(false);
  while (cin >> n >> root[0] >> root[1]) {
    mcmf.Init(n * 2 + 1);
    src = 0;
    snk = n * 2 + 1;
    for (int i = 1, x; i <= n; ++i) {
      cin >> x;
      assert(x > 0);
      mcmf.AddEdge(i, i + n, 1, -x);
    }
    for (int i = 0; i < 2; ++i) {
      for (int j = 1; j <= n; ++j) {
        tree[i][j].clear();
        demand[i][j] = INF;
        value[i][j] = 0;
      }
      for (int j = 1, x, y; j < n; ++j) {
        cin >> x >> y;
        tree[i][x].push_back(y);
        tree[i][y].push_back(x);
      }
    }
    for (int i = 0, m; i < 2; ++i) {
      cin >> m;
      for (int j = 0, x, y; j < m; ++j) {
        cin >> x >> y;
        demand[i][x] = y;
        value[i][x] = VALUE;
      }
      DFS(root[i], -1, i);
    }
    long long ans = (-mcmf.Run()) % VALUE;
    if (mcmf.Check()) {
      cout << ans << endl;
    } else {
      cout << -1 << endl;
    }
  }
  return 0;
}
