#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int maxn = 4005;
struct Edge {
  int from, to;
  LL cap, flow, cost;
};
struct MCMF {
  int n, m, s, t;
  vector<Edge> edges;
  vector<int> G[maxn];
  bool inq[maxn];
  int p[maxn];
  LL d[maxn], a[maxn];
  void init(int nn, int ss, int tt) {
    n = nn, s = ss, t = tt;
    for (int i = 0; i < n; i++) G[i].clear();
    edges.clear();
  }
  void AddEdge(int from, int to, int cap, int cost) {
    edges.push_back((Edge){from, to, cap, 0, cost});
    edges.push_back((Edge){to, from, 0, 0, -cost});
    m = edges.size();
    G[from].push_back(m - 2);
    G[to].push_back(m - 1);
  }
  bool BellmanFord(int s, int t, LL &flow, LL &cost) {
    for (int i = 0; i < n; i++) d[i] = 1E9, inq[i] = false;
    d[s] = 0, inq[s] = true, p[s] = 0, a[s] = 1E9;
    queue<int> Q;
    Q.push(s);
    while (!Q.empty()) {
      int u = Q.front();
      Q.pop();
      inq[u] = false;
      for (int i = 0; i < G[u].size(); i++) {
        Edge &e = edges[G[u][i]];
        if (e.cap > e.flow && d[e.to] > d[u] + e.cost) {
          d[e.to] = d[u] + e.cost;
          p[e.to] = G[u][i];
          a[e.to] = min(a[u], e.cap - e.flow);
          if (!inq[e.to]) {
            Q.push(e.to);
            inq[e.to] = true;
          }
        }
      }
    }
    if (d[t] == 1E9) return false;
    flow += a[t];
    cost += d[t] * a[t];
    int u = t;
    while (u != s) {
      edges[p[u]].flow += a[t];
      edges[p[u] ^ 1].flow -= a[t];
      u = edges[p[u]].from;
    }
    return true;
  }
  LL Mincost() {
    LL flow = 0, cost = 0;
    while (BellmanFord(s, t, flow, cost))
      ;
    return cost;
  }
  void AddBC(int x, int y, int b, int c, int cost) {
    if (b > 0) AddEdge(s, y, b, cost), AddEdge(x, t, b, cost);
    if (c > 0) AddEdge(x, y, c - b, cost);
  }
} X;
int n1, n2, m, r, b, u[205], v[205], oldS, oldT, S, T, bal[205][205], res, an;
char s1[205], s2[205], ans[405];
int main() {
  scanf("%d%d%d%d%d%s%s", &n1, &n2, &m, &r, &b, s1 + 1, s2 + 1);
  for (int i = 1; i <= m; i++) scanf("%d%d", &u[i], &v[i]);
  oldS = 0;
  oldT = n1 + n2 + 1;
  S = oldT + 1;
  T = S + 1;
  X.init(T + 1, S, T);
  X.AddEdge(oldT, oldS, 1E9, 0);
  for (int i = 1; i <= n1; i++)
    if (s1[i] == 'R')
      X.AddBC(oldS, i, 1, 1E9, 0);
    else if (s1[i] == 'B')
      X.AddBC(i, oldT, 1, 1E9, 0);
    else
      X.AddEdge(oldS, i, 1E9, 0), X.AddEdge(i, oldT, 1E9, 0);
  for (int i = n1 + 1; i <= n1 + n2; i++)
    if (s2[i - n1] == 'R')
      X.AddBC(i, oldT, 1, 1E9, 0);
    else if (s2[i - n1] == 'B')
      X.AddBC(oldS, i, 1, 1E9, 0);
    else
      X.AddEdge(oldS, i, 1E9, 0), X.AddEdge(i, oldT, 1E9, 0);
  for (int i = 1; i <= m; i++)
    X.AddEdge(u[i], v[i] + n1, 1, r), X.AddEdge(v[i] + n1, u[i], 1, b);
  X.Mincost();
  for (int i = 1; i <= n1; i++)
    for (auto &z : X.G[i])
      if (X.edges[z].to > n1 && X.edges[z].to <= n1 + n2)
        bal[i][X.edges[z].to - n1] += X.edges[z].flow;
  for (auto &x : X.G[S])
    if (X.edges[x].flow < X.edges[x].cap) {
      printf("-1");
      return 0;
    }
  for (int i = 1; i <= m; i++)
    if (bal[u[i]][v[i]] > 0) {
      bal[u[i]][v[i]]--;
      res += r;
      ans[an++] = 'R';
    } else if (bal[u[i]][v[i]] < 0) {
      bal[u[i]][v[i]]++;
      res += b;
      ans[an++] = 'B';
    } else
      ans[an++] = 'U';
  printf("%d %s", res, ans);
  return 0;
}
