#include <bits/stdc++.h>
using namespace std;
const int N = 3030;
struct Edge {
  int y, c, f, cost, nxt;
} e[N];
int oldS, oldT, T, S, V, n1, n2, m, r, b;
int p[N], d[N], pe[N], inq[N], bal[310][310];
int head[N], tot = 1, u[N], v[N];
char s1[N], s2[N];
void Add(int x, int y, int f, int c) {
  e[++tot] = (Edge){y, f, 0, c, head[x]};
  head[x] = tot;
  e[++tot] = (Edge){x, 0, 0, -c, head[y]};
  head[y] = tot;
}
void Add_edge(int x, int y) {
  Add(x, y + n1, 1, r);
  Add(y + n1, x, 1, b);
}
void Add_LR(int x, int y, int l, int r, int c) {
  int tmp = r - l;
  if (l > 0) Add(S, y, l, c), Add(x, T, l, c);
  if (tmp > 0) Add(x, y, tmp, c);
}
void Impose_left(int x) {
  if (s1[x] == 'R')
    Add_LR(oldS, x, 1, m, 0);
  else if (s1[x] == 'B')
    Add_LR(x, oldT, 1, m, 0);
  else
    Add(oldS, x, m, 0), Add(x, oldT, m, 0);
}
void Impose_right(int x) {
  if (s2[x] == 'R')
    Add_LR(x + n1, oldT, 1, m, 0);
  else if (s2[x] == 'B')
    Add_LR(oldS, x + n1, 1, m, 0);
  else
    Add(oldS, x + n1, m, 0), Add(x + n1, oldT, m, 0);
}
bool Dinic() {
  for (int i = 0; i < V; i++) d[i] = 1e9, p[i] = pe[i] = -1, inq[i] = 0;
  d[S] = 0;
  queue<int> q;
  q.push(S);
  inq[S] = 1;
  while (q.size()) {
    int u = q.front();
    q.pop();
    inq[u] = 0;
    for (int i = head[u]; i; i = e[i].nxt)
      if (e[i].c - e[i].f > 0 && d[e[i].y] > d[u] + e[i].cost) {
        p[e[i].y] = u;
        pe[e[i].y] = i;
        d[e[i].y] = d[u] + e[i].cost;
        if (!inq[e[i].y]) q.push(e[i].y), inq[e[i].y] = 1;
      }
  }
  if (p[T] == -1) return 0;
  int cur = T;
  while (cur != S) {
    e[pe[cur]].f++;
    e[pe[cur] ^ 1].f--;
    cur = p[cur];
  }
  return 1;
}
void Construct() {
  for (int i = 0; i < n1; i++)
    for (int j = head[i]; j; j = e[j].nxt)
      if (e[j].y >= n1 && e[j].y < n1 + n2) bal[i][e[j].y - n1] += e[j].f;
}
void Get_ans() {
  int res = 0;
  string w = "";
  for (int i = head[S]; i; i = e[i].nxt)
    if (e[i].c - e[i].f > 0) {
      puts("-1");
      return;
    }
  for (int i = 0; i < m; i++)
    if (bal[u[i]][v[i]] > 0) {
      bal[u[i]][v[i]]--;
      res += r;
      w += "R";
    } else if (bal[u[i]][v[i]] < 0) {
      bal[u[i]][v[i]]++;
      res += b;
      w += "B";
    } else
      w += "U";
  printf("%d\n", res);
  cout << w << endl;
}
int main() {
  scanf("%d%d%d%d%d", &n1, &n2, &m, &r, &b);
  scanf("%s", s1);
  scanf("%s", s2);
  for (int i = 0; i < m; i++) scanf("%d%d", &u[i], &v[i]), u[i]--, v[i]--;
  oldS = n1 + n2;
  oldT = oldS + 1;
  S = oldT + 1;
  T = S + 1;
  V = T + 1;
  for (int i = 0; i < n1; i++) Impose_left(i);
  for (int i = 0; i < n2; i++) Impose_right(i);
  for (int i = 0; i < m; i++) Add_edge(u[i], v[i]);
  Add(oldT, oldS, 100000, 0);
  while (Dinic())
    ;
  Construct();
  Get_ans();
}
