#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300;
int n1, n2, m, r, b;
char c1[MAXN], c2[MAXN];
const int MAXV = 500, MAXE = 5000;
const int INF = 0x3f3f3f3f;
namespace network_flow {
int deg[MAXV], nodetot;
int h[MAXV], tot = 1, s, t, S, T, lim;
int val[MAXE], cost[MAXE], nxt[MAXE], ver[MAXE];
void add(int x, int y, int z, int c) {
  nxt[++tot] = h[x];
  ver[tot] = y;
  val[tot] = z;
  cost[tot] = c;
  h[x] = tot;
}
void addedge(int x, int y, int l, int r, int c) {
  deg[x] -= l, deg[y] += l;
  add(x, y, r - l, c), add(y, x, 0, -c);
}
void pre_work(int ntot) {
  nodetot = ntot;
  S = ntot + 1, T = S + 1;
  for (int i = 1; i <= nodetot; i++) {
    lim += max(deg[i], 0);
    if (deg[i] > 0)
      addedge(S, i, 0, deg[i], 0);
    else if (deg[i] < 0)
      addedge(i, T, 0, -deg[i], 0);
  }
}
int dis[MAXV];
bool ins[MAXV];
bool SPFA() {
  memset(dis, 0x3f, sizeof(dis));
  dis[S] = 0;
  queue<int> q;
  q.push(S);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    ins[u] = 0;
    for (int i = h[u]; i; i = nxt[i])
      if (val[i]) {
        int v = ver[i];
        if (dis[v] > dis[u] + cost[i]) {
          dis[v] = dis[u] + cost[i];
          if (!ins[v]) ins[v] = 1, q.push(v);
        }
      }
  }
  return dis[T] != INF;
}
int dfs(int u, int flow) {
  if (u == T) return flow;
  int lft = flow;
  ins[u] = 1;
  for (int i = h[u]; i && lft; i = nxt[i])
    if (val[i]) {
      int v = ver[i];
      if (!ins[v] && dis[v] == dis[u] + cost[i]) {
        int tmp = dfs(v, min(lft, val[i]));
        if (!tmp) {
          dis[v] = INF;
          continue;
        }
        lft -= tmp;
        val[i] -= tmp, val[i ^ 1] += tmp;
      }
    }
  ins[u] = 0;
  return flow - lft;
}
pair<int, int> MCMF() {
  int ret = 0, mincost = 0;
  while (SPFA()) {
    int tmp = dfs(S, INF);
    ret += tmp, mincost += tmp * dis[T];
  }
  return make_pair(ret, mincost);
}
}  // namespace network_flow
using network_flow::addedge;
using network_flow::deg;
using network_flow::lim;
using network_flow::MCMF;
using network_flow::pre_work;
using network_flow::s;
using network_flow::t;
using network_flow::val;
int main() {
  scanf("%d%d%d%d%d", &n1, &n2, &m, &r, &b);
  s = n1 + n2 + 1, t = s + 1;
  scanf("%s%s", c1 + 1, c2 + 1);
  for (int i = 1, x, y; i <= m; i++) {
    scanf("%d%d", &x, &y);
    y += n1;
    addedge(x, y, 0, 1, r);
    addedge(y, x, 0, 1, b);
  }
  for (int i = 1; i <= n1; i++) {
    if (c1[i] == 'R') addedge(s, i, 1, INF, 0);
    if (c1[i] == 'B') addedge(i, t, 1, INF, 0);
    if (c1[i] == 'U') addedge(s, i, 0, INF, 0), addedge(i, t, 0, INF, 0);
  }
  for (int i = 1; i <= n2; i++) {
    if (c2[i] == 'R') addedge(i + n1, t, 1, INF, 0);
    if (c2[i] == 'B') addedge(s, i + n1, 1, INF, 0);
    if (c2[i] == 'U')
      addedge(s, i + n1, 0, INF, 0), addedge(i + n1, t, 0, INF, 0);
  }
  addedge(t, s, 0, INF, 0);
  pre_work(n1 + n2 + 2);
  pair<int, int> ans = MCMF();
  if (ans.first == lim) {
    printf("%d\n", ans.second);
    for (int i = 1; i <= m; i++) {
      if (val[4 * i - 1])
        putchar('R');
      else if (val[4 * i + 1])
        putchar('B');
      else
        putchar('U');
    }
    puts("");
  } else
    puts("-1");
  return 0;
}
