You are given a bipartite graph: the first part of this graph contains n_1 vertices, the second part contains n_2 vertices, and there are m edges. The graph can contain multiple edges.

Initially, each edge is colorless. For each edge, you may either leave it uncolored (it is free), paint it red (it costs r coins) or paint it blue (it costs b coins). No edge can be painted red and blue simultaneously.

There are three types of vertices in this graph — colorless, red and blue. Colored vertices impose additional constraints on edges' colours:

  * for each red vertex, the number of red edges indicent to it should be strictly greater than the number of blue edges incident to it; 
  * for each blue vertex, the number of blue edges indicent to it should be strictly greater than the number of red edges incident to it. 



Colorless vertices impose no additional constraints.

Your goal is to paint some (possibly none) edges so that all constraints are met, and among all ways to do so, you should choose the one with minimum total cost. 

Input

The first line contains five integers n_1, n_2, m, r and b (1 ≤ n_1, n_2, m, r, b ≤ 200) — the number of vertices in the first part, the number of vertices in the second part, the number of edges, the amount of coins you have to pay to paint an edge red, and the amount of coins you have to pay to paint an edge blue, respectively.

The second line contains one string consisting of n_1 characters. Each character is either U, R or B. If the i-th character is U, then the i-th vertex of the first part is uncolored; R corresponds to a red vertex, and B corresponds to a blue vertex.

The third line contains one string consisting of n_2 characters. Each character is either U, R or B. This string represents the colors of vertices of the second part in the same way.

Then m lines follow, the i-th line contains two integers u_i and v_i (1 ≤ u_i ≤ n_1, 1 ≤ v_i ≤ n_2) denoting an edge connecting the vertex u_i from the first part and the vertex v_i from the second part.

The graph may contain multiple edges.

Output

If there is no coloring that meets all the constraints, print one integer -1.

Otherwise, print an integer c denoting the total cost of coloring, and a string consisting of m characters. The i-th character should be U if the i-th edge should be left uncolored, R if the i-th edge should be painted red, or B if the i-th edge should be painted blue. If there are multiple colorings with minimum possible cost, print any of them.

Examples

Input


3 2 6 10 15
RRB
UB
3 2
2 2
1 2
1 1
2 1
1 1


Output


35
BUURRU


Input


3 1 3 4 5
RRR
B
2 1
1 1
3 1


Output


-1


Input


3 1 3 4 5
URU
B
2 1
1 1
3 1


Output


14
RBB
#include <bits/stdc++.h>
using namespace std;
struct edge {
  long long to, cap, cost, rev, id;
  edge() {}
  edge(long long a, long long b, long long c, long long d, long long e) {
    to = a, cap = b, cost = c, rev = d, id = e;
  }
};
long long n1, n2, m, r, b;
char c[405], ansc[405];
long long S, T;
vector<pair<long long, long long> > g[405];
vector<edge> G[405];
long long dist[405];
long long prevv[405], preve[405];
void BellmanFord() {
  for (long long i = 1; i <= T; i++) dist[i] = 1e10;
  dist[S] = 0, prevv[S] = -1;
  bool update = true;
  while (update) {
    update = false;
    for (long long i = 1; i <= T; i++) {
      for (long long j = 0; j < G[i].size(); j++) {
        if (G[i][j].cap == 0) continue;
        if (dist[G[i][j].to] > dist[i] + G[i][j].cost) {
          dist[G[i][j].to] = dist[i] + G[i][j].cost;
          prevv[G[i][j].to] = i;
          preve[G[i][j].to] = j;
          update = true;
        }
      }
    }
  }
}
void add_edge(long long from, long long to, long long cap, long long cost,
              long long id) {
  G[from].push_back(edge(to, cap, cost, G[to].size(), id));
  G[to].push_back(edge(from, 0, -cost, G[from].size() - 1, -1));
}
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n1 >> n2 >> m >> r >> b;
  for (long long i = 1; i <= n1; i++) cin >> c[i];
  for (long long i = 1; i <= n2; i++) cin >> c[n1 + i];
  long long u, v;
  for (long long i = 1; i <= m; i++) {
    cin >> u >> v;
    v += n1;
    g[u].push_back(pair<long long, long long>(v, i));
    g[v].push_back(pair<long long, long long>(u, i));
  }
  long long V = n1 + n2, M = 1000000, ans = 0;
  S = V + 1, T = V + 2;
  for (long long i = 1; i <= V; i++) {
    if (c[i] == 'U') add_edge(S, i, 1e10, 0, -1), add_edge(i, T, 1e10, 0, -1);
    if ((i <= n1 && c[i] == 'R') || (i > n1 && c[i] == 'B')) {
      add_edge(S, i, 1e10, 0, -1);
      add_edge(S, i, 1, -M, -1);
      ans += M;
    }
    if ((i <= n1 && c[i] == 'B') || (i > n1 && c[i] == 'R')) {
      add_edge(i, T, 1e10, 0, -1);
      add_edge(i, T, 1, -M, -1);
      ans += M;
    }
    for (long long j = 0; j < g[i].size(); j++)
      add_edge(i, g[i][j].first, 1, (i <= n1) ? r : b, g[i][j].second);
  }
  long long f = 1e10;
  while (f > 0) {
    BellmanFord();
    if (dist[T] >= 0) break;
    long long p = T, flow = f;
    while (prevv[p] != -1) {
      flow = min(flow, G[prevv[p]][preve[p]].cap);
      p = prevv[p];
    }
    p = T;
    while (prevv[p] != -1) {
      G[prevv[p]][preve[p]].cap -= flow;
      G[p][G[prevv[p]][preve[p]].rev].cap += flow;
      p = prevv[p];
    }
    f -= flow;
    ans += dist[T] * flow;
  }
  for (int i = 1; i <= T; i++) {
    for (int j = 0; j < G[i].size(); j++) {
      if (G[i][j].cost <= -M && G[i][j].cap > 0) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << ans << endl;
  for (long long i = 1; i <= m; i++) ansc[i] = 'U';
  for (long long i = 1; i <= V; i++) {
    for (long long j = 0; j < G[i].size(); j++) {
      if (G[i][j].id == -1) continue;
      if (G[i][j].cap == 0) {
        if (i <= n1)
          ansc[G[i][j].id] = 'R';
        else
          ansc[G[i][j].id] = 'B';
      }
    }
  }
  for (long long i = 1; i <= m; i++) cout << ansc[i];
  cout << endl;
  return 0;
}
