#include <bits/stdc++.h>
using namespace std;
namespace mine {
const int INF = 0x3f3f3f3f;
const int MAX_N = 510;
int n, rt1, rt2, w[MAX_N];
struct Tree {
  int hou[MAX_N], f[MAX_N];
  struct Edge {
    int y, g;
  } e[MAX_N * 2];
  int ln;
  void ins(int x, int y) {
    e[++ln] = (Edge){y, hou[x]};
    hou[x] = ln;
  }
  int nfa[MAX_N], ned[MAX_N];
  Tree() {
    ln = 0;
    memset(hou, 0, sizeof hou);
    memset(ned, -1, sizeof ned);
  }
  int getnum(int x, int fa, int st) {
    if (st == 0 and ned[x] >= 0) return ned[x];
    int tot = 0;
    for (int k = hou[x]; k > 0; k = e[k].g)
      if (e[k].y != fa) tot += getnum(e[k].y, x, 0);
    return tot;
  }
  void dfs(int x, int fa, int tfa) {
    nfa[x] = ned[x] >= 0 ? x : tfa;
    f[x] = fa;
    for (int k = hou[x]; k > 0; k = e[k].g) {
      int y = e[k].y;
      if (y == fa) continue;
      dfs(y, x, nfa[x]);
    }
  }
} t1, t2;
struct MCMF {
  int hou[MAX_N * 2];
  struct Edge {
    int y, g, c;
    long long w;
  } e[MAX_N * MAX_N];
  int ln;
  int oth(int x) { return x & 1 ? x + 1 : x - 1; }
  void ins(int x, int y, int c, int w) {
    e[++ln] = (Edge){y, hou[x], c, w};
    hou[x] = ln;
    e[++ln] = (Edge){x, hou[y], 0, -w};
    hou[y] = ln;
  }
  long long dis[MAX_N * 2];
  bool v[MAX_N * 2];
  int fm[MAX_N * 2], mif[MAX_N * 2];
  queue<int> q;
  long long flow, cost;
  bool solve(int st, int ed) {
    memset(dis, -63, sizeof dis);
    dis[st] = 0;
    q.push(st);
    mif[st] = INF;
    v[st] = 1;
    while (q.size()) {
      int x = q.front();
      q.pop();
      for (int k = hou[x]; k > 0; k = e[k].g) {
        int y = e[k].y;
        if (dis[y] < dis[x] + e[k].w and e[k].c > 0) {
          dis[y] = dis[x] + e[k].w;
          mif[y] = min(e[k].c, mif[x]);
          fm[y] = k;
          if (!v[y]) v[y] = 1, q.push(y);
        }
      }
      v[x] = 0;
    }
    if (dis[ed] == dis[MAX_N * 2 - 1] or mif[ed] == 0) return 0;
    flow += mif[ed];
    cost += dis[ed] * mif[ed];
    int x = ed;
    while (x != st) {
      int t = fm[x];
      e[t].c -= mif[ed];
      e[oth(t)].c += mif[ed];
      x = e[oth(t)].y;
    }
    return 1;
  }
  bool check(int st, int ed) {
    int tot1 = 0, tot2 = 0;
    for (int k = hou[st]; k > 0; k = e[k].g)
      if (e[k].c > 0) return 1;
    for (int k = hou[ed]; k > 0; k = e[k].g)
      if (e[oth(k)].c > 0) return 1;
    return 0;
  }
  MCMF() {
    ln = 0;
    flow = cost = 0;
    memset(hou, 0, sizeof hou);
  }
} mcmf;
void input() {
  scanf("%d%d%d", &n, &rt1, &rt2);
  for (int i = 1; i <= n; i++) scanf("%d", &w[i]);
  for (int i = 1; i <= n - 1; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    t1.ins(x, y);
    t1.ins(y, x);
  }
  for (int i = 1; i <= n - 1; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    t2.ins(x, y);
    t2.ins(y, x);
  }
  int q1;
  scanf("%d", &q1);
  while (q1--) {
    int x, y;
    scanf("%d%d", &x, &y);
    t1.ned[x] = y;
  }
  int q2;
  scanf("%d", &q2);
  while (q2--) {
    int x, y;
    scanf("%d%d", &x, &y);
    t2.ned[x] = y;
  }
}
void main() {
  input();
  if (t1.ned[rt1] != t2.ned[rt2]) {
    puts("-1");
    return;
  }
  t1.dfs(rt1, 0, 0);
  t2.dfs(rt2, 0, 0);
  int st = 0, ed = 2 * n + 1;
  for (int i = 1; i <= n; i++) {
    int fx = t1.nfa[i], fy = t2.nfa[i];
    mcmf.ins(fx, n + fy, 1, w[i]);
    if (t1.ned[i] >= 0)
      mcmf.ins(st, i, t1.ned[i] - t1.getnum(i, t1.f[i], 1), 0);
    if (t2.ned[i] >= 0)
      mcmf.ins(n + i, ed, t2.ned[i] - t2.getnum(i, t2.f[i], 1), 0);
  }
  while (mcmf.solve(st, ed))
    ;
  if (mcmf.flow != t1.ned[rt1] or mcmf.check(st, ed))
    puts("-1");
  else
    printf("%lld", mcmf.cost);
}
};  // namespace mine
int main() {
  srand(time(0));
  mine::main();
}
