#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000;
const int maxm = 20000;
struct node {
  int to, nxt, w, cost;
} e[maxm];
inline int read() {
  int x = 0, t = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') t = -1, ch = getchar();
  while (ch <= '9' && ch >= '0') x = x * 10 + ch - 48, ch = getchar();
  return x * t;
}
int head[maxn], vis[maxn], tot = 1, d[maxn];
int dist[maxn], cost, ss, tt, st, ed;
inline void add(int u, int v, int w, int c) {
  e[++tot].to = v, e[tot].w = w, e[tot].cost = c, e[tot].nxt = head[u],
  head[u] = tot;
  e[++tot].to = u, e[tot].w = 0, e[tot].cost = -c, e[tot].nxt = head[v],
  head[v] = tot;
}
int ans = 0;
int pre[maxn], id[maxn];
bool spfa() {
  memset(vis, 0, sizeof vis);
  for (int i = 0; i < maxn; ++i) dist[i] = 1061109567;
  dist[ss] = 0, vis[ss] = 1;
  queue<int> q;
  q.push(ss);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    vis[u] = 0;
    for (int i = head[u]; i; i = e[i].nxt) {
      int d = e[i].to;
      if (dist[d] > dist[u] + e[i].cost && e[i].w) {
        dist[d] = dist[u] + e[i].cost;
        pre[d] = u, id[d] = i;
        if (vis[d] == 0) {
          q.push(d);
          vis[d] = 1;
        }
      }
    }
  }
  if (dist[tt] == 1061109567) return 0;
  return 1;
}
int n1, n2;
int dinic() {
  while (spfa()) {
    int u = tt;
    ++ans;
    while (u) {
      e[id[u]].w--, e[id[u] ^ 1].w++;
      u = pre[u];
    }
    cost += dist[tt];
  }
  return ans;
}
int m, x, y;
int ch, r, b;
char c1[220], c2[220];
int main() {
  n1 = read(), n2 = read(), m = read(), r = read(), b = read();
  scanf("%s%s", c1, c2);
  st = n1 + n2 + 1, ed = st + 1;
  ss = ed + 1, tt = ed + 2;
  for (int i = 0; i < m; ++i) {
    x = read(), y = read();
    add(x, y + n1, 1, r);
    add(y + n1, x, 1, b);
  }
  for (int i = 1; i <= n1; ++i) {
    if (c1[i - 1] == 'R')
      add(st, i, 1061109567 - 1, 0), d[st]--, d[i]++;
    else if (c1[i - 1] == 'B')
      add(i, ed, 1061109567 - 1, 0), --d[i], ++d[ed];
    else
      add(i, ed, 1061109567, 0), add(st, i, 1061109567, 0);
  }
  for (int i = 1; i <= n2; ++i) {
    if (c2[i - 1] == 'R')
      add(i + n1, ed, 1061109567 - 1, 0), --d[i + n1], ++d[ed];
    else if (c2[i - 1] == 'B')
      add(st, i + n1, 1061109567 - 1, 0), --d[st], ++d[i + n1];
    else
      add(i + n1, ed, 1061109567, 0), add(st, i + n1, 1061109567, 0);
  }
  add(ed, st, 1061109567, 0);
  for (int i = 1; i <= n1 + n2 + 2; ++i) {
    if (d[i] > 0)
      add(ss, i, d[i], 0), ch += d[i];
    else if (d[i] < 0)
      add(i, tt, -d[i], 0);
  }
  dinic();
  if (ch != ans) {
    printf("-1\n");
  } else {
    printf("%d\n", cost);
    for (int i = 0; i < m; i++) {
      if (!e[4 * i + 2].w)
        printf("R");
      else if (!e[4 * i + 4].w)
        printf("B");
      else
        printf("U");
    }
    printf("\n");
  }
  return 0;
}
