#include <bits/stdc++.h>
using namespace std;
const long long iinf = 1e9 + 10;
const long long inf = 1ll << 60;
const long long mod = 1e9 + 7;
void GG() {
  cout << "-1\n";
  exit(0);
}
long long mpow(long long a, long long n, long long mo = mod) {
  long long re = 1;
  while (n > 0) {
    if (n & 1) re = re * a % mo;
    a = a * a % mo;
    n >>= 1;
  }
  return re;
}
long long inv(long long b, long long mo = mod) {
  if (b == 1) return b;
  return (mo - mo / b) * inv(mo % b, mo) % mo;
}
const long long maxn = 404 + 5;
string L, R;
vector<pair<long long, long long> > G[maxn];
struct Edge {
  long long to, cap, flow, cost, id;
};
vector<Edge> E;
vector<long long> g[maxn];
long long N, S, T;
void add(long long v, long long u, long long cap, long long cost,
         long long id = -1) {
  if (cap < 0) GG();
  g[v].push_back((long long)E.size());
  E.push_back({u, cap, 0, cost, id});
  g[u].push_back((long long)E.size());
  E.push_back({v, 0, 0, -cost, id});
}
long long par[maxn];
bool inq[maxn];
long long dst[maxn];
long long mc() {
  memset(par, -1, sizeof par);
  memset(dst, 0x3f, sizeof dst);
  memset(inq, 0, sizeof inq);
  dst[S] = 0;
  inq[S] = 1;
  queue<long long> q({S});
  while (!q.empty()) {
    long long v = q.front();
    q.pop();
    ;
    inq[v] = 0;
    for (long long i : g[v]) {
      Edge &e = E[i];
      if (e.cap - e.flow > 0) {
        if (dst[e.to] > dst[v] + e.cost) {
          dst[e.to] = dst[v] + e.cost;
          par[e.to] = i;
          if (!inq[e.to]) {
            inq[e.to] = 1;
            q.push(e.to);
          }
        }
      }
    }
  }
  if (dst[T] > 0) return 1;
  if (par[T] != -1) {
    for (long long at = T; at != S;) {
      E[par[at]].flow++;
      E[par[at] ^ 1].flow--;
      at = E[par[at] ^ 1].to;
    }
  };
  return dst[T];
}
long long edgeans[maxn];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  long long n1, n2, m, r, b;
  cin >> n1 >> n2 >> m >> r >> b;
  cin >> L >> R;
  for (long long i = 0; i < m; ++i) {
    long long a, b;
    cin >> a >> b;
    --a;
    --b;
    G[a].push_back({b + n1, i});
    G[b + n1].push_back({a, i});
  }
  N = n1 + n2 + 4;
  S = N - 1, T = N - 2;
  long long req = r * m;
  for (long long i = 0; i < n1; ++i) {
    if (L[i] == 'R') {
      add(S, i, (long long)G[i].size() - 1, 0);
    }
    if (L[i] == 'U') {
      add(S, i, (long long)G[i].size() * 2, 0);
    }
    if (L[i] == 'B') {
      add(S, i, (long long)G[i].size() + 1, -1000000);
      req += 1000000 * ((long long)G[i].size() + 1);
      add(S, i, (long long)G[i].size() - 1, 0);
    }
    for (pair<long long, long long> j : G[i]) {
      add(i, j.first, 1, -r, j.second);
      add(i, j.first, 1, b, j.second);
    }
  }
  for (long long i = 0; i < n2; ++i) {
    long long me = i + n1;
    if (R[i] == 'R') {
      add(me, T, (long long)G[me].size() - 1, 0);
    }
    if (R[i] == 'B') {
      add(me, T, (long long)G[me].size() + 1, -1000000);
      req += 1000000 * ((long long)G[me].size() + 1);
      add(me, T, (long long)G[me].size() - 1, 0);
    }
    if (R[i] == 'U') {
      add(me, T, (long long)G[me].size() * 2, 0);
    }
  };
  while (1) {
    long long hi = mc();
    if (hi > 0) break;
    ;
    req += hi;
  };
  if (req >= 40000) GG();
  cout << req << '\n';
  for (long long v = 0; v < n1; ++v) {
    for (long long i : g[v]) {
      if (i % 2 == 0) {
        Edge &e = E[i];
        assert(e.to >= n1 && e.to < n1 + n2);
        if (e.flow == e.cap) edgeans[e.id]++;
      }
    }
  }
  for (long long i = 0; i < m; ++i) {
    cout << "RUB"[edgeans[i]];
  }
}
