#include <bits/stdc++.h>
using namespace std;
const int oo = 2139063143;
const int N = 510;
const int P = 1000000007;
const double eps = 1e-7;
template <typename T>
inline void sc(T &x) {
  x = 0;
  static int p;
  p = 1;
  static char c;
  c = getchar();
  while (!isdigit(c)) {
    if (c == '-') p = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c - 48);
    c = getchar();
  }
  x *= p;
}
template <typename T>
inline void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
inline void pr(T x) {
  print(x), putchar('\n');
}
template <typename T1, typename T2>
void chkmax(T1 &A, T2 B) {
  A = A >= B ? A : B;
}
template <typename T1, typename T2>
void chkmin(T1 &A, T2 B) {
  A = A <= B ? A : B;
}
struct EDGE {
  int v, w, c, nx;
} lb[N * N << 3];
int tot = 1, top[N];
int n1, n2, m, R, B;
void add(int u, int v, int w, int c) {
  lb[++tot] = (EDGE){v, w, c, top[u]}, top[u] = tot;
  lb[++tot] = (EDGE){u, 0, -c, top[v]}, top[v] = tot;
}
int S, T, sum, deg[N];
void addlr(int u, int v, int l, int r, int c) {
  add(u, v, r - l, c);
  deg[v] += l, deg[u] -= l;
  sum += l * c;
}
int FL = 0;
void link() {
  for (int i = 1; i < S; i++)
    if (deg[i] > 0)
      add(S, i, deg[i], 0), FL += deg[i];
    else if (deg[i] < 0)
      add(i, T, -deg[i], 0);
}
int dis[N], flow[N], pre[N], las[N];
bool in[N];
bool bfs() {
  for (int u = 1; u <= T; u++)
    dis[u] = flow[u] = 1e9, pre[u] = las[u] = 0, in[u] = 0;
  queue<int> q;
  dis[S] = 0, q.push(S), in[S] = 1;
  while (q.size()) {
    int u = q.front();
    q.pop(), in[u] = 0;
    for (int kb = top[u]; kb; kb = lb[kb].nx) {
      int v = lb[kb].v, w = lb[kb].w, c = lb[kb].c;
      if (w && dis[v] > dis[u] + c) {
        dis[v] = dis[u] + c;
        flow[v] = min(flow[u], w);
        pre[v] = u, las[v] = kb;
        if (!in[v]) q.push(v), in[v] = 1;
      }
    }
  }
  return pre[T];
}
int maflow, micost;
void mcmf() {
  while (bfs()) {
    int u = T, fl = flow[T];
    maflow += fl, micost += fl * dis[T];
    while (u != S) {
      lb[las[u]].w -= fl, lb[las[u] ^ 1].w += fl;
      u = pre[u];
    }
  }
}
int c[N], d[N], x[N], y[N], pos[N][2];
char sb[N];
int main() {
  sc(n1), sc(n2), sc(m), sc(R), sc(B);
  int s = n1 + n2 + 1, t = s + 1;
  S = t + 1, T = S + 1;
  scanf("%s%s", sb + 1, sb + n1 + 1);
  for (int i = 1; i <= n1; i++)
    if (sb[i] == 'R')
      addlr(s, i, 1, 1e9, 0);
    else if (sb[i] == 'B')
      addlr(i, t, 1, 1e9, 0);
    else
      addlr(s, i, 0, 1e9, 0), addlr(i, t, 0, 1e9, 0);
  for (int i = n1 + 1; i <= n1 + n2; i++)
    if (sb[i] == 'B')
      addlr(s, i, 1, 1e9, 0);
    else if (sb[i] == 'R')
      addlr(i, t, 1, 1e9, 0);
    else
      addlr(s, i, 0, 1e9, 0), addlr(i, t, 0, 1e9, 0);
  for (int i = 1; i <= m; i++) {
    sc(x[i]), sc(y[i]);
    y[i] += n1;
    addlr(x[i], y[i], 0, 1, R), pos[i][0] = tot, addlr(y[i], x[i], 0, 1, B),
                                pos[i][1] = tot;
  }
  addlr(t, s, 0, 1e9, 0);
  link();
  mcmf();
  if (maflow != FL) return pr(-1), 0;
  pr(micost + sum);
  for (int i = 1; i <= m; i++) {
    if (lb[pos[i][0]].w)
      putchar('R');
    else if (lb[pos[i][1]].w)
      putchar('B');
    else
      putchar('U');
  }
  putchar('\n');
  return 0;
}
