#include <bits/stdc++.h>
using namespace std;
const int INF = int(1e9) + 7;
const int maxd = int(1e5) + 11;
const int maxe = int(1e5) + 11;
const int maxn = int(1e5) + 11;
int tot = 0;
int head[maxd];
int S, T;
struct Edge {
  int from, to, cap, cost, next;
  Edge() {}
  Edge(int x, int y, int a, int b, int c)
      : from(x), to(y), cap(a), cost(b), next(c) {}
} eage[maxe * 2];
int add(int x, int y, int a, int b) {
  int k = tot;
  eage[tot] = Edge(x, y, a, b, head[x]), head[x] = tot++;
  eage[tot] = Edge(y, x, 0, -b, head[y]), head[y] = tot++;
  return k;
}
bool used[maxd], vis[maxd];
int dis[maxd], ans, fl;
queue<int> que;
bool spfa() {
  for (int i = 0; i < maxd; i++) used[i] = false, dis[i] = INF, vis[i] = false;
  while (que.size()) que.pop();
  que.push(S);
  used[S] = true;
  dis[S] = 0;
  while (que.size()) {
    int u = que.front();
    que.pop();
    used[u] = false;
    for (int i = head[u]; ~i; i = eage[i].next)
      if (eage[i].cap && dis[eage[i].to] > dis[u] + eage[i].cost) {
        int v = eage[i].to;
        dis[v] = dis[u] + eage[i].cost;
        if (!used[v]) {
          used[v] = true;
          que.push(v);
        }
      }
  }
  return (dis[T] < INF);
}
int dfs(int u, int flow) {
  if (u == T) {
    ans += dis[u] * flow;
    return flow;
  }
  vis[u] = true;
  int ret = 0;
  for (int i = head[u]; ~i; i = eage[i].next)
    if (!vis[eage[i].to] && eage[i].cap &&
        dis[eage[i].to] == dis[u] + eage[i].cost) {
      int v = eage[i].to;
      int newf = dfs(v, min(flow, eage[i].cap));
      eage[i].cap -= newf;
      eage[i ^ 1].cap += newf;
      ret += newf;
      flow -= newf;
      if (!flow) break;
    }
  if (!ret) dis[u] = -1;
  return ret;
}
pair<int, int> MCMF() {
  while (spfa()) fl += dfs(S, INF);
  return make_pair(ans, fl);
}
int n1, n2, m, r, b, id1[maxn], id2[maxn], idnum, s, t, low, iddr[maxn],
    iddb[maxn];
pair<int, int> q[maxn];
char s1[maxn], s2[maxn];
inline int add1(int x, int y, int l, int r, int w) {
  int k = add(x, y, r - l, w);
  if (l) {
    add(S, y, 1, 0);
    add(x, T, 1, 0);
  }
  return k;
}
int main() {
  memset(head, -1, sizeof head);
  scanf("%d%d%d%d%d", &n1, &n2, &m, &r, &b);
  s = ++idnum;
  t = ++idnum;
  S = ++idnum;
  T = ++idnum;
  for (int i = 1; i <= n1; i++) id1[i] = ++idnum;
  for (int i = 1; i <= n2; i++) id2[i] = ++idnum;
  add1(t, s, 0, INF, 0);
  scanf("%s%s", s1 + 1, s2 + 1);
  for (int i = 1; i <= n1; i++)
    if (s1[i] == 'R')
      add1(s, id1[i], 1, INF, 0), low++;
    else if (s1[i] == 'B')
      add1(id1[i], t, 1, INF, 0), low++;
    else {
      add1(s, id1[i], 0, INF, 0);
      add1(id1[i], t, 0, INF, 0);
    }
  for (int i = 1; i <= n2; i++)
    if (s2[i] == 'R')
      add1(id2[i], t, 1, INF, 0), low++;
    else if (s2[i] == 'B')
      add1(s, id2[i], 1, INF, 0), low++;
    else {
      add1(s, id2[i], 0, INF, 0);
      add1(id2[i], t, 0, INF, 0);
    }
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &q[i].first, &q[i].second);
    iddr[i] = add1(id1[q[i].first], id2[q[i].second], 0, 1, r);
    iddb[i] = add1(id2[q[i].second], id1[q[i].first], 0, 1, b);
  }
  pair<int, int> now = MCMF();
  if (now.second != low) {
    printf("-1\n");
    return 0;
  }
  printf("%d\n", now.first);
  for (int i = 1; i <= m; i++)
    if (eage[iddr[i]].cap == 0 && eage[iddb[i]].cap == 1)
      printf("R");
    else if (eage[iddr[i]].cap == 1 && eage[iddb[i]].cap == 0)
      printf("B");
    else
      printf("U");
  return 0;
}
