#include <bits/stdc++.h>
using namespace std;
const int INF = 1e8;
vector<vector<pair<int, int> > > G;
struct Edge {
  int from, to, c, f, res;
  int d;
  int rvs_e;
  int cst;
};
vector<Edge> E;
void dbgE() {
  cout << "-------------E------------\n";
  for (int i = 0; i < E.size(); i++) {
    cout << i << ": from=" << E[i].from << ", to=" << E[i].to
         << ", flow=" << E[i].f << ", capacity=" << E[i].c
         << ",  residual=" << E[i].res << ", rev_id= " << E[i].rvs_e
         << ", demand=" << E[i].d << '\n';
  }
  cout << "---------------------------\n";
}
inline void addEdge(int from, int to, int c, int f, int res, int d, int rv,
                    int cst = 0) {
  G[from].push_back({to, E.size()});
  E.push_back({from, to, c, f, res, d, rv, cst});
}
int findPath(int s, int t, vector<pair<int, int> > &Par) {
  queue<pair<int, int> > Q;
  int mn_flow = INF;
  Q.push({s, mn_flow});
  fill(Par.begin(), Par.end(), pair<int, int>({-1, -1}));
  Par[s] = {-2, -2};
  bool reached = false;
  while (!reached && !Q.empty()) {
    int v;
    tie(v, mn_flow) = Q.front();
    Q.pop();
    for (int i = 0; i < G[v].size(); i++) {
      int kid = G[v][i].first;
      int kid_e = G[v][i].second;
      if (Par[kid].first == -1 && E[kid_e].res) {
        Par[kid] = {v, kid_e};
        int new_mn_flow = min(mn_flow, E[kid_e].res);
        if (kid == t) {
          reached = true;
          mn_flow = new_mn_flow;
          break;
        }
        Q.push({kid, new_mn_flow});
      }
    }
  }
  if (reached) return mn_flow;
  return 0;
}
int findMinPath(int s, int t, vector<pair<int, int> > &Par) {
  fill(Par.begin(), Par.end(), pair<int, int>({-1, -1}));
  Par[s] = {-2, -2};
  vector<int> D = vector<int>(Par.size(), INF);
  D[s] = 0;
  queue<int> Q;
  vector<bool> inQ = vector<bool>(Par.size(), false);
  vector<int> mnFlowQ = vector<int>(Par.size(), INF);
  Q.push(s);
  inQ[s] = true;
  int mn_flow = INF;
  while (!Q.empty()) {
    int v = Q.front();
    mn_flow = mnFlowQ[v];
    Q.pop();
    inQ[v] = false;
    for (auto &it : G[v]) {
      int kid = it.first;
      int kid_e = it.second;
      if (E[kid_e].res && D[kid] > D[v] + E[kid_e].cst) {
        D[kid] = D[v] + E[kid_e].cst;
        Par[kid] = {v, kid_e};
        if (!inQ[kid]) Q.push(kid);
        inQ[kid] = true;
        mnFlowQ[kid] = min(mn_flow, E[kid_e].res);
      }
    }
  }
  if (mnFlowQ[t] != INF) return mnFlowQ[t];
  return 0;
}
void findMaxFlow(int s, int t) {
  vector<pair<int, int> > Par = vector<pair<int, int> >(G.size(), {-1, -1});
  while (int mnf = findMinPath(s, t, Par)) {
    int v = t;
    while (v != s) {
      int par = Par[v].first;
      int e = Par[v].second;
      E[e].f += mnf;
      E[e].res -= mnf;
      int rvs_e = E[e].rvs_e;
      E[rvs_e].f -= mnf;
      E[rvs_e].res += mnf;
      v = par;
    }
  }
}
int sp = -1, tp = -1;
bool flowWithDemands(int s, int t) {
  sp = G.size();
  G.emplace_back();
  tp = G.size();
  G.emplace_back();
  auto SP_to = map<int, int>();
  auto TP_from = map<int, int>();
  int e;
  auto Dmnds = vector<int>();
  for (int i = 0; i < E.size(); i++)
    if (E[i].d) Dmnds.push_back(i);
  for (auto i : Dmnds) {
    auto it = E[i];
    if (SP_to.count(it.to))
      e = SP_to[it.to];
    else {
      SP_to[it.to] = e = E.size();
      addEdge(sp, it.to, 0, 0, 0, 0, e + 1);
      addEdge(it.to, sp, 0, 0, 0, 0, e);
    }
    E[e].c += it.d;
    E[e].res += it.d;
    if (TP_from.count(it.from))
      e = TP_from[it.from];
    else {
      TP_from[it.from] = e = E.size();
      addEdge(it.from, tp, 0, 0, 0, 0, e + 1);
      addEdge(tp, it.from, 0, 0, 0, 0, e);
    }
    E[e].c += it.d;
    E[e].res += it.d;
    E[i].c -= it.d;
  }
  int e_last = E.size();
  addEdge(t, s, INF, 0, INF, 0, e_last + 1);
  addEdge(s, t, 0, 0, 0, 0, e_last);
  findMaxFlow(sp, tp);
  for (auto it : SP_to)
    if (E[it.second].res) return false;
  for (auto it : TP_from)
    if (E[it.second].res) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n1, n2, m, r, b;
  cin >> n1 >> n2 >> m >> r >> b;
  G = vector<vector<pair<int, int> > >(n1 + n2 + 2, vector<pair<int, int> >());
  char clr;
  int eix;
  int s = n1 + n2;
  int t = s + 1;
  for (int u = 0; u < n1; u++) {
    cin >> clr;
    eix = E.size();
    if (clr == 'R') {
      addEdge(s, u, INF, 0, INF, 1, eix + 1);
      addEdge(u, s, 0, 0, 0, 0, eix);
    } else if (clr == 'B') {
      addEdge(u, t, INF, 0, INF, 1, eix + 1);
      addEdge(t, u, 0, 0, 0, 0, eix);
    } else if (clr == 'U') {
      addEdge(s, u, INF, 0, INF, 0, eix + 1);
      addEdge(u, s, 0, 0, 0, 0, eix);
      eix = E.size();
      addEdge(u, t, INF, 0, INF, 0, eix + 1);
      addEdge(t, u, 0, 0, 0, 0, eix);
    }
  }
  for (int v = n1; v < n1 + n2; v++) {
    cin >> clr;
    eix = E.size();
    if (clr == 'B') {
      addEdge(s, v, INF, 0, INF, 1, eix + 1);
      addEdge(v, s, 0, 0, 0, 0, eix);
    } else if (clr == 'R') {
      addEdge(v, t, INF, 0, INF, 1, eix + 1);
      addEdge(t, v, 0, 0, 0, 0, eix);
    } else if (clr == 'U') {
      addEdge(s, v, INF, 0, INF, 0, eix + 1);
      addEdge(v, s, 0, 0, 0, 0, eix);
      eix = E.size();
      addEdge(v, t, INF, 0, INF, 0, eix + 1);
      addEdge(t, v, 0, 0, 0, 0, eix);
    }
  }
  auto OP = vector<tuple<int, int, int, int> >();
  for (int i = 0; i < m; i++) {
    int v, u;
    cin >> u >> v;
    u--, v--;
    v += n1;
    eix = E.size();
    addEdge(u, v, 1, 0, 1, 0, eix + 1, r);
    OP.push_back({u, v, eix, eix + 2});
    addEdge(v, u, 0, 0, 0, 0, eix, -r);
    eix = E.size();
    addEdge(v, u, 1, 0, 1, 0, eix + 1, b);
    OP.push_back({v, u, eix, -1});
    addEdge(u, v, 0, 0, 0, 0, eix, -b);
  }
  if (flowWithDemands(s, t)) {
    int cst = 0;
    string op = "";
    for (int i = 0; i < OP.size(); i++) {
      int eid = get<2>(OP[i]);
      int rv = get<3>(OP[i]);
      if (rv == -1) continue;
      if (E[eid].f > 0) {
        cst += r;
        op += "R";
        E[eid].f--;
      } else if (E[rv].f > 0) {
        cst += b;
        op += "B";
        E[rv].f--;
      } else
        op += "U";
    }
    cout << cst << '\n' << op << '\n';
  } else
    cout << -1 << '\n';
  return 0;
}
