#include <bits/stdc++.h>
using namespace std;
const int inf = 1e6;
const int N = 4e5 + 5;
struct Edge {
  int v, c;
  int cost;
  Edge(int _v, int _c, int _cost) : v(_v), c(_c), cost(_cost) {}
};
vector<int> g[N];
vector<Edge> E;
int addEdge(int u, int v, int c, int cost) {
  g[u].emplace_back((int)E.size());
  E.emplace_back(v, c, cost);
  g[v].emplace_back((int)E.size());
  E.emplace_back(u, 0, -cost);
  return (int)E.size() - 1;
}
int S, T;
int d[N];
int p[N];
bool inc() {
  for (int i = 0; i <= T; ++i) d[i] = inf, p[i] = -1;
  d[S] = 0;
  p[S] = inf;
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      pq;
  pq.push(pair<int, int>(0, S));
  while (pq.size()) {
    int du = pq.top().first;
    int u = pq.top().second;
    pq.pop();
    if (du != d[u]) continue;
    for (int i : g[u]) {
      int v = E[i].v;
      int C = E[i].cost;
      if (d[v] > du + C && E[i].c > 0) {
        d[v] = du + C;
        p[v] = i;
        pq.push(pair<int, int>(d[v], v));
      }
    }
  }
  return d[T] < 0;
}
int MCMF() {
  int Flow = 0;
  int Cost = 0;
  while (inc()) {
    int F = inf;
    for (int u = T; u != S;) {
      int i = p[u];
      F = min(E[i].c, F);
      u = E[i ^ 1].v;
    }
    for (int u = T; u != S;) {
      int i = p[u];
      E[i].c -= F;
      i ^= 1;
      E[i].c += F;
      u = E[i].v;
    }
    Flow += F;
    Cost += F * d[T];
  }
  return Cost;
}
pair<int, int> idx[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n1;
  cin >> n1;
  int n2;
  cin >> n2;
  int m;
  cin >> m;
  int r;
  cin >> r;
  int b;
  cin >> b;
  string s;
  cin >> s;
  string t;
  cin >> t;
  int colored = 0;
  S = 0;
  T = n1 + n2 + 1;
  int tot = 0;
  for (char c : s) {
    tot++;
    if (c == 'R') addEdge(S, tot, 1, -inf);
    if (c == 'B') addEdge(tot, T, 1, -inf);
    if (c != 'B') addEdge(S, tot, inf, 0);
    if (c != 'R') addEdge(tot, T, inf, 0);
    if (c != 'U') colored++;
  }
  for (char c : t) {
    tot++;
    if (c == 'B') addEdge(S, tot, 1, -inf);
    if (c == 'R') addEdge(tot, T, 1, -inf);
    if (c != 'R') addEdge(S, tot, inf, 0);
    if (c != 'B') addEdge(tot, T, inf, 0);
    if (c != 'U') colored++;
  }
  for (int i = 0; i < m; ++i) {
    int x;
    cin >> x;
    int y;
    cin >> y;
    y += n1;
    idx[i].first = addEdge(x, y, 1, r);
    idx[i].second = addEdge(y, x, 1, b);
  }
  int res = MCMF() + colored * inf;
  if (res > inf) {
    cout << "-1";
    return 0;
  }
  cout << res << "\n";
  for (int i = 0; i < m; ++i) {
    if (E[idx[i].first].c) {
      cout << "R";
      continue;
    }
    if (E[idx[i].second].c) {
      cout << "B";
      continue;
    }
    cout << "U";
  }
}
