#include <bits/stdc++.h>
using namespace std;
const int maxn = 405, Inf = 1e9;
inline int gi() {
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  int sum = 0;
  while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
  return sum;
}
int n1, n2, m, r, b, R[maxn], B[maxn];
char s1[maxn], s2[maxn];
struct edge {
  int to, next, cap, w;
} e[maxn * 10];
int s, t, S, T, h[maxn * 2], in[maxn], out[maxn], tot = 1;
int pe[maxn * 2], pu[maxn * 2], dis[maxn * 2];
queue<int> q;
bool vis[maxn * 2];
inline void link(int u, int v, int w, int x) {
  e[++tot] = (edge){v, h[u], w, x};
  h[u] = tot;
  e[++tot] = (edge){u, h[v], 0, -x};
  h[v] = tot;
}
inline void add(int u, int v, int l, int r, int x) {
  link(u, v, r - l, x);
  out[u] += l;
  in[v] += l;
}
bool spfa() {
  memset(dis + 1, 63, sizeof(int) * T);
  dis[S] = 0;
  vis[S] = 1;
  q.push(S);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    vis[u] = 0;
    for (int i = h[u], v; v = e[i].to, i; i = e[i].next)
      if (e[i].cap && dis[v] > dis[u] + e[i].w) {
        dis[v] = dis[u] + e[i].w;
        pu[v] = u;
        pe[v] = i;
        if (!vis[v]) vis[v] = 1, q.push(v);
      }
  }
  return dis[T] < 1e9;
}
void min_cost_max_flow() {
  int flow = 0, cost = 0;
  while (spfa()) {
    int u = T, f = 1e9, c = 0;
    while (u != S) {
      f = min(f, e[pe[u]].cap);
      c += e[pe[u]].w;
      u = pu[u];
    }
    flow += f;
    cost += c * f;
    u = T;
    while (u != S) {
      e[pe[u]].cap -= f;
      e[pe[u] ^ 1].cap += f;
      u = pu[u];
    }
  }
  for (int i = h[S]; i; i = e[i].next)
    if (e[i].cap) puts("-1"), exit(0);
  printf("%d\n", cost);
}
int main() {
  n1 = gi();
  n2 = gi();
  m = gi();
  r = gi();
  b = gi();
  scanf("%s%s", s1 + 1, s2 + 1);
  s = n1 + n2 + 1;
  t = s + 1;
  for (int u, v, i = 1; i <= m; ++i) {
    u = gi();
    v = gi();
    add(u, v + n1, 0, 1, r);
    R[i] = tot;
    add(v + n1, u, 0, 1, b);
    B[i] = tot;
  }
  for (int i = 1; i <= n1; ++i)
    if (s1[i] == 'R')
      add(s, i, 1, Inf, 0);
    else if (s1[i] == 'B')
      add(i, t, 1, Inf, 0);
    else
      add(s, i, 0, Inf, 0), add(i, t, 0, Inf, 0);
  for (int i = 1; i <= n2; ++i)
    if (s2[i] == 'R')
      add(i + n1, t, 1, Inf, 0);
    else if (s2[i] == 'B')
      add(s, i + n1, 1, Inf, 0);
    else
      add(s, i + n1, 0, Inf, 0), add(i + n1, t, 0, Inf, 0);
  add(t, s, 0, Inf, 0);
  S = t + 1;
  T = S + 1;
  for (int i = 1; i <= t; ++i)
    if (in[i] >= out[i])
      link(S, i, in[i] - out[i], 0);
    else
      link(i, T, out[i] - in[i], 0);
  min_cost_max_flow();
  for (int i = 1; i <= m; ++i)
    if (e[B[i]].cap)
      putchar('B');
    else if (e[R[i]].cap)
      putchar('R');
    else
      putchar('U');
  return 0;
}
