#include <bits/stdc++.h>
using namespace std;
int n, rt[2];
int a[505];
int h[2][505], fr[2][1005], to[2][1005], cnt;
void add(int x, int y, int c) {
  fr[c][++cnt] = h[c][x];
  h[c][x] = cnt;
  to[c][cnt] = y;
}
int s, t;
int hd[100000], nx[100000], ed[100000], f[100000], w[100000],
    tot = 1, pre[100000], prn[100000], dis[10000], vis[100000];
void ad(int x, int y, int ff, int ww) {
  nx[++tot] = hd[x];
  hd[x] = tot;
  ed[tot] = y;
  f[tot] = ff;
  w[tot] = ww;
  nx[++tot] = hd[y];
  hd[y] = tot;
  ed[tot] = x;
  f[tot] = 0;
  w[tot] = -ww;
}
bool spfa() {
  memset(dis, 0x80, sizeof(dis));
  queue<int> q;
  q.push(s);
  dis[s] = 0;
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    vis[now] = 0;
    for (int i = hd[now]; i; i = nx[i]) {
      if (f[i] > 0 && dis[ed[i]] < dis[now] + w[i]) {
        dis[ed[i]] = dis[now] + w[i];
        pre[ed[i]] = i;
        prn[ed[i]] = now;
        if (!vis[ed[i]]) {
          vis[ed[i]] = 1;
          q.push(ed[i]);
        }
      }
    }
  }
  return dis[t] != dis[9999];
}
int mfmc() {
  int ans = 0;
  while (spfa()) {
    int x = t, res = 1e9;
    while (x != s) {
      res = min(res, f[pre[x]]);
      x = prn[x];
    }
    x = t;
    while (x != s) {
      f[pre[x]] -= res;
      f[pre[x] ^ 1] += res;
      x = prn[x];
    }
    ans += res * dis[t];
  }
  return ans;
}
int num[2][505], id;
int dfs2(int now, int fa, int c) {
  if (num[c][now]) return num[c][now];
  if (c)
    ad(now + n, id, 1, 0);
  else
    ad(id, now, 1, 0);
  int tmp = 0;
  for (int i = h[c][now]; i; i = fr[c][i]) {
    if (to[c][i] != fa) tmp += dfs2(to[c][i], now, c);
  }
  return tmp;
}
void dfs1(int now, int fa, int c) {
  for (int i = h[c][now]; i; i = fr[c][i]) {
    if (to[c][i] != fa) dfs1(to[c][i], now, c);
  }
  if (num[c][now]) {
    id = ++cnt;
    int ff = num[c][now];
    for (int i = h[c][now]; i; i = fr[c][i]) {
      if (to[c][i] != fa) ff -= dfs2(to[c][i], now, c);
    }
    if (c)
      ad(id, t, ff, 0), ad(now + n, id, 1, 0);
    else
      ad(s, id, ff, 0), ad(id, now, 1, 0);
  }
}
int main() {
  scanf("%d%d%d", &n, &rt[0], &rt[1]);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    ad(i, i + n, 1, a[i]);
  }
  for (int c = 0; c <= 1; c++, cnt = 0)
    for (int i = 1, x, y; i < n; i++) {
      scanf("%d%d", &x, &y);
      add(x, y, c);
      add(y, x, c);
    }
  cnt = n * 2;
  t = ++cnt;
  int qq;
  for (int c = 0; c <= 1; c++) {
    scanf("%d", &qq);
    for (int i = 1, x, y; i <= qq; i++) {
      scanf("%d%d", &x, &y);
      num[c][x] = y;
    }
  }
  dfs1(rt[0], 0, 0);
  dfs1(rt[1], 0, 1);
  int a = mfmc();
  for (int i = hd[0]; i; i = nx[i]) {
    if (f[i]) {
      printf("-1");
      return 0;
    }
  }
  for (int i = hd[t]; i; i = nx[i]) {
    if (f[i ^ 1]) {
      printf("-1");
      return 0;
    }
  }
  printf("%d", a);
}
