#include <bits/stdc++.h>
using namespace std;
using ll = int;
const ll oo = 1e5;
const int N = 422, E = 2 * 10006;
vector<int> g[N];
int ne;
struct Edge {
  int from, to;
  ll cap, cost;
} edge[E];
int start = N - 1, target = N - 2, p[N];
int inqueue[N];
ll d[N];
ll pot[N];
bool spfa(int source, int sink) {
  for (int i = 0; i < N; i++) {
    d[i] = oo;
    inqueue[i] = 0;
  }
  d[source] = 0;
  queue<int> q;
  q.push(source);
  inqueue[source] = 1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    inqueue[u] = 0;
    for (int e : g[u]) {
      auto v = edge[e];
      if (v.cap > 0 and d[u] + v.cost + pot[u] - pot[v.to] < d[v.to]) {
        d[v.to] = d[u] + v.cost + pot[u] - pot[v.to];
        p[v.to] = e;
        if (!inqueue[v.to]) {
          q.push(v.to);
          inqueue[v.to] = 1;
        }
      }
    }
  }
  return d[sink] != oo;
}
bool dijkstra(int source, int sink) {
  for (int i = 0; i < N; i++) d[i] = oo;
  d[source] = 0;
  priority_queue<pair<ll, int>> q;
  q.emplace(0, source);
  ll dt;
  int u;
  while (!q.empty()) {
    tie(dt, u) = q.top();
    q.pop();
    dt = -dt;
    if (dt > d[u]) continue;
    for (int e : g[u]) {
      auto v = edge[e];
      const ll cand = d[u] + v.cost + pot[u] - pot[v.to];
      if (v.cap > 0 and cand < 0) {
        ;
      }
      if (v.cap > 0 and cand < d[v.to]) {
        p[v.to] = e;
        d[v.to] = cand;
        q.emplace(-d[v.to], v.to);
      }
    }
  }
  return d[sink] < oo;
  return false;
}
pair<ll, ll> mincost(int source = start, int sink = target) {
  ll ans = 0, mf = 0;
  while (dijkstra(source, sink)) {
    ;
    ll f = oo;
    for (int u = sink; u != source; u = edge[p[u]].from)
      f = min(f, edge[p[u]].cap);
    mf += f;
    ans += f * (d[sink] - pot[source] + pot[sink]);
    for (int u = sink; u != source; u = edge[p[u]].from) {
      edge[p[u]].cap -= f;
      edge[p[u] ^ 1].cap += f;
      pot[u] += d[u];
    }
  }
  return {mf, ans};
}
void addEdge(int u, int v, ll c, ll cost) {
  assert(cost >= 0);
  edge[ne] = {u, v, c, cost};
  g[u].push_back(ne++);
  edge[ne] = {v, u, 0, -cost};
  g[v].push_back(ne++);
}
int n1, n2, m, r, b;
char side[2][N];
int u[N], v[N];
int main() {
  scanf("%d %d %d %d %d", &n1, &n2, &m, &r, &b);
  scanf(" %s %s", side[0], side[1]);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", u + i, v + i);
  }
  for (int i = 0; i < m; i++) {
    addEdge(u[i] - 1, v[i] - 1 + n1, 1, r);
    addEdge(v[i] - 1 + n1, u[i] - 1, 1, b);
  }
  int s = N - 3, t = N - 4;
  for (int i = 0; i < n1; i++) {
    if (side[0][i] == 'R') {
      addEdge(start, i, oo, 0);
      addEdge(s, i, 1, 0);
      addEdge(start, t, 1, 0);
    } else if (side[0][i] == 'B') {
      addEdge(i, target, oo, 0);
      addEdge(i, t, 1, 0);
      addEdge(s, target, 1, 0);
    } else {
      addEdge(start, i, oo, 0);
      addEdge(i, target, oo, 0);
    }
  }
  for (int i = 0; i < n2; i++) {
    if (side[1][i] == 'R') {
      addEdge(i + n1, target, oo, 0);
      addEdge(i + n1, t, 1, 0);
      addEdge(s, target, 1, 0);
    } else if (side[1][i] == 'B') {
      addEdge(start, i + n1, oo, 0);
      addEdge(s, i + n1, 1, 0);
      addEdge(start, t, 1, 0);
    } else {
      addEdge(start, i + n1, oo, 0);
      addEdge(i + n1, target, oo, 0);
    }
  }
  addEdge(target, start, oo, 0);
  auto ans = mincost(s, t);
  for (int e : g[s]) {
    if (edge[e].cap > 0) {
      return printf("-1\n"), 0;
    }
  }
  printf("%d\n", ans.second);
  for (int i = 0; i < m; i++) {
    if (edge[4 * i].cap == 0) {
      printf("R");
    } else if (edge[4 * i + 2].cap == 0) {
      printf("B");
    } else
      printf("U");
  }
  printf("\n");
}
