#include <bits/stdc++.h>
using namespace std;
inline int read() {
  register int x = 0, f = 1;
  register char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = 0;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + (ch ^ '0');
    ch = getchar();
  }
  return f ? x : -x;
}
const int N = 4e2 + 10, inf = 0x3f3f3f3f;
int n1, n2, m, R, B, r[N], b[N];
int s, t, ns, nt, num = 1, head[N], deg[N], dis[N], vis[N], pre[N], id[N],
                  flow[N];
int f, c, sum;
char s1[N], s2[N];
struct edge {
  int to, val, flo, next;
} e[N * 10];
inline void add(int u, int v, int w, int f) {
  e[++num] = (edge){v, w, f, head[u]}, head[u] = num;
  e[++num] = (edge){u, -w, 0, head[v]}, head[v] = num;
}
inline void link(int u, int v, int w, int mn, int mx) {
  add(u, v, w, mx - mn);
  deg[u] -= mn, deg[v] += mn;
}
inline bool Bfs() {
  queue<int> q;
  memset(vis, 0, sizeof(vis));
  memset(dis, 0x3f, sizeof(dis));
  q.push(ns);
  dis[ns] = 0, vis[ns] = 1, flow[ns] = inf;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    vis[u] = 0;
    for (int i = head[u]; i; i = e[i].next) {
      int v = e[i].to;
      if (!e[i].flo || dis[v] <= dis[u] + e[i].val) continue;
      dis[v] = dis[u] + e[i].val;
      id[v] = i;
      pre[v] = u;
      flow[v] = min(flow[u], e[i].flo);
      if (!vis[v]) vis[v] = 1, q.push(v);
    }
  }
  return dis[nt] < inf;
}
inline void Work() {
  int p = nt;
  f += flow[nt];
  c += dis[nt] * flow[nt];
  while (p ^ ns) {
    e[id[p]].flo -= flow[nt], e[id[p] ^ 1].flo += flow[nt], p = pre[p];
  }
}
int main() {
  n1 = read(), n2 = read(), m = read(), R = read(), B = read();
  s = n1 + n2 + 1, t = s + 1;
  ns = t + 1, nt = t + 2;
  scanf("%s%s", s1 + 1, s2 + 1);
  for (int t = (1), ed = (m); t <= ed; ++t) {
    int u = read(), v = read() + n1;
    link(u, v, R, 0, 1), r[t] = num;
    link(v, u, B, 0, 1), b[t] = num;
  }
  for (int i = (1), ed = (n1); i <= ed; ++i) {
    if (s1[i] == 'R')
      link(s, i, 0, 1, inf);
    else if (s1[i] == 'B')
      link(i, t, 0, 1, inf);
    else
      link(s, i, 0, 0, inf), link(i, t, 0, 0, inf);
  }
  for (int i = (1), ed = (n2); i <= ed; ++i) {
    if (s2[i] == 'R')
      link(n1 + i, t, 0, 1, inf);
    else if (s2[i] == 'B')
      link(s, n1 + i, 0, 1, inf);
    else
      link(s, n1 + i, 0, 0, inf), link(n1 + i, t, 0, 0, inf);
  }
  add(t, s, 0, inf);
  for (int i = (1), ed = (t); i <= ed; ++i) {
    if (deg[i] > 0)
      add(ns, i, 0, deg[i]), sum += deg[i];
    else
      add(i, nt, 0, -deg[i]);
  }
  while (Bfs()) Work();
  if (f != sum) {
    puts("-1");
    return 0;
  }
  printf("%d\n", c);
  for (int i = (1), ed = (m); i <= ed; ++i) {
    if (e[r[i]].flo)
      printf("R");
    else if (e[b[i]].flo)
      printf("B");
    else
      printf("U");
  }
  puts("");
  return 0;
}
