There are n cities in the country. 

Two candidates are fighting for the post of the President. The elections are set in the future, and both candidates have already planned how they are going to connect the cities with roads. Both plans will connect all cities using n - 1 roads only. That is, each plan can be viewed as a tree. Both of the candidates had also specified their choice of the capital among n cities (x for the first candidate and y for the second candidate), which may or may not be same.

Each city has a potential of building a port (one city can have at most one port). Building a port in i-th city brings a_i amount of money. However, each candidate has his specific demands. The demands are of the form: 

  * k x, which means that the candidate wants to build exactly x ports in the subtree of the k-th city of his tree (the tree is rooted at the capital of his choice). 



Find out the maximum revenue that can be gained while fulfilling all demands of both candidates, or print -1 if it is not possible to do.

It is additionally guaranteed, that each candidate has specified the port demands for the capital of his choice.

Input

The first line contains integers n, x and y (1 ≤ n ≤ 500, 1 ≤ x, y ≤ n) — the number of cities, the capital of the first candidate and the capital of the second candidate respectively.

Next line contains integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 100 000) — the revenue gained if the port is constructed in the corresponding city.

Each of the next n - 1 lines contains integers u_i and v_i (1 ≤ u_i, v_i ≤ n, u_i ≠ v_i), denoting edges between cities in the tree of the first candidate.

Each of the next n - 1 lines contains integers u'_i and v'_i (1 ≤ u'_i, v'_i ≤ n, u'_i ≠ v'_i), denoting edges between cities in the tree of the second candidate.

Next line contains an integer q_1 (1 ≤ q_1 ≤ n), denoting the number of demands of the first candidate.

Each of the next q_1 lines contains two integers k and x (1 ≤ k ≤ n, 1 ≤ x ≤ n) — the city number and the number of ports in its subtree.

Next line contains an integer q_2 (1 ≤ q_2 ≤ n), denoting the number of demands of the second candidate.

Each of the next q_2 lines contain two integers k and x (1 ≤ k ≤ n, 1 ≤ x ≤ n) — the city number and the number of ports in its subtree.

It is guaranteed, that given edges correspond to valid trees, each candidate has given demand about each city at most once and that each candidate has specified the port demands for the capital of his choice. That is, the city x is always given in demands of the first candidate and city y is always given in the demands of the second candidate.

Output

Print exactly one integer — the maximum possible revenue that can be gained, while satisfying demands of both candidates, or -1 if it is not possible to satisfy all of the demands.

Examples

Input

4 1 2
1 2 3 4
1 2
1 3
3 4
1 2
2 3
1 4
2
1 3
4 1
1
2 3


Output

9

Input

5 1 1
3 99 99 100 2
1 2
1 3
3 4
3 5
1 3
1 2
2 4
2 5
2
1 2
3 1
2
1 2
2 1


Output

198

Input

4 1 2
1 2 3 4
1 2
1 3
3 4
2 1
2 4
4 3
1
1 4
2
4 1
2 4


Output

-1

Note

In the first example, it is optimal to build ports in cities 2, 3 and 4, which fulfills all demands of both candidates and gives revenue equal to 2 + 3 + 4 = 9.

In the second example, it is optimal to build ports in cities 2 and 3, which fulfills all demands of both candidates and gives revenue equal to 99 + 99 = 198. 

In the third example, it is not possible to build ports in such way, that all demands of both candidates are specified, hence the answer is -1.
#include <bits/stdc++.h>
using namespace std;
int read() {
  int r = 0, t = 1, c = getchar();
  while (c < '0' || c > '9') {
    t = c == '-' ? -1 : 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    r = (r << 3) + (r << 1) + (c ^ 48);
    c = getchar();
  }
  return r * t;
}
namespace run {
int n, r1, r2, begin1[4010], begin2[4010], next1[4010], next2[4010], to1[4010],
    to2[4010], e1, e2, w[4010], x, y, f1[4010], f2[4010];
double a[4010][4010];
void add1(int u, int v) {
  e1++;
  next1[e1] = begin1[u];
  begin1[u] = e1;
  to1[e1] = v;
}
void add2(int u, int v) {
  e2++;
  next2[e2] = begin2[u];
  begin2[u] = e2;
  to2[e2] = v;
}
void pivot(int l, int e) {
  double k = a[l][e];
  a[l][e] = 1;
  for (int i = (0), _end_ = (x); i <= _end_; i++) a[l][i] /= k;
  for (int i = (0), _end_ = (y); i <= _end_; i++)
    if (i != l && fabs(a[i][e]) > 1e-8) {
      k = a[i][e];
      a[i][e] = 0;
      for (int j = (0), _end_ = (x); j <= _end_; j++) a[i][j] -= a[l][j] * k;
    }
}
int init() {
  while (1) {
    int e = 0, l = 0;
    for (int i = (1), _end_ = (y); i <= _end_; i++)
      if (a[i][0] < -1e-8 && (!l || (rand() & 1))) l = i;
    if (!l) break;
    for (int i = (1), _end_ = (x); i <= _end_; i++)
      if (a[l][i] < -1e-8 && (!e || (rand() & 1))) e = i;
    if (!e) {
      printf("-1\n");
      return 0;
    }
    pivot(l, e);
  }
  return 1;
}
int simplex() {
  while (1) {
    int e = 0, l = 0;
    double mi = 1e15;
    for (int i = (1), _end_ = (x); i <= _end_; i++)
      if (a[0][i] > 1e-8) {
        e = i;
        break;
      }
    if (!e) break;
    for (int i = (1), _end_ = (y); i <= _end_; i++)
      if (a[i][e] > 1e-8 && a[i][0] / a[i][e] < mi) {
        mi = a[i][0] / a[i][e];
        l = i;
      }
    if (!l) {
      printf("-1\n");
      return 0;
    }
    pivot(l, e);
  }
  return 1;
}
void dfs1(int u) {
  int v;
  for (int i = begin1[u]; i; i = next1[i])
    if ((v = to1[i]) != f1[u]) {
      f1[v] = u;
      dfs1(v);
    }
}
void dfs2(int u) {
  int v;
  for (int i = begin2[u]; i; i = next2[i])
    if ((v = to2[i]) != f2[u]) {
      f2[v] = u;
      dfs2(v);
    }
}
void add1(int u) {
  a[y - 1][u] = 1;
  a[y][u] = -1;
  for (int i = begin1[u]; i; i = next1[i])
    if (to1[i] != f1[u]) add1(to1[i]);
}
void add2(int u) {
  a[y - 1][u] = 1;
  a[y][u] = -1;
  for (int i = begin2[u]; i; i = next2[i])
    if (to2[i] != f2[u]) add2(to2[i]);
}
int main() {
  n = read();
  r1 = read();
  r2 = read();
  for (int i = (1), _end_ = (n); i <= _end_; i++) w[i] = read();
  for (int i = (1), _end_ = (n - 1); i <= _end_; i++) {
    int u = read(), v = read();
    add1(u, v);
    add1(v, u);
  }
  for (int i = (1), _end_ = (n - 1); i <= _end_; i++) {
    int u = read(), v = read();
    add2(u, v);
    add2(v, u);
  }
  dfs1(r1);
  dfs2(r2);
  x = n;
  int q = read();
  for (int i = (1), _end_ = (n); i <= _end_; i++) a[0][i] = w[i];
  while (q--) {
    int p = read(), v = read();
    y += 2;
    a[y - 1][0] = v;
    a[y][0] = -v;
    add1(p);
  }
  q = read();
  while (q--) {
    int p = read(), v = read();
    y += 2;
    a[y - 1][0] = v;
    a[y][0] = -v;
    add2(p);
  }
  for (int i = (1), _end_ = (n); i <= _end_; i++) {
    y++;
    a[y][0] = 1;
    a[y][i] = 1;
  }
  if (init() && simplex()) {
    printf("%d\n", int(-a[0][0] + 1e-8));
  }
  return 0;
}
}  // namespace run
int main() { return run::main(); }
