#include <bits/stdc++.h>
using namespace std;
double a[2510][2510];
int n, m;
void pivot(int l, int e) {
  double delta = a[l][e];
  a[l][e] = 1;
  for (int i = 0; i <= n; i++) a[l][i] /= delta;
  for (int i = 0; i <= m; i++) {
    if (i != l && fabs(a[i][e]) > 1e-6) {
      delta = a[i][e];
      a[i][e] = 0;
      for (int j = 0; j <= n; j++) a[i][j] -= a[l][j] * delta;
    }
  }
}
bool init_solution() {
  while (1) {
    int e = 0, l = 0;
    for (int i = 1; i <= m; i++) {
      if (a[i][0] < -1e-6 && (!e || (rand() & 1))) e = i;
    }
    if (!e) break;
    for (int i = 1; i <= n; i++) {
      if (a[e][i] < -1e-6 && (!l || rand() & 1)) l = i;
    }
    if (!l) {
      return 0;
    }
    pivot(e, l);
  }
  return 1;
}
bool solve() {
  while (1) {
    int l = 0, e = 0;
    double mn = 1e18;
    for (int i = 1; i <= n; i++) {
      if (a[0][i] > 1e-6) {
        e = i;
        break;
      }
    }
    if (!e) break;
    for (int i = 1; i <= m; i++) {
      if (a[i][e] > 1e-6 && a[i][0] / a[i][e] < mn) {
        mn = a[i][0] / a[i][e];
        l = i;
      }
    }
    if (!l) return 0;
    pivot(l, e);
  }
  return 1;
}
vector<int> con1[510], con2[510];
int fa1[510], fa2[510], x, y;
void dfs1(int np, int fath) {
  fa1[np] = fath;
  for (int i = 0; i < con1[np].size(); i++) {
    if (con1[np][i] == fath) continue;
    dfs1(con1[np][i], np);
  }
}
void dfs2(int np, int fath) {
  fa2[np] = fath;
  for (int i = 0; i < con2[np].size(); i++) {
    if (con2[np][i] == fath) continue;
    dfs2(con2[np][i], np);
  }
}
void dfs3(int np) {
  a[m][np] = 1;
  for (int i = 0; i < con1[np].size(); i++) {
    if (con1[np][i] == fa1[np]) continue;
    dfs3(con1[np][i]);
  }
}
void dfs4(int np) {
  a[m][np] = 1;
  for (int i = 0; i < con2[np].size(); i++) {
    if (con2[np][i] == fa2[np]) continue;
    dfs4(con2[np][i]);
  }
}
int q;
int main() {
  srand(time(0));
  scanf("%d%d%d", &n, &x, &y);
  for (int i = 1; i <= n; i++) scanf("%lf", &a[0][i]);
  for (int i = 1, ti, tj; i < n; i++) {
    scanf("%d%d", &ti, &tj);
    con1[ti].push_back(tj);
    con1[tj].push_back(ti);
  }
  for (int i = 1, ti, tj; i < n; i++) {
    scanf("%d%d", &ti, &tj);
    con2[ti].push_back(tj);
    con2[tj].push_back(ti);
  }
  dfs1(x, 0);
  dfs2(y, 0);
  m = 1;
  scanf("%d", &q);
  for (int i = 1, ti, tj; i <= q; i++) {
    scanf("%d%d", &ti, &tj);
    dfs3(ti);
    a[m][0] = tj;
    ++m;
    for (int j = 0; j <= n; j++) a[m][j] = -a[m - 1][j];
    ++m;
  }
  scanf("%d", &q);
  for (int i = 1, ti, tj; i <= q; i++) {
    scanf("%d%d", &ti, &tj);
    dfs4(ti);
    a[m][0] = tj;
    ++m;
    for (int j = 0; j <= n; j++) a[m][j] = -a[m - 1][j];
    ++m;
  }
  for (int i = 1; i <= n; i++) {
    a[m][i] = a[m][i + n] = a[m][0] = 1;
    ++m;
  }
  m--;
  if (!init_solution()) {
    puts("-1");
    return 0;
  }
  solve();
  printf("%d\n", (int)(-a[0][0] + 0.3));
  return 0;
}
