#include <bits/stdc++.h>
using namespace std;
namespace io {
template <class free>
inline void read(free&);
inline void read(char&);
template <class f1, class... f2>
inline void read(f1&, f2&...);
inline void read(char& c) {
  while (c = getchar(), c == ' ' || c == '\n' || c == '\r')
    ;
}
template <class f1, class... f2>
inline void read(f1& x, f2&... y) {
  read(x), read(y...);
}
template <class free>
inline void read(free& x) {
  x ^= x;
  register char c;
  while (c = getchar(), c < '0' || c > '9')
    ;
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
}
}  // namespace io
using io::read;
struct point {
  int next, to, w, w1;
} ar[4050];
bool is[4050];
int ps, pt, a1[4050], a2[4050], pre[4050];
int tot, a[4050], head[4050], art(1), fee;
int ps1, pt1, T[4050], flow[4050], dis[4050];
inline bool bfs();
inline void link(int, int, int, int);
int main() {
  int n1, n2, m, r, b, ans(0);
  read(n1, n2, m, r, b), tot = n1 + n2;
  for (int i(1); i <= tot; ++i) {
    char c;
    switch (read(c), c) {
      case 'U':
        a[i] = -1;
        break;
      case 'R':
        a[i] = 0;
        break;
      case 'B':
        a[i] = 1;
        break;
    }
  }
  ps = ++tot, pt = ++tot;
  for (int i(1); i <= n1; ++i) {
    if (!~a[i]) {
      link(ps, i, 0x3f3f3f3f, 0), link(i, pt, 0x3f3f3f3f, 0);
      continue;
    }
    if (a[i])
      --a1[i], ++a1[pt], link(i, pt, 0x3f3f3f3f, 0);
    else
      ++a1[i], --a1[ps], link(ps, i, 0x3f3f3f3f, 0);
  }
  for (int i(n1 + 1); i <= n1 + n2; ++i) {
    if (!~a[i]) {
      link(ps, i, 0x3f3f3f3f, 0), link(i, pt, 0x3f3f3f3f, 0);
      continue;
    }
    if (a[i])
      ++a1[i], --a1[ps], link(ps, i, 0x3f3f3f3f, 0);
    else
      --a1[i], ++a1[pt], link(i, pt, 0x3f3f3f3f, 0);
  }
  for (int i(1), u, v; i <= m; ++i)
    read(u, v), link(u, v + n1, 1, r), a2[i] = art, link(v + n1, u, 1, b);
  link(pt, ps, 0x3f3f3f3f, 0), ps1 = ++tot, pt1 = ++tot;
  for (int i(1); i <= n1 + n2 + 2; ++i) {
    if (!a1[i]) continue;
    if (a1[i] > 0)
      link(ps1, i, a1[i], 0);
    else
      link(i, pt1, -a1[i], 0);
  }
  while (bfs())
    ;
  for (int i(head[ps1]); i; i = ar[i].next)
    if (ar[i].w) return puts("-1"), 0;
  printf("%d\n", fee);
  for (int i(1); i <= m; ++i)
    if (ar[a2[i]].w)
      putchar('R');
    else if (ar[a2[i] + 2].w)
      putchar('B');
    else
      putchar('U');
  return 0;
}
inline bool bfs() {
  memset(dis, 0x3f, tot + 1 << 2);
  int L(0), R(1);
  dis[T[1] = ps1] = 0, flow[ps1] = 0x3f3f3f3f;
  while (L++ ^ R)
    for (int i(head[is[T[L = L ^ 4050 ? L : 0]] = 0, T[L]]), i1; i;
         i = ar[i].next)
      if (ar[i].w && dis[i1 = ar[i].to] > dis[T[L]] + ar[i].w1) {
        dis[i1] = dis[T[L]] + ar[i].w1;
        flow[i1] = min(flow[T[L]], ar[i].w), pre[i1] = i;
        if (is[i1]) continue;
        is[T[++R, R = R ^ 4050 ? R : 4050] = i1] = 1;
      }
  if (dis[pt1] >= 0x3f3f3f3f) return false;
  for (int i(pt1); pre[i]; i = ar[pre[i] ^ 1].to)
    ar[pre[i]].w -= flow[pt1], ar[pre[i] ^ 1].w += flow[pt1];
  return fee += dis[pt1] * flow[pt1], true;
}
inline void link(int u, int v, int w, int w1) {
  ar[++art] = {head[u], v, w, w1}, head[u] = art;
  ar[++art] = {head[v], u, 0, -w1}, head[v] = art;
}
