#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long int INFL = 0x3f3f3f3f3f3f3f3f;
const int N = 1550;
const int M = 0;
const long long int mod = 1e9 + 7;
struct Edge {
  int u, v, cap, flow, cost, next;
  Edge() {}
  Edge(int u, int v, int cap, int flow, int cost, int next)
      : u(u), v(v), cap(cap), flow(flow), cost(cost), next(next) {}
};
int n, m, head[N], src, snk;
vector<Edge> e;
int pi[N], dist[N], path[N], mincap[N], vis[N];
void init(int _n, int _src, int _snk) {
  n = _n;
  m = 0;
  src = _src;
  snk = _snk;
  memset(head, -1, sizeof(head));
}
void addEdge(int u, int v, int cap, int cost) {
  e.push_back(Edge(u, v, cap, 0, cost, head[u]));
  head[u] = m++;
  e.push_back(Edge(v, u, 0, 0, -cost, head[v]));
  head[v] = m++;
}
int bellman_ford() {
  memset(pi, INF, sizeof(pi));
  pi[src] = 0;
  int flag = 1;
  for (int i = 0; flag && i < n; i++) {
    flag = 0;
    for (int j = 0; j < m; j++) {
      if (e[j].cap == e[j].flow) continue;
      if (pi[e[j].u] + e[j].cost < pi[e[j].v]) {
        pi[e[j].v] = pi[e[j].u] + e[j].cost;
        flag = 1;
      }
    }
  }
  return flag;
}
int dijkstra() {
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      heap;
  memset(dist, INF, sizeof(dist));
  memset(vis, 0, sizeof(vis));
  dist[src] = 0;
  mincap[src] = INF;
  heap.push(make_pair(0, src));
  while (!heap.empty()) {
    int u = heap.top().second;
    heap.pop();
    if (vis[u]) continue;
    vis[u] = 1;
    for (int i = head[u]; i != -1; i = e[i].next) {
      int v = e[i].v;
      if (vis[v] || e[i].flow == e[i].cap) continue;
      int w = dist[u] + e[i].cost + pi[u] - pi[v];
      if (w < dist[v]) {
        dist[v] = w;
        path[v] = i;
        mincap[v] = min(mincap[u], e[i].cap - e[i].flow);
        heap.push(make_pair(dist[v], v));
      }
    }
  }
  for (int i = 0; i < n; i++) pi[i] += dist[i];
  return dist[snk] < INF;
}
pair<int, int> mcmf() {
  if (bellman_ford()) return make_pair(-1, -1);
  int cost = 0, flow = 0;
  while (dijkstra()) {
    int first = mincap[snk];
    for (int v = snk; v != src;) {
      int idx = path[v];
      e[idx].flow += first;
      e[idx ^ 1].flow -= first;
      cost += e[idx].cost * first;
      v = e[idx].u;
    }
    flow += first;
  }
  return make_pair(cost, flow);
}
vector<int> v1[N], v2[N];
int val[N], qt1[N], qt2[N], sub[N], aux;
stack<int> stk;
bool imp = false;
void initDfs() { memset(sub, 0, sizeof(sub)); }
void dfs(vector<int> v[], int qt[], int a, int dad, bool cnd) {
  stk.push(a);
  for (int i = 0; i < v[a].size(); i++) {
    if (v[a][i] != dad) {
      dfs(v, qt, v[a][i], a, cnd);
      sub[a] += sub[v[a][i]];
    }
  }
  if (qt[a] != -1 && sub[a] > qt[a]) {
    cout << -1 << endl;
    exit(0);
  }
  if (qt[a] != -1) {
    int u;
    do {
      u = stk.top();
      stk.pop();
      if (cnd)
        addEdge(aux, u, 1, -val[u]);
      else
        addEdge(u, aux, 1, 0);
    } while (u != a);
    if (cnd)
      addEdge(src, aux, qt[a] - sub[a], 0);
    else
      addEdge(aux, snk, qt[a] - sub[a], 0);
    sub[a] = qt[a];
    aux++;
  }
}
int main(void) {
  ios_base::sync_with_stdio(false);
  int n, x, y;
  cin >> n >> x >> y;
  init(N - 1, 0, N - 1);
  aux = n + 1;
  memset(qt1, -1, sizeof(qt1));
  memset(qt2, -1, sizeof(qt2));
  for (int i = 1; i <= n; i++) cin >> val[i];
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    v1[a].push_back(b);
    v1[b].push_back(a);
  }
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    v2[a].push_back(b);
    v2[b].push_back(a);
  }
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    qt1[a] = b;
  }
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    qt2[a] = b;
  }
  initDfs();
  dfs(v1, qt1, x, x, true);
  initDfs();
  dfs(v2, qt2, y, y, false);
  pair<int, int> ans = mcmf();
  if (qt1[x] != qt2[y] || ans.second != qt1[x]) {
    cout << -1 << endl;
  } else {
    cout << -ans.first << endl;
  }
  return 0;
}
