#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
int addnum, vel[3010], key[3010], vet[3010], ne[3010], head[3010];
int from[410];
int idx[410], idy[410];
int vis[410];
int tot;
char s1[210], s2[210];
int sum;
int n1, n2, r, b, m;
int ans;
int du[410];
int dis[410], S, T, fS, fT;
void add(int u, int v, int k, int w) {
  addnum++, vel[addnum] = v, key[addnum] = k, vet[addnum] = w,
            ne[addnum] = head[u], head[u] = addnum;
  addnum++, vel[addnum] = u, key[addnum] = 0, vet[addnum] = -w,
            ne[addnum] = head[v], head[v] = addnum;
}
int spfa(int s, int t) {
  for (int i = 0; i <= tot; i++) dis[i] = inf, vis[i] = 0;
  queue<int> q;
  q.push(s);
  dis[s] = 0;
  from[s] = 0;
  while (q.size()) {
    int u = q.front();
    vis[u] = 0;
    q.pop();
    for (int e = head[u]; e; e = ne[e]) {
      int v = vel[e];
      if (!key[e]) continue;
      if (dis[u] + vet[e] < dis[v]) {
        from[v] = e;
        dis[v] = dis[u] + vet[e];
        if (!vis[v]) q.push(v), vis[v] = 1;
      }
    }
  }
  return dis[t] != inf;
}
void mcf(int s, int t) {
  int x = inf;
  for (int e = from[t]; e; e = from[vel[e ^ 1]]) x = min(x, key[e]);
  sum -= x;
  for (int e = from[t]; e; e = from[vel[e ^ 1]]) {
    key[e] -= x;
    key[e ^ 1] += x;
    ans += x * vet[e];
  }
}
int main() {
  addnum = 1;
  scanf("%d%d%d%d%d", &n1, &n2, &m, &r, &b);
  scanf("%s", s1 + 1);
  scanf("%s", s2 + 1);
  S = 0, T = tot = n1 + n2 + 1;
  fS = ++tot;
  fT = ++tot;
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    add(x, n1 + y, 1, r);
    idx[i] = addnum;
    add(n1 + y, x, 1, b);
    idy[i] = addnum;
  }
  for (int i = 1; i <= n1; i++)
    if (s1[i] == 'R') {
      add(fS, i, 1, 0);
      add(S, fT, 1, 0);
      sum++;
      add(S, i, inf, 0);
    } else if (s1[i] == 'B') {
      add(fS, T, 1, 0);
      add(i, fT, 1, 0);
      sum++;
      add(i, T, inf, 0);
    } else
      add(S, i, inf, 0), add(i, T, inf, 0);
  for (int i = n1 + 1; i <= n1 + n2; i++)
    if (s2[i - n1] == 'B') {
      add(fS, i, 1, 0);
      add(S, fT, 1, 0);
      sum++;
      add(S, i, inf, 0);
    } else if (s2[i - n1] == 'R') {
      add(fS, T, 1, 0);
      add(i, fT, 1, 0);
      sum++;
      add(i, T, inf, 0);
    } else
      add(S, i, inf, 0), add(i, T, inf, 0);
  add(T, S, inf, 0);
  while (spfa(fS, fT)) mcf(fS, fT);
  if (sum != 0) return puts("-1"), 0;
  printf("%d\n", ans);
  for (int i = 1; i <= m; i++)
    if (key[idx[i]])
      putchar('R');
    else if (key[idy[i]])
      putchar('B');
    else
      putchar('U');
  puts("");
}
