#include <bits/stdc++.h>
using namespace std;
int coste[501], d1[501], d2[501], dad1[501], dad2[501];
vector<int> G1[501], G2[501];
bool ok = true;
int dfs1(int node, int last) {
  if (d1[node] == 0)
    dad1[node] = last;
  else
    dad1[node] = node;
  int fijo = d1[node];
  int ret = d1[node];
  for (auto it = G1[node].begin(); it != G1[node].end(); it++) {
    if (dad1[*it] == -1) {
      if (fijo == 0)
        ret += dfs1(*it, dad1[node]);
      else
        d1[node] -= dfs1(*it, dad1[node]);
    }
  }
  return ret;
}
int dfs2(int node, int last) {
  if (d2[node] == 0)
    dad2[node] = last;
  else
    dad2[node] = node;
  int fijo = d2[node];
  int ret = d2[node];
  for (auto it = G2[node].begin(); it != G2[node].end(); it++) {
    if (dad2[*it] == -1) {
      if (fijo == 0) {
        ret += dfs2(*it, dad2[node]);
      } else {
        d2[node] -= dfs2(*it, dad2[node]);
      }
    }
  }
  return ret;
}
const int MAXNI = 1010;
const long long INFFLUJO = 1e14;
const long long INFCOSTO = 1e14;
struct edge {
  int u, v;
  long long cap, flow;
  long long cost;
  long long rem() { return cap - flow; }
};
int nodes;
vector<int> G[MAXNI];
vector<edge> e;
void addEdge(int u, int v, long long cap, long long cost) {
  G[u].push_back(((int)e.size()));
  e.push_back((edge){u, v, cap, 0, cost});
  G[v].push_back(((int)e.size()));
  e.push_back((edge){v, u, 0, 0, -cost});
}
long long dist[MAXNI], mnCost;
int pre[MAXNI];
long long cap[MAXNI], mxFlow;
bool in_queue[MAXNI];
void flow(int s, int t) {
  memset(in_queue, 0, sizeof(in_queue));
  mxFlow = mnCost = 0;
  while (1) {
    fill(dist, dist + nodes, INFCOSTO);
    dist[s] = 0;
    memset(pre, -1, sizeof(pre));
    pre[s] = 0;
    memset(cap, 0, sizeof(cap));
    cap[s] = INFFLUJO;
    queue<int> q;
    q.push(s);
    in_queue[s] = 1;
    while (((int)q.size())) {
      int u = q.front();
      q.pop();
      in_queue[u] = 0;
      for (auto it : G[u]) {
        edge &E = e[it];
        if (E.rem() && dist[E.v] > dist[u] + E.cost) {
          dist[E.v] = dist[u] + E.cost;
          pre[E.v] = it;
          cap[E.v] = min(cap[u], E.rem());
          if (!in_queue[E.v]) q.push(E.v), in_queue[E.v] = 1;
        }
      }
    }
    if (pre[t] == -1) break;
    mxFlow += cap[t];
    mnCost += cap[t] * dist[t];
    for (int v = t; v != s; v = e[pre[v]].u) {
      e[pre[v]].flow += cap[t];
      e[pre[v] ^ 1].flow -= cap[t];
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, c1, c2;
  cin >> n >> c1 >> c2;
  nodes = 1004;
  c1--;
  c2--;
  for (int i = (0); i < (n); i++) cin >> coste[i];
  for (int i = (0); i < (n - 1); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G1[a].push_back(b);
    G1[b].push_back(a);
  }
  for (int i = (0); i < (n - 1); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G2[a].push_back(b);
    G2[b].push_back(a);
  }
  memset(d1, 0, sizeof(d1)), memset(d2, 0, sizeof(d2));
  int d;
  cin >> d;
  for (int D = (0); D < (d); D++) {
    int a, b;
    cin >> a >> b;
    a--;
    d1[a] = b;
  }
  int check = d1[c1];
  cin >> d;
  for (int D = (0); D < (d); D++) {
    int a, b;
    cin >> a >> b;
    a--;
    d2[a] = b;
  }
  int check2 = d2[c2];
  memset(dad1, -1, sizeof(dad1));
  memset(dad2, -1, sizeof(dad2));
  dfs1(c1, -1);
  dfs2(c2, -1);
  for (int i = (0); i < (n); i++) {
    if (d1[i] > 0) {
      addEdge(1002, i, d1[i], 0);
    }
    if (d2[i] > 0) {
      addEdge(i + n, 1003, d2[i], 0);
    }
    if (d1[i] < 0 || d2[i] < 0) ok = false;
    addEdge(dad1[i], dad2[i] + n, 1, -coste[i]);
  }
  flow(1002, 1003);
  if (ok && mxFlow == check && mxFlow == check2)
    cout << -1 * mnCost << endl;
  else
    cout << -1 << endl;
  return 0;
}
