#include <bits/stdc++.h>
using namespace std;
template <typename T>
void maxtt(T &t1, T t2) {
  t1 = max(t1, t2);
}
template <typename T>
void mintt(T &t1, T t2) {
  t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "URDL";
const long long MOD2 = (long long)1000000007 * (long long)1000000007;
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
  x += y;
  if (x >= mod) x -= mod;
  if (x < 0) x += mod;
  assert(x >= 0 && x < mod);
}
void et(int x = -1) {
  printf("%d\n", x);
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 1000000007) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }
class MinCostFlow {
 public:
  int S, T, ecnt;
  int head[1000];
  int flw[100000], cost[100000], dis[1000];
  int to[100000], next[100000];
  bool use[1000];
  MinCostFlow() {
    memset(head, 0, sizeof(head));
    ecnt = 2;
  }
  void add_edge(int u, int v, int _c, int ww) {
    flw[ecnt] = _c;
    cost[ecnt] = ww;
    to[ecnt] = v;
    next[ecnt] = head[u];
    head[u] = ecnt++;
    flw[ecnt] = 0;
    cost[ecnt] = -ww;
    to[ecnt] = u;
    next[ecnt] = head[v];
    head[v] = ecnt++;
  }
  void SPFA() {
    for (int i = 1; i <= T; ++i) dis[i] = (1 << 29);
    priority_queue<pair<int, int> > Q;
    dis[S] = 0;
    Q.push(make_pair(0, S));
    while (!Q.empty()) {
      int u = Q.top().second, d = -Q.top().first;
      Q.pop();
      if (dis[u] != d) continue;
      for (int p = head[u]; p; p = next[p]) {
        int &v = to[p];
        if (flw[p] && dis[v] > d + cost[p]) {
          dis[v] = d + cost[p];
          Q.push(make_pair(-dis[v], v));
        }
      }
    }
    for (int i = 1; i <= T; ++i) dis[i] = dis[T] - dis[i];
  }
  int add_flow(int u, int flow, int &minCost) {
    if (u == T) {
      minCost += dis[S] * flow;
      return flow;
    }
    use[u] = true;
    int now = flow;
    for (int p = head[u]; p; p = next[p]) {
      int &v = to[p];
      if (flw[p] && !use[v] && dis[u] == dis[v] + cost[p]) {
        int tmp = add_flow(v, min(now, flw[p]), minCost);
        flw[p] -= tmp;
        flw[p ^ 1] += tmp;
        now -= tmp;
        if (!now) break;
      }
    }
    return flow - now;
  }
  bool modify_label() {
    int d = (1 << 29);
    for (int u = 1; u <= T; ++u)
      if (use[u])
        for (int p = head[u]; p; p = next[p]) {
          int &v = to[p];
          if (flw[p] && !use[v]) d = min(d, dis[v] + cost[p] - dis[u]);
        }
    if (d == (1 << 29)) return false;
    for (int i = 1; i <= T; ++i)
      if (use[i]) dis[i] += d;
    return true;
  }
  pair<int, int> minCostFlow(int s, int t) {
    S = s;
    T = t;
    SPFA();
    int flw = 0;
    int minCost = 0;
    while (true) {
      while (true) {
        for (int i = 1; i <= T; ++i) use[i] = 0;
        int tt = add_flow(S, (1 << 29), minCost);
        flw += tt;
        if (!tt) break;
      }
      if (!modify_label()) break;
    }
    return {flw, minCost};
  }
  vector<pair<int, int> > getEdge() {
    vector<pair<int, int> > ans;
    for (int(i) = 1; (i) <= (int)(T); (i)++)
      for (int j = head[i]; j > 0; j = next[j])
        if (flw[j] == 0) {
          ans.push_back(make_pair(i, to[j]));
        }
    return ans;
  }
  int in[1000] = {0}, ssSum = 0;
  void addLimEdge(int u, int v, int l, int r, int w) {
    in[v] += l;
    in[u] -= l;
    add_edge(u, v, r - l, w);
  }
  void initLim(int S, int s, int t, int T, int cusInf) {
    for (int i = s; i <= t; i++) {
      if (in[i] < 0)
        add_edge(i, T, -in[i], 0);
      else if (in[i] > 0) {
        add_edge(S, i, in[i], 0);
        ssSum += in[i];
      }
    }
    add_edge(t, s, cusInf, 0);
  }
};
int r, b, n1, n2, mt[222][2];
char ins[2][205];
void fmain(int tid) {
  scanf("%d%d%d%d%d", &n1, &n2, &m, &r, &b);
  for (int(i) = 0; (i) < (int)(2); (i)++) scanf("%s", ins[i] + 1);
  int S = 1, s = 2, t = n1 + n2 + 3, T = t + 1;
  MinCostFlow mf = MinCostFlow();
  int M = 1000;
  for (int(i) = 1; (i) <= (int)(n1); (i)++) {
    if (ins[0][i] == 'R') {
      mf.addLimEdge(s, i + 2, 1, M, 0);
    } else if (ins[0][i] == 'B') {
      mf.addLimEdge(i + 2, t, 1, M, 0);
    } else {
      mf.addLimEdge(s, i + 2, 0, M, 0);
      mf.addLimEdge(i + 2, t, 0, M, 0);
    }
  }
  for (int(i) = 1; (i) <= (int)(n2); (i)++) {
    if (ins[1][i] == 'B') {
      mf.addLimEdge(s, n1 + i + 2, 1, M, 0);
    } else if (ins[1][i] == 'R') {
      mf.addLimEdge(n1 + i + 2, t, 1, M, 0);
    } else {
      mf.addLimEdge(s, n1 + i + 2, 0, M, 0);
      mf.addLimEdge(n1 + i + 2, t, 0, M, 0);
    }
  }
  for (int(i) = 1; (i) <= (int)(m); (i)++) {
    int u, v;
    scanf("%d%d", &u, &v);
    mf.addLimEdge(u + 2, n1 + v + 2, 0, 1, r);
    mt[i][0] = mf.ecnt - 2;
    mf.addLimEdge(n1 + v + 2, u + 2, 0, 1, b);
    mt[i][1] = mf.ecnt - 2;
  }
  mf.initLim(S, s, t, T, M);
  auto ans = mf.minCostFlow(S, T);
  if (ans.first != mf.ssSum) et();
  printf("%d\n", ans.second);
  for (int(i) = 1; (i) <= (int)(m); (i)++) {
    int re = mt[i][0], be = mt[i][1];
    if (mf.flw[re] == 1 && mf.flw[be] == 0)
      printf("B");
    else if (mf.flw[re] == 0 && mf.flw[be] == 1)
      printf("R");
    else
      printf("U");
  }
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
