#include <bits/stdc++.h>
const int N = 200;
const int inf = 1e9;
using namespace std;
int n1, n2, m, cr, cb, S, T, idc, id1[N + 5], id2[N + 5], num[N + 5];
char s1[N + 5], s2[N + 5];
namespace F {
const int N = 1e6;
const long long inf = 2e18;
struct edges {
  int v;
  long long w, f;
} edge[N + 5];
int head[N + 5], S, T, nxt[N + 5], edge_cnt = 1, cur[N + 5], vis[N + 5],
                                   p[N + 5], q[N + 5];
long long dis[N + 5], cost, fl[N + 5];
void add_edge(int u, int v, long long w, long long f) {
  edge[++edge_cnt] = (edges){v, w, f};
  nxt[edge_cnt] = head[u];
  head[u] = edge_cnt;
}
void add(int u, int v, long long w, long long f) {
  add_edge(u, v, w, f);
  add_edge(v, u, 0, -f);
}
void addlim(int u, int v, long long l, long long r, long long f) {
  fl[u] -= l;
  fl[v] += l;
  add(u, v, r - l, f);
}
bool spfa() {
  for (int i = 1; i <= idc; i++)
    dis[i] = inf, cur[i] = head[i], vis[i] = p[i] = 0;
  int l = 1, r = 0;
  dis[S] = 0;
  q[++r] = S;
  while (l <= r) {
    int u = q[l++];
    vis[u] = 0;
    for (int i = head[u]; i; i = nxt[i]) {
      int v = edge[i].v;
      long long w = edge[i].w, f = edge[i].f;
      if (w && dis[v] > dis[u] + f) {
        dis[v] = dis[u] + f;
        if (!vis[v]) {
          q[++r] = v;
          vis[v] = 1;
        }
      }
    }
  }
  return dis[T] != inf;
}
long long dfs(int u, long long flow) {
  if (u == T) return flow;
  long long sm = 0;
  p[u] = 1;
  for (int &i = cur[u]; i; i = nxt[i]) {
    int v = edge[i].v;
    long long w = edge[i].w, f = edge[i].f;
    if (w && dis[v] == dis[u] + f && !p[v]) {
      long long res = dfs(v, min(flow, w));
      edge[i].w -= res;
      edge[i ^ 1].w += res;
      flow -= res;
      sm += res;
      cost += res * f;
      if (!flow) break;
    }
  }
  p[u] = 0;
  return sm;
}
pair<long long, long long> dinic(int s, int t) {
  S = ++idc;
  T = ++idc;
  for (int i = 1; i <= idc - 2; i++)
    if (fl[i] > 0)
      F::add(S, i, fl[i], 0);
    else if (fl[i] < 0)
      F::add(i, T, -fl[i], 0);
  F::add(t, s, inf, 0);
  long long ans = 0;
  cost = 0;
  while (spfa()) ans += dfs(S, inf);
  return make_pair(ans, cost);
}
bool check() {
  for (int i = head[S]; i; i = nxt[i])
    if (edge[i].w) return 0;
  for (int i = head[T]; i; i = nxt[i])
    if (edge[i ^ 1].w) return 0;
  return 1;
}
void clear() {
  for (int i = 1; i <= idc; i++) head[i] = 0;
  edge_cnt = 1;
  idc = 0;
}
void solve() {
  for (int i = 1; i <= m; i++) {
    if (!edge[num[i]].w)
      printf("R");
    else if (!edge[num[i] + 2].w)
      printf("B");
    else
      printf("U");
  }
}
}  // namespace F
int main() {
  scanf("%d%d%d%d%d", &n1, &n2, &m, &cr, &cb);
  scanf("%s", s1 + 1);
  scanf("%s", s2 + 1);
  S = ++idc;
  T = ++idc;
  for (int i = 1; i <= n1; i++) {
    id1[i] = ++idc;
    if (s1[i] == 'R') F::addlim(S, id1[i], 1, inf, 0);
    if (s1[i] == 'B') F::addlim(id1[i], T, 1, inf, 0);
    if (s1[i] == 'U') {
      F::add(S, id1[i], inf, 0);
      F::add(id1[i], T, inf, 0);
    }
  }
  for (int i = 1; i <= n2; i++) {
    id2[i] = ++idc;
    if (s2[i] == 'B') F::addlim(S, id2[i], 1, inf, 0);
    if (s2[i] == 'R') F::addlim(id2[i], T, 1, inf, 0);
    if (s2[i] == 'U') {
      F::add(S, id2[i], inf, 0);
      F::add(id2[i], T, inf, 0);
    }
  }
  int u, v;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    F::add(id1[u], id2[v], 1, cr);
    num[i] = F::edge_cnt - 1;
    F::add(id2[v], id1[u], 1, cb);
  }
  pair<long long, long long> ans = F::dinic(S, T);
  if (!F::check())
    cout << -1 << endl;
  else {
    cout << ans.second << endl;
    F::solve();
  }
  return 0;
}
