#include <bits/stdc++.h>
using namespace std;
long long mo(const long long input, const long long ceil) {
  return input >= ceil ? input % ceil : input;
}
const long long Q = 500, P = 10000;
long long e[P], nn[P], v[P], c[P];
long long las[Q], pn[Q], pm[P], inc = 1;
void iNS(long long x, long long y, long long z, long long w) {
  e[++inc] = y;
  nn[inc] = las[x];
  las[x] = inc;
  c[inc] = z;
  v[inc] = w;
}
void ins(long long x, long long y, long long z, long long w) {
  iNS(x, y, z, w), iNS(y, x, 0, -w);
}
long long s, t;
char cc[Q];
queue<long long> q;
long long dis[Q], ch[Q];
bool Spfa() {
  for (long long i = 1; i <= t; i++) dis[i] = 1e9;
  dis[s] = 0;
  q.push(s);
  while (q.size()) {
    long long x = q.front();
    q.pop();
    ch[x] = 0;
    for (long long t = las[x]; t; t = nn[t]) {
      long long y = e[t];
      if (c[t] && dis[x] + v[t] < dis[y]) {
        dis[y] = dis[x] + v[t];
        pn[y] = x, pm[y] = t;
        if (!ch[y]) q.push(y), ch[y] = 1;
      }
    }
  }
  return dis[t] < 0;
}
long long als = 0;
void Upd() {
  als += dis[t];
  for (long long now = t; now != s; now = pn[now])
    --c[pm[now]], ++c[pm[now] ^ 1];
}
void solve(long long tt) {
  long long n1, n2, r, b, m;
  cin >> n1 >> n2 >> m >> r >> b;
  s = n1 + n2 + 1, t = s + 1;
  cin >> (cc + 1);
  for (long long i = 1; i <= n1; i++) {
    if (cc[i] == 'R') ins(i, t, 1, -40001), als += 40001;
    if (cc[i] != 'B') ins(i, t, 40001, 0);
    if (cc[i] == 'B') ins(s, i, 1, -40001), als += 40001;
    if (cc[i] != 'R') ins(s, i, 40001, 0);
  }
  cin >> (cc + 1);
  for (long long i = 1; i <= n2; i++) {
    if (cc[i] == 'B') ins(i + n1, t, 1, -40001), als += 40001;
    if (cc[i] != 'R') ins(i + n1, t, 40001, 0);
    if (cc[i] == 'R') ins(s, i + n1, 1, -40001), als += 40001;
    if (cc[i] != 'B') ins(s, i + n1, 40001, 0);
  }
  long long rem = inc;
  for (long long i = 1; i <= m; i++) {
    long long x, y;
    cin >> x >> y;
    ins(x, y + n1, 1, b), ins(y + n1, x, 1, r);
  }
  while (Spfa()) Upd();
  if (als >= 40001) {
    puts("-1");
    return;
  }
  cout << als << "\n";
  for (long long i = 1; i <= m; i++)
    cout << (c[rem + (i - 1) * 4 + 2] ? 'B' : (c[rem + i * 4] ? 'R' : 'U'));
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long tt = 1;
  for (long long i = 0; i < tt; i++) solve(tt);
  cerr << "\n\n\nTime : "
       << 1000 * (long double)clock() / (long double)CLOCKS_PER_SEC << "ms\n";
  ;
  return 0;
}
