#include <bits/stdc++.h>
const int N = 405, INF = 1e9, M = N * 3;
int dis[N], last[N], to[M << 1], Next[M << 1], w[M << 1], v[M << 1], vis[N], x,
    y, d[N];
int flow[N], f[N], in[N], out[N], S, T, SS, TT, edge, idr[N], ans, n1, n2, m, r,
    b, maxflow, idb[N];
char s[N], t[N];
std::queue<int> q;
void add(int x, int y, int ww, int vv) {
  to[++edge] = y;
  Next[edge] = last[x];
  last[x] = edge;
  w[edge] = ww;
  v[edge] = vv;
}
void Addfj(int x, int y, int ww, int vv) {
  add(x, y, ww, vv);
  add(y, x, 0, -vv);
}
void Add(int x, int y, int L, int R, int v) {
  in[y] += L, out[x] += L;
  ans += v * L;
  if (R > L) Addfj(x, y, R - L, v);
}
bool BFS() {
  memset(dis, 0x3f, sizeof(dis));
  memset(flow, 0x3f, sizeof(flow));
  memset(vis, 0, sizeof(vis));
  dis[SS] = 0;
  q.push(SS);
  while (q.size()) {
    int x = q.front(), d = dis[x];
    q.pop();
    vis[x] = 0;
    for (int i = last[x]; i; i = Next[i]) {
      if (!w[i]) continue;
      int u = to[i];
      if (d + v[i] >= dis[u]) continue;
      dis[u] = d + v[i];
      flow[u] = std::min(flow[x], w[i]);
      f[u] = i;
      if (!vis[u]) q.push(u), vis[u] = 1;
    }
  }
  return dis[TT] < INF;
}
int c(int x) { return x & 1 ? x + 1 : x - 1; }
int main() {
  scanf("%d%d%d%d%d", &n1, &n2, &m, &r, &b);
  scanf("%s", s + 1);
  scanf("%s", t + 1);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    y += n1;
    Add(x, y, 0, 1, r);
    idr[i] = edge;
    Add(y, x, 0, 1, b);
    idb[i] = edge;
    d[x]++, d[y]++;
  }
  S = n1 + n2 + 1, T = S + 1;
  for (int i = 1; i <= n1; i++) {
    int x = i;
    if (s[i] == 'R')
      Add(S, x, 1, d[x], 0);
    else if (s[i] == 'B')
      Add(x, T, 1, d[x], 0);
    else
      Add(S, x, 0, d[x], 0), Add(x, T, 0, d[x], 0);
  }
  for (int i = 1; i <= n2; i++) {
    int x = i + n1;
    if (t[i] == 'R')
      Add(x, T, 1, d[x], 0);
    else if (t[i] == 'B')
      Add(S, x, 1, d[x], 0);
    else
      Add(x, T, 0, d[x], 0), Add(S, x, 0, d[x], 0);
  }
  Add(T, S, 0, INF, 0);
  SS = T + 1, TT = SS + 1;
  for (int i = 1; i <= T; i++) {
    if (out[i] > in[i])
      maxflow += out[i] - in[i], Addfj(i, TT, out[i] - in[i], 0);
    else if (in[i] > out[i])
      Addfj(SS, i, in[i] - out[i], 0);
  }
  while (BFS()) {
    maxflow -= flow[TT];
    ans += dis[TT] * flow[TT];
    int u = TT;
    while (u != SS) {
      w[f[u]] -= flow[TT];
      w[c(f[u])] += flow[TT];
      u = to[c(f[u])];
    }
  }
  if (maxflow)
    puts("-1");
  else {
    printf("%d\n", ans);
    for (int i = 1; i <= m; i++) {
      if (w[idr[i]])
        putchar('R');
      else if (w[idb[i]])
        putchar('B');
      else
        putchar('U');
    }
  }
}
