#include <bits/stdc++.h>
using namespace std;
constexpr int kN = int(1E3 + 10), kInf = int(1E9 + 10);
struct Edge {
  int to, rev, cost, flow, num;
};
vector<Edge> graph[kN];
pair<int, int> dis[kN];
int from[kN];
void AddEdge(int u, int v, int c, int f, int num) {
  graph[u].push_back({v, int(graph[v].size()), c, f, num});
  graph[v].push_back({u, int(graph[u].size()) - 1, -c, 0, num});
  return;
}
pair<int, int> MCMF(int s, int t) {
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      pq;
  pair<int, int> nxt;
  int now, flow;
  for (int i = 0; i < kN; i++) dis[i] = {kInf, 0};
  dis[s] = {0, kInf};
  pq.push({dis[s].first, s});
  while (!pq.empty()) {
    nxt = pq.top();
    pq.pop();
    if (nxt.first > dis[nxt.second].first) continue;
    for (Edge i : graph[nxt.second])
      if (i.flow > 0 && i.cost + nxt.first < dis[i.to].first) {
        dis[i.to] = {nxt.first + i.cost, min(dis[nxt.second].second, i.flow)};
        from[i.to] = i.rev;
        pq.push({dis[i.to].first, i.to});
      }
  }
  if (dis[t].first >= kInf) return dis[t];
  flow = dis[t].second;
  now = t;
  while (now != s) {
    graph[now][from[now]].flow += flow;
    graph[graph[now][from[now]].to][graph[now][from[now]].rev].flow -= flow;
    now = graph[now][from[now]].to;
  }
  return dis[t];
}
int main() {
  int n1, n2, m, r, b, u, v, tot, ss, tt, s, t, ans = 0;
  pair<int, int> tmp;
  string s1, s2, s3;
  cin >> n1 >> n2 >> m >> r >> b >> s1 >> s2;
  tot = n1 + n2;
  s1 += s2;
  for (int i = n1; i < tot; i++)
    if (s1[i] == 'R')
      s1[i] = 'B';
    else if (s1[i] == 'B')
      s1[i] = 'R';
  s = tot + 1, t = tot + 2, ss = tot + 3, tt = tot;
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    u--;
    v--;
    AddEdge(u, v + n1, r, 1, i);
    AddEdge(v + n1, u, b, 1, i);
  }
  AddEdge(t, s, 0, kInf, m);
  for (int i = 0; i < tot; i++)
    if (s1[i] == 'R') {
      AddEdge(s, i, 0, kInf, m);
      AddEdge(ss, i, 0, 1, m);
      AddEdge(s, tt, 0, 1, m);
    } else if (s1[i] == 'B') {
      AddEdge(i, t, 0, kInf, m);
      AddEdge(ss, t, 0, 1, m);
      AddEdge(i, tt, 0, 1, m);
    } else {
      AddEdge(s, i, 0, kInf, m);
      AddEdge(i, t, 0, kInf, m);
    }
  while (true) {
    tmp = MCMF(ss, tt);
    if (tmp.second == 0) break;
    ans += tmp.first * tmp.second;
  }
  for (Edge i : graph[ss])
    if (i.flow > 0) {
      cout << -1 << endl;
      return 0;
    }
  cout << ans << endl;
  s3.resize(m);
  for (int i = 0; i < m; i++) s3[i] = 'U';
  for (int i = 0; i < n1; i++)
    for (Edge j : graph[i])
      if (j.num < m) {
        if (j.cost == r && j.flow == 0)
          s3[j.num] = 'R';
        else if (j.cost == -b && j.flow == 1)
          s3[j.num] = 'B';
      }
  cout << s3 << endl;
}
