#include <bits/stdc++.h>
using namespace std;
const int maxn = 205;
const int inf = 1e6;
int n1, n2, m, costr, costb;
int lcol[maxn], rcol[maxn];
char s1[maxn], s2[maxn];
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  return x * f;
}
struct flow_with_demands {
  static const int maxn = 455;
  static const int maxm = maxn << 3;
  int cnt, tot, s, t, second, tt, cost;
  int now[maxn], sumd[maxn], pre[maxm], son[maxm], c[maxm], val[maxm];
  void init() {
    s = n1 + n2 + 1, t = s + 1, second = t + 1, tt = second + 1, tot = 1,
    cnt = tt;
  }
  void add(int a, int b, int x, int y) {
    son[++tot] = b, pre[tot] = now[a], now[a] = tot;
    c[tot] = x, val[tot] = y;
  }
  void link(int a, int b, int x, int y) {
    add(a, b, x, y);
    add(b, a, 0, -y);
  }
  void link(int a, int b, int d, int u, int y) {
    add(a, b, u - d, y);
    add(b, a, 0, -y);
    sumd[a] -= d, sumd[b] += d;
  }
  void build() {
    for (int i = 1; i <= m; i++) {
      int x = read(), y = read();
      link(x, y + n1, 1, costr);
      link(y + n1, x, 1, costb);
    }
    for (int i = 1; i <= n1; i++) {
      switch (lcol[i]) {
        case 0:
          link(s, i, inf, 0), link(i, t, inf, 0);
          break;
        case 1:
          link(s, i, 1, inf, 0);
          break;
        default:
          link(i, t, 1, inf, 0);
      }
    }
    for (int i = 1; i <= n2; i++) {
      switch (rcol[i]) {
        case 0:
          link(s, i + n1, inf, 0), link(i + n1, t, inf, 0);
          break;
        case 1:
          link(i + n1, t, 1, inf, 0);
          break;
        default:
          link(s, i + n1, 1, inf, 0);
      }
    }
    for (int i = 1; i <= t; i++) {
      if (sumd[i] > 0)
        link(second, i, sumd[i], 0);
      else if (sumd[i] < 0)
        link(i, tt, -sumd[i], 0);
    }
    link(t, s, inf, 0);
  }
  int dis[maxn], fromp[maxn], q[maxn * maxn];
  bool vis[maxn];
  bool spfa() {
    memset(dis, 63, sizeof(int) * (cnt + 1));
    memset(fromp, -1, sizeof(int) * (cnt + 1));
    int head = 1, tail = 1;
    q[head] = second;
    dis[second] = 0, vis[second] = 1;
    while (head <= tail) {
      int x = q[head++];
      for (int p = now[x]; p; p = pre[p])
        if (c[p] && dis[son[p]] > dis[x] + val[p]) {
          dis[son[p]] = dis[x] + val[p], fromp[son[p]] = p;
          if (!vis[son[p]]) q[++tail] = son[p], vis[son[p]] = 1;
        }
      vis[x] = 0;
    }
    return fromp[tt] != -1;
  }
  void min_cost() {
    int tmpflow = inf, tmpcost = 0;
    for (int x = tt; x != second; x = son[fromp[x] ^ 1])
      tmpflow = min(tmpflow, c[fromp[x]]), tmpcost += val[fromp[x]];
    cost += tmpcost * tmpflow;
    for (int x = tt; x != second; x = son[fromp[x] ^ 1])
      c[fromp[x]] -= tmpflow, c[fromp[x] ^ 1] += tmpflow;
  }
  void solve() {
    while (spfa()) min_cost();
    for (int p = now[second]; p; p = pre[p])
      if (c[p]) {
        puts("-1");
        return;
      }
    printf("%d\n", cost);
    for (int i = 1; i <= m; i++) {
      if (!c[i * 4 - 2])
        putchar('R');
      else if (!c[i * 4])
        putchar('B');
      else
        putchar('U');
    }
    puts("");
  }
} flow;
int main() {
  n1 = read(), n2 = read(), m = read(), costr = read(), costb = read();
  scanf("%s%s", s1 + 1, s2 + 1);
  for (int i = 1; i <= n1; i++) {
    switch (s1[i]) {
      case 'U':
        lcol[i] = 0;
        break;
      case 'R':
        lcol[i] = 1;
        break;
      default:
        lcol[i] = 2;
    }
  }
  for (int i = 1; i <= n2; i++) {
    switch (s2[i]) {
      case 'U':
        rcol[i] = 0;
        break;
      case 'R':
        rcol[i] = 1;
        break;
      default:
        rcol[i] = 2;
    }
  }
  flow.init();
  flow.build();
  flow.solve();
  return 0;
}
