#include <bits/stdc++.h>
using namespace std;
const int N = 450, inf = 1e8;
int n1, n2, m, r, b, node, s, t, S, T, a[N], id[N];
char col1[N], col2[N];
int head[N], ce = 1, inq[N], dis[N], maxflow, mincost, need;
struct edge {
  int to, nxt, cap, flow, w;
} e[5000];
void lnk(int a, int b, int c, int w) {
  e[++ce] = (edge){b, head[a], c, 0, w}, head[a] = ce;
  e[++ce] = (edge){a, head[b], 0, 0, -w}, head[b] = ce;
}
bool bfs() {
  for (int i = 1; i <= node; ++i) dis[i] = inf, inq[i] = 0;
  dis[s] = 0, inq[s] = 1;
  queue<int> q;
  q.push(s);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = head[u]; i; i = e[i].nxt) {
      int v = e[i].to;
      if (e[i].cap > e[i].flow && dis[v] > dis[u] + e[i].w) {
        dis[v] = dis[u] + e[i].w;
        if (!inq[v]) q.push(v), inq[v] = 1;
      }
    }
    inq[u] = 0;
  }
  return dis[t] < inf;
}
int dfs(int u, int lim) {
  if (u == t) return mincost += dis[t] * lim, lim;
  int tag = 0;
  inq[u] = 1;
  for (int i = head[u]; i; i = e[i].nxt)
    if (e[i].cap > e[i].flow && dis[e[i].to] == dis[u] + e[i].w &&
        !inq[e[i].to]) {
      int d = dfs(e[i].to, min(lim - tag, e[i].cap - e[i].flow));
      tag += d, e[i].flow += d, e[i ^ 1].flow -= d;
      if (tag == lim) {
        inq[u] = 0;
        return tag;
      }
    }
  return tag;
}
int main() {
  scanf("%d%d%d%d%d", &n1, &n2, &m, &r, &b);
  scanf("%s", col1 + 1);
  scanf("%s", col2 + 1);
  node = n1 + n2, S = ++node, T = ++node, s = ++node, t = ++node;
  for (int i = 1; i <= n1; ++i)
    if (col1[i] == 'R')
      ++a[i], --a[S], lnk(S, i, inf, 0);
    else if (col1[i] == 'B')
      --a[i], ++a[T], lnk(i, T, inf, 0);
    else
      lnk(S, i, inf, 0), lnk(i, T, inf, 0);
  for (int i = 1; i <= n2; ++i)
    if (col2[i] == 'R')
      --a[i + n1], ++a[T], lnk(i + n1, T, inf, 0);
    else if (col2[i] == 'B')
      ++a[i + n1], --a[S], lnk(S, i + n1, inf, 0);
    else
      lnk(S, i + n1, inf, 0), lnk(i + n1, T, inf, 0);
  for (int i = 1; i <= T; ++i)
    if (a[i] > 0)
      lnk(s, i, a[i], 0), need += a[i];
    else if (a[i] < 0)
      lnk(i, t, -a[i], 0);
  lnk(T, S, inf, 0);
  for (int i = 1, u, v; i <= m; ++i)
    scanf("%d%d", &u, &v), id[i] = ce + 1, lnk(u, v + n1, 1, r),
                           lnk(v + n1, u, 1, b);
  while (bfs()) maxflow += dfs(s, inf);
  if (maxflow < need) {
    puts("-1");
    return 0;
  }
  printf("%d\n", mincost);
  for (int i = 1; i <= m; ++i)
    if (e[id[i]].flow)
      putchar('R');
    else if (e[id[i] + 2].flow)
      putchar('B');
    else
      putchar('U');
  return 0;
}
