#include <bits/stdc++.h>
using namespace std;
const int SIZE = 1e3 + 5;
const int INF = 1e9;
int N, r1, r2;
int A[SIZE];
int d1[SIZE], d2[SIZE];
int tot1[SIZE], tot2[SIZE];
int pos1[SIZE], pos2[SIZE];
vector<int> v1[SIZE], v2[SIZE];
struct edge {
  int v, f, c, u;
  int cost;
};
vector<edge> E[SIZE];
int st[SIZE], lvl[SIZE];
int cost[SIZE];
void init() {
  for (int i = 0; i < SIZE; i++) {
    d1[i] = 0;
    d2[i] = 0;
    tot1[i] = 0;
    tot2[i] = 0;
    pos1[i] = 0;
    pos2[i] = 0;
    v1[i].clear();
    v2[i].clear();
    E[i].clear();
  }
}
void DFS1(int indx, int closest) {
  pos1[indx] = closest;
  for (int i = 0; i < (int)v1[indx].size(); i++) {
    int idx = v1[indx][i];
    if (pos1[idx] == 0) {
      if (d1[idx] != 0) {
        DFS1(idx, idx);
        tot1[indx] += d1[idx];
      } else {
        DFS1(idx, closest);
        tot1[indx] += tot1[idx];
      }
    }
  }
}
void DFS2(int indx, int closest) {
  pos2[indx] = closest;
  for (int i = 0; i < (int)v2[indx].size(); i++) {
    int idx = v2[indx][i];
    if (pos2[idx] == 0) {
      if (d2[idx] != 0) {
        DFS2(idx, idx);
        tot2[indx] += d2[idx];
      } else {
        DFS2(idx, closest);
        tot2[indx] += tot2[idx];
      }
    }
  }
}
void addedge(int a, int b, int ca, int cb, int cost) {
  edge A = {a, 0, ca, (int)E[a].size(), -cost};
  edge B = {b, 0, cb, (int)E[b].size(), cost};
  E[a].push_back(B);
  E[b].push_back(A);
}
bool Dijsktra(int S, int T) {
  for (int i = 0; i < SIZE; i++) {
    cost[i] = INF;
    lvl[i] = -1;
  }
  priority_queue<pair<int, int> > pq;
  pq.push(make_pair(0, S));
  cost[S] = 0;
  lvl[S] = 0;
  while (!pq.empty()) {
    int indx = pq.top().second;
    int step = -pq.top().first;
    pq.pop();
    if (step > cost[indx]) continue;
    for (int i = 0; i < (int)E[indx].size(); i++) {
      edge &t = E[indx][i];
      int idx = t.v;
      if (cost[idx] > cost[indx] + t.cost && t.c > t.f) {
        cost[idx] = cost[indx] + t.cost;
        lvl[idx] = lvl[indx] + 1;
        pq.push(make_pair(-cost[idx], idx));
      }
    }
  }
  return lvl[T] >= 0;
}
int DFS(int indx, int T, int flow) {
  if (indx == T) return flow;
  for (int &i = st[indx]; i < (int)E[indx].size(); i++) {
    edge &t = E[indx][i];
    int idx = t.v;
    if (lvl[idx] == lvl[indx] + 1 && cost[idx] == cost[indx] + t.cost &&
        t.c > t.f) {
      int ret = DFS(idx, T, min(flow, t.c - t.f));
      if (ret > 0) {
        t.f += ret;
        E[t.v][t.u].f -= ret;
        return ret;
      }
    }
  }
  return 0;
}
pair<int, int> MCMF(int S, int T) {
  pair<int, int> ret = make_pair(0, 0);
  while (Dijsktra(S, T)) {
    memset(st, 0, sizeof(st));
    while (int flow = DFS(S, T, INF)) {
      ret.first += cost[T];
      ret.second += flow;
    }
  }
  return ret;
}
int main() {
  int a, b;
  int q1, q2;
  int S = 0, T = SIZE - 1;
  init();
  scanf("%d %d %d", &N, &r1, &r2);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &A[i]);
  }
  for (int i = 1; i < N; i++) {
    scanf("%d %d", &a, &b);
    v1[a].push_back(b);
    v1[b].push_back(a);
  }
  for (int i = 1; i < N; i++) {
    scanf("%d %d", &a, &b);
    v2[a].push_back(b);
    v2[b].push_back(a);
  }
  scanf("%d", &q1);
  for (int i = 0; i < q1; i++) {
    scanf("%d %d", &a, &b);
    d1[a] = b;
  }
  scanf("%d", &q2);
  for (int i = 0; i < q2; i++) {
    scanf("%d %d", &a, &b);
    d2[a] = b;
  }
  DFS1(r1, r1);
  DFS2(r2, r2);
  bool valid = true;
  for (int i = 1; i <= N; i++) {
    if ((d1[i] != 0 && d1[i] < tot1[i]) || (d2[i] != 0 && d2[i] < tot2[i]))
      valid = false;
  }
  if (valid == false) {
    printf("-1\n");
    return 0;
  }
  int total1 = 0, total2 = 0;
  for (int i = 1; i <= N; i++) {
    if (d1[i] != 0) {
      addedge(S, i, 0, d1[i] - tot1[i], 0);
      total1 += (d1[i] - tot1[i]);
    }
    if (d2[i] != 0) {
      addedge(i + N, T, 0, d2[i] - tot2[i], 0);
      total2 += (d2[i] - tot2[i]);
    }
    addedge(pos1[i], pos2[i] + N, 0, 1, -A[i]);
  }
  pair<int, int> ans = MCMF(S, T);
  if (ans.second == d1[r1] && d1[r1] == d2[r2]) {
    printf("%d\n", -ans.first);
  } else
    printf("-1\n");
  return 0;
}
