#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const long long infLL = 9000000000000000000;
void faltu() { cerr << '\n'; }
template <typename T, typename... hello>
void faltu(T arg, const hello &...rest) {
  cerr << arg << ' ';
  faltu(rest...);
}
namespace mcmf {
const int MAX = 1000010;
const long long INF = 1LL << 60;
long long cap[MAX], flow[MAX], cost[MAX], dis[MAX];
int n, m, s, t, Q[10000010], adj[MAX], link[MAX], last[MAX], from[MAX],
    visited[MAX];
void init(int nodes, int source, int sink) {
  m = 0, n = nodes, s = source, t = sink;
  for (int i = 0; i <= n; i++) last[i] = -1;
}
int addEdge(int u, int v, long long c, long long w) {
  adj[m] = v, cap[m] = c, flow[m] = 0, cost[m] = +w, link[m] = last[u],
  last[u] = m++;
  adj[m] = u, cap[m] = 0, flow[m] = 0, cost[m] = -w, link[m] = last[v],
  last[v] = m++;
  return m - 2;
}
bool spfa() {
  int i, j, x, f = 0, l = 0;
  for (i = 0; i <= n; i++) visited[i] = 0, dis[i] = INF;
  dis[s] = 0, Q[l++] = s;
  while (f < l) {
    i = Q[f++];
    for (j = last[i]; j != -1; j = link[j]) {
      if (flow[j] < cap[j]) {
        x = adj[j];
        if (dis[x] > dis[i] + cost[j]) {
          dis[x] = dis[i] + cost[j], from[x] = j;
          if (!visited[x]) {
            visited[x] = 1;
            if (f && rand() & 7)
              Q[--f] = x;
            else
              Q[l++] = x;
          }
        }
      }
    }
    visited[i] = 0;
  }
  return (dis[t] != INF);
}
pair<long long, long long> solve() {
  int i, j;
  long long mincost = 0, maxflow = 0;
  while (spfa()) {
    long long aug = INF;
    for (i = t, j = from[i]; i != s; i = adj[j ^ 1], j = from[i]) {
      aug = min(aug, cap[j] - flow[j]);
    }
    for (i = t, j = from[i]; i != s; i = adj[j ^ 1], j = from[i]) {
      flow[j] += aug, flow[j ^ 1] -= aug;
    }
    maxflow += aug, mincost += aug * dis[t];
  }
  return make_pair(mincost, maxflow);
}
};  // namespace mcmf
const long long INF = 1e9;
const int mx = 500;
int id[mx], revid[mx];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n1, n2, m, r, b, s, t, t1;
  cin >> n1 >> n2 >> m >> r >> b;
  s = 0, t = n1 + n2 + 1, t1 = n1 + n2 + 2;
  mcmf::init(n1 + n2 + 10, s, t1);
  int cnt = 0;
  string s1, s2;
  cin >> s1 >> s2;
  for (int i = 1; i <= n1; i++) {
    char c = s1[i - 1];
    if (c == 'R') {
      mcmf::addEdge(s, i, 1, -INF);
      mcmf::addEdge(s, i, INF, 0);
      cnt++;
    }
    if (c == 'B') {
      mcmf::addEdge(i, t, 1, -INF);
      mcmf::addEdge(i, t, INF, 0);
      cnt++;
    }
    if (c == 'U') {
      mcmf::addEdge(s, i, INF, 0);
      mcmf::addEdge(i, t, INF, 0);
    }
  }
  for (int i = 1; i <= n2; i++) {
    char c = s2[i - 1];
    if (c == 'R') {
      mcmf::addEdge(i + n1, t, 1, -INF);
      mcmf::addEdge(i + n1, t, INF, 0);
      cnt++;
    }
    if (c == 'B') {
      mcmf::addEdge(s, i + n1, 1, -INF);
      mcmf::addEdge(s, i + n1, INF, 0);
      cnt++;
    }
    if (c == 'U') {
      mcmf::addEdge(s, i + n1, INF, 0);
      mcmf::addEdge(i + n1, t, INF, 0);
    }
  }
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    id[i] = mcmf::addEdge(u, v + n1, 1, r);
    revid[i] = mcmf::addEdge(v + n1, u, 1, b);
  }
  mcmf::addEdge(t, t1, m, 0);
  mcmf::addEdge(s, t, m, 0);
  pair<long long, long long> ans = mcmf::solve();
  if (ans.first + (cnt * INF) >= INF) {
    cout << "-1";
  } else {
    cout << ans.first + (cnt * INF) << '\n';
    for (int i = 1; i <= m; i++) {
      if (mcmf::flow[id[i]] > 0) {
        cout << 'R';
      } else if (mcmf::flow[revid[i]] > 0) {
        cout << 'B';
      } else {
        cout << 'U';
      }
    }
  }
  return 0;
}
