#include <bits/stdc++.h>
using namespace std;
int N, M, K, s, t, r, b, tot, R[501], B[501], fst[501],
    cnt = 1, to[100001], flow[100001], len[100001], nxt[100001], mflow[501],
    pre[501];
long long dis[501], ans;
bool in[501];
int get() {
  int x = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x;
}
void add(int u, int v, int f, int l) {
  to[++cnt] = v, flow[cnt] = f, len[cnt] = l, nxt[cnt] = fst[u], fst[u] = cnt;
  to[++cnt] = u, flow[cnt] = 0, len[cnt] = -l, nxt[cnt] = fst[v], fst[v] = cnt;
}
bool spfa() {
  memset(dis, 0x3f, sizeof(dis));
  memset(in, 0, sizeof(in));
  queue<int> q;
  q.push(s);
  dis[s] = 0;
  in[s] = 1;
  mflow[s] = 0x3fffffff;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    in[u] = 0;
    for (int i = fst[u]; i; i = nxt[i])
      if (flow[i] && dis[to[i]] > dis[u] + len[i]) {
        dis[to[i]] = dis[u] + len[i];
        mflow[to[i]] = min(mflow[u], flow[i]);
        pre[to[i]] = i;
        if (!in[to[i]]) q.push(to[i]), in[to[i]] = 1;
      }
  }
  return dis[t] != 0x3f3f3f3f3f3f3f3f;
}
void upd() {
  int x = t;
  while (x != s) {
    x = pre[x];
    flow[x] -= mflow[t], flow[x ^ 1] += mflow[t], x = to[x ^ 1];
  }
  ans += dis[t] * mflow[t];
}
int main() {
  N = get(), M = get(), K = get(), r = get(), b = get(), s = 0, t = N + M + 1;
  for (int i = 1; i <= N; i++) {
    char c;
    cin >> c;
    c == 'R' || c == 'B' ? tot++,
        c == 'R'         ? add(s, i, 1, -0x3fffffff),
        add(s, i, 0x3fffffff, 0)
                 : (add(i, t, 1, -0x3fffffff), add(i, t, 0x3fffffff, 0))
                 : (add(s, i, 0x3fffffff, 0), add(i, t, 0x3fffffff, 0));
  }
  for (int i = 1; i <= M; i++) {
    char c;
    cin >> c;
    c == 'R' || c == 'B' ? tot++,
        c == 'R'         ? add(i + N, t, 1, -0x3fffffff),
        add(i + N, t, 0x3fffffff, 0)
                 : (add(s, i + N, 1, -0x3fffffff), add(s, i + N, 0x3fffffff, 0))
                 : (add(s, i + N, 0x3fffffff, 0), add(i + N, t, 0x3fffffff, 0));
  }
  for (int i = 1; i <= K; i++) {
    int u, v;
    cin >> u >> v;
    add(u, v + N, 1, r);
    R[i] = cnt - 1;
    add(v + N, u, 1, b);
    B[i] = cnt - 1;
  }
  while (spfa()) {
    if (dis[t] <= 0)
      upd();
    else if (ans + tot * 0x3fffffff < 0x3fffffff)
      break;
  }
  ans += 1ll * tot * 0x3fffffff;
  if (ans > 0x3fffffff) {
    cout << -1 << endl;
    return 0;
  }
  cout << ans << endl;
  for (int i = 1; i <= K; i++)
    cout << (!flow[R[i]] ? 'R' : !flow[B[i]] ? 'B' : 'U');
  return 0;
}
