#include <bits/stdc++.h>
using namespace std;
const int INF = 1e8;
struct edge {
  int dest, back_id, cap, flow, cost;
  bool backwards;
  int id;
};
struct MinCostMaxFlow {
  vector<vector<edge>> G;
  vector<pair<int, int>> p;
  MinCostMaxFlow(int n) : G(n), p(n) {}
  void add_edge(int s, int t, int cap, int cost, int id) {
    edge a = {t, (int)G[t].size(), cap, 0, cost, false, id};
    edge b = {s, (int)G[s].size(), 0, 0, -cost, true, -1};
    G[s].push_back(a);
    G[t].push_back(b);
  }
  bool spfa(int s, int t) {
    vector<int> d(G.size(), INF);
    vector<bool> inq(G.size(), false);
    queue<int> q;
    d[s] = 0;
    p[s].first = -1;
    q.push(s);
    inq[s] = 0;
    while (!q.empty()) {
      int u = q.front();
      inq[u] = false;
      q.pop();
      for (int i = 0; i < G[u].size(); i++) {
        edge& e = G[u][i];
        if (e.flow < e.cap && d[e.dest] > d[u] + e.cost) {
          d[e.dest] = d[u] + e.cost;
          p[e.dest] = {u, i};
          if (!inq[e.dest]) inq[e.dest] = true, q.push(e.dest);
        }
      }
    }
    return (d[t] != INF);
  }
  pair<int, int> mcmf(int s, int t) {
    int F = 0, C = 0;
    vector<int> d(G.size());
    while (spfa(s, t)) {
      int v = t, f = INF;
      while (p[v].first != -1) {
        f = min(f, G[p[v].first][p[v].second].cap -
                       G[p[v].first][p[v].second].flow);
        v = p[v].first;
      }
      F += f;
      v = t;
      while (p[v].first != -1) {
        edge& e = G[p[v].first][p[v].second];
        if (e.backwards)
          e.cap -= f, G[v][e.back_id].flow -= f;
        else
          e.flow += f, G[v][e.back_id].cap += f;
        C += e.cost * f;
        v = p[v].first;
      }
    }
    return {F, C};
  }
};
int n1, n2, m, r, b;
pair<int, int> input[200];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n1 >> n2 >> m >> r >> b;
  MinCostMaxFlow mcmf(n1 + n2 + 3);
  string s1, s2;
  cin >> s1 >> s2;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    input[i] = {u, v};
    mcmf.add_edge(u, v + n1, 1, b, i);
    mcmf.add_edge(v + n1, u, 1, r, i);
  }
  int s = n1 + n2, t = n1 + n2 + 1, x = n1 + n2 + 2, to_x = 0;
  for (int i = 0; i < n1; i++) {
    if (s1[i] == 'B') {
      mcmf.add_edge(s, i, 1, 0, -1);
      mcmf.add_edge(x, i, INF, 0, -1);
      to_x--;
    } else if (s1[i] == 'R') {
      mcmf.add_edge(i, t, 1, 0, -1);
      mcmf.add_edge(i, x, INF, 0, -1);
      to_x++;
    } else {
      mcmf.add_edge(i, x, INF, 0, -1);
      mcmf.add_edge(x, i, INF, 0, -1);
    }
  }
  for (int i = 0; i < n2; i++) {
    if (s2[i] == 'B') {
      mcmf.add_edge(i + n1, t, 1, 0, -1);
      mcmf.add_edge(i + n1, x, INF, 0, -1);
      to_x++;
    } else if (s2[i] == 'R') {
      mcmf.add_edge(s, i + n1, 1, 0, -1);
      mcmf.add_edge(x, i + n1, INF, 0, -1);
      to_x--;
    } else {
      mcmf.add_edge(i + n1, x, INF, 0, -1);
      mcmf.add_edge(x, i + n1, INF, 0, -1);
    }
  }
  if (to_x > 0) mcmf.add_edge(s, x, to_x, 0, -1);
  if (to_x < 0) mcmf.add_edge(x, t, -to_x, 0, -1);
  int val = 0;
  for (edge& e : mcmf.G[s]) val += e.cap;
  pair<int, int> p = mcmf.mcmf(s, t);
  if (p.first != val) {
    cout << "-1\n";
    return 0;
  }
  cout << p.second << "\n";
  vector<char> sol(m, 'U');
  for (int i = 0; i < mcmf.G.size(); i++) {
    for (edge& e : mcmf.G[i]) {
      if (e.flow == 1 && e.id != -1) sol[e.id] = (i < e.dest ? 'B' : 'R');
    }
  }
  for (int i = 0; i < m; i++) cout << sol[i];
  cout << "\n";
  return 0;
}
