#include <bits/stdc++.h>
long long gi() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) f ^= ch == '-', ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return f ? x : -x;
}
char cL[210], cR[210];
int Cost, fir[410], dis[1000010], nxt[1000010], w[1000010], cost[1000010],
    id = 1;
void link(int a, int b, int c, int d) {
  nxt[++id] = fir[a], fir[a] = id, dis[id] = b, w[id] = c, cost[id] = d;
  nxt[++id] = fir[b], fir[b] = id, dis[id] = a, w[id] = 0, cost[id] = -d;
}
int S, T;
int que[200010], inq[410], cnt[410], hd, tl;
int dist[410], lst[410], E1[210], E2[210];
bool Mincost() {
  hd = tl = 0;
  memset(cnt, 0, sizeof cnt);
  que[tl++] = S;
  memset(dist, 63, sizeof dist);
  dist[S] = 0;
  while (hd ^ tl) {
    int x = que[hd++];
    if (++cnt[x] == T) {
      int Flow = 1e9;
      for (int i = lst[x]; dis[i ^ 1] != x; i = lst[dis[i ^ 1]])
        Flow = std::min(Flow, w[i]);
      for (int i = lst[x]; dis[i ^ 1] != x; i = lst[dis[i ^ 1]])
        Cost += cost[i] * Flow, w[i] -= Flow, w[i ^ 1] += Flow;
      return 1;
    }
    for (int i = fir[x]; i; i = nxt[i])
      if (w[i] && dist[dis[i]] > dist[x] + cost[i]) {
        dist[dis[i]] = dist[x] + cost[i];
        lst[dis[i]] = i;
        if (!inq[dis[i]]) inq[dis[i]] = 1, que[tl++] = dis[i];
      }
    inq[x] = 0;
  }
  if (dist[T] >= 0) return 0;
  int Flow = 1e9;
  for (int i = lst[T]; i; i = lst[dis[i ^ 1]]) Flow = std::min(Flow, w[i]);
  for (int i = lst[T]; i; i = lst[dis[i ^ 1]])
    Cost += cost[i] * Flow, w[i] -= Flow, w[i ^ 1] += Flow;
  return 1;
}
int main() {
  int L = gi(), R = gi(), m = gi(), r = gi(), b = gi(), u, v;
  scanf("%s", cL + 1);
  scanf("%s", cR + 1);
  S = L + R + 1, T = L + R + 2;
  for (int i = 1; i <= L; ++i)
    if (cL[i] == 'B')
      link(i, T, 1, -100000), Cost += 100000, link(i, T, 2333, 0);
    else if (cL[i] == 'R')
      link(S, i, 1, -100000), Cost += 100000, link(S, i, 2333, 0);
    else
      link(S, i, 2333, 0), link(i, T, 2333, 0);
  for (int i = 1; i <= R; ++i)
    if (cR[i] == 'R')
      link(i + L, T, 1, -100000), Cost += 100000, link(i + L, T, 2333, 0);
    else if (cR[i] == 'B')
      link(S, i + L, 1, -100000), Cost += 100000, link(S, i + L, 2333, 0);
    else
      link(S, i + L, 2333, 0), link(i + L, T, 2333, 0);
  for (int i = 1; i <= m; ++i)
    u = gi(), v = gi(), link(u, v + L, 1, r), E1[i] = id, link(v + L, u, 1, b),
    E2[i] = id;
  while (Mincost())
    ;
  if (Cost > 100000) Cost = -1;
  printf("%d\n", Cost);
  if (Cost != -1)
    for (int i = 1; i <= m; ++i) putchar(w[E1[i]] ? 'R' : w[E2[i]] ? 'B' : 'U');
  return 0;
}
