#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
int n1, n2, m, R, B, S, T, ss, tt, tf[415], sum, flow, ans;
char a[415], b[415];
int fir[415], cur[415], nxt[2505], to[2505], c[2505], w[2505], tot = 1;
void line(int x, int y, int z, int v) {
  nxt[++tot] = fir[x], fir[x] = tot, to[tot] = y, c[tot] = z, w[tot] = v;
  nxt[++tot] = fir[y], fir[y] = tot, to[tot] = x, c[tot] = 0, w[tot] = -v;
}
int dis[415];
queue<int> q;
bool inq[415], vis[415];
bool SPFA() {
  memset(dis, 0x3f, (T + 1) << 2), q.push(T), dis[T] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop(), inq[u] = 0;
    for (int i = fir[u], v; i; i = nxt[i])
      if (c[i ^ 1] && dis[v = to[i]] > dis[u] + w[i ^ 1]) {
        dis[v] = dis[u] + w[i ^ 1];
        if (!inq[v]) inq[v] = 1, q.push(v);
      }
  }
  return dis[S] < inf;
}
int aug(int u, int augco) {
  if (u == T) {
    ans += dis[S] * augco;
    return augco;
  }
  int need = augco, dt;
  vis[u] = 1;
  for (int &i = cur[u], v; i; i = nxt[i])
    if (c[i] && !vis[v = to[i]] && dis[u] == dis[v] + w[i]) {
      dt = aug(v, min(c[i], need)), c[i] -= dt, c[i ^ 1] += dt;
      if (!(need -= dt)) break;
    }
  return vis[u] = 0, augco - need;
}
int main() {
  scanf("%d%d%d%d%d%s%s", &n1, &n2, &m, &R, &B, a + 1, b + 1);
  S = 0, T = n1 + n2 + 1;
  for (int i = 1, x, y; i <= m; i++)
    scanf("%d%d", &x, &y), line(x, n1 + y, 1, R), line(n1 + y, x, 1, B);
  for (int i = 1; i <= n1; i++)
    if (a[i] == 'R')
      tf[S]--, tf[i]++, line(S, i, inf, 0);
    else if (a[i] == 'B')
      tf[i]--, tf[T]++, line(i, T, inf, 0);
    else
      line(S, i, inf, 0), line(i, T, inf, 0);
  for (int i = 1; i <= n2; i++)
    if (b[i] == 'R')
      tf[n1 + i]--, tf[T]++, line(n1 + i, T, inf, 0);
    else if (b[i] == 'B')
      tf[S]--, tf[n1 + i]++, line(S, n1 + i, inf, 0);
    else
      line(S, n1 + i, inf, 0), line(n1 + i, T, inf, 0);
  ss = T + 1, tt = T + 2;
  for (int i = 0; i <= T; i++)
    if (tf[i] > 0)
      line(ss, i, tf[i], 0), sum += tf[i];
    else if (tf[i] < 0)
      line(i, tt, -tf[i], 0);
  line(T, S, inf, 0), S = ss, T = tt;
  while (SPFA()) memcpy(cur, fir, (T + 1) << 2), flow += aug(S, inf);
  if (flow < sum) return puts("-1"), 0;
  printf("%d\n", ans);
  for (int i = 2; i <= 4 * m; i += 4)
    putchar(!c[i] ? 'R' : !c[i + 2] ? 'B' : 'U');
}
