#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10, M = 1e6 + 10, INF = 1e9;
int sum, ans, S, T, cnt, tot = 1, s, t, n1, n2, m, R, B, de[N], mark[N],
                         head[N], pre[N], dis[N], to[M], ne[M], w[M], c[M];
char s1[N], s2[N];
void add(int x, int y, int l, int r) {
  to[++tot] = y;
  ne[tot] = head[x];
  w[tot] = l;
  c[tot] = r;
  head[x] = tot;
}
void link(int x, int y, int l, int r, int z) {
  ans += l * z;
  de[x] -= l, de[y] += l;
  add(x, y, r - l, z), add(y, x, 0, -z);
}
bool Spfa() {
  for (int i = 1; i <= cnt; i++) dis[i] = INF;
  queue<int> q;
  q.push(S);
  dis[S] = 0;
  while (q.size()) {
    int x = q.front();
    q.pop();
    mark[x] = 0;
    for (int i = head[x]; i; i = ne[i]) {
      int y = to[i];
      if (!w[i]) continue;
      if (dis[y] > dis[x] + c[i]) {
        pre[y] = i;
        dis[y] = dis[x] + c[i];
        if (!mark[y]) mark[y] = 1, q.push(y);
      }
    }
  }
  return dis[T] != INF;
}
void Ek() {
  int flow = INF;
  for (int i = T; i != S; i = to[pre[i] ^ 1]) flow = min(flow, w[pre[i]]);
  for (int i = T; i != S; i = to[pre[i] ^ 1])
    w[pre[i]] -= flow, w[pre[i] ^ 1] += flow;
  sum += 2 * flow;
  ans += dis[T] * flow;
}
int main() {
  scanf("%d%d%d%d%d%s%s", &n1, &n2, &m, &R, &B, s1 + 1, s2 + 1);
  cnt = n1 + n2, s = ++cnt, t = ++cnt, S = ++cnt, T = ++cnt;
  for (int i = 1, x, y; i <= m; i++) {
    scanf("%d%d", &x, &y);
    link(x, n1 + y, 0, 1, R);
    link(n1 + y, x, 0, 1, B);
  }
  for (int i = 1; i <= n1; i++) {
    if (s1[i] == 'R') link(s, i, 1, INF, 0);
    if (s1[i] == 'B') link(i, t, 1, INF, 0);
    if (s1[i] == 'U') link(s, i, 0, INF, 0), link(i, t, 0, INF, 0);
  }
  for (int i = 1; i <= n2; i++) {
    if (s2[i] == 'R') link(n1 + i, t, 1, INF, 0);
    if (s2[i] == 'B') link(s, n1 + i, 1, INF, 0);
    if (s2[i] == 'U') link(s, n1 + i, 0, INF, 0), link(n1 + i, t, 0, INF, 0);
  }
  link(t, s, 0, INF, 0);
  for (int i = 1; i <= cnt - 2; i++) {
    if (de[i] > 0)
      link(S, i, 0, de[i], 0);
    else
      link(i, T, 0, -de[i], 0);
    sum -= abs(de[i]);
  }
  while (Spfa()) Ek();
  if (sum) return puts("-1"), 0;
  printf("%d\n", ans);
  for (int i = 1; i <= m * 2; i += 2) {
    if (w[i << 1]) {
      if (w[(i + 1) << 1])
        putchar('U');
      else
        putchar('B');
    } else
      putchar('R');
  }
  return 0;
}
