#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = getchar();
  int nega = 1;
  while (!isdigit(ch)) {
    if (ch == '-') nega = -1;
    ch = getchar();
  }
  int ans = 0;
  while (isdigit(ch)) {
    ans = ans * 10 + ch - 48;
    ch = getchar();
  }
  if (nega == -1) return -ans;
  return ans;
}
inline int min(int x, int y, int z) { return min(x, min(y, z)); }
inline int max(int x, int y, int z) { return max(x, max(y, z)); }
inline int add(int x, int y) {
  return x + y >= 998244353 ? x + y - 998244353 : x + y;
}
inline int add(int x, int y, int z) { return add(add(x, y), z); }
inline int sub(int x, int y) { return x - y < 0 ? x - y + 998244353 : x - y; }
inline int mul(int x, int y) { return 1LL * x * y % 998244353; }
inline int mul(int x, int y, int z) { return mul(mul(x, y), z); }
struct Edge {
  int u, v, w, nxt, cap;
};
Edge edge[50005];
int first[505], ss = 1;
void adde(int u, int v, int w, int x) {
  ss++;
  edge[ss].u = u, edge[ss].v = v, edge[ss].cap = w, edge[ss].w = x;
  edge[ss].nxt = first[u];
  first[u] = ss;
  ss++;
  edge[ss].u = v, edge[ss].v = u, edge[ss].cap = 0, edge[ss].w = -x;
  edge[ss].nxt = first[v];
  first[v] = ss;
}
int n1, n2, m, R, B;
char s1[505], s2[505];
int s, t, S, T, sum, ans;
int d1[505], d2[505], d[505];
int id1[505], id2[505];
int dis[505], vis[505], fr[505];
bool spfa(int s, int t) {
  for (int i = 1; i <= T; i++) dis[i] = 0x3f3f3f3f;
  dis[s] = 0;
  queue<int> q;
  q.push(s);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    vis[u] = 0;
    for (int i = first[u]; i != 0; i = edge[i].nxt) {
      if (!edge[i].cap) continue;
      int v = edge[i].v;
      if (dis[v] > dis[u] + edge[i].w) {
        dis[v] = dis[u] + edge[i].w;
        fr[v] = i;
        if (!vis[v]) vis[v] = 1, q.push(v);
      }
    }
  }
  if (dis[t] == 0x3f3f3f3f) return 0;
  sum--;
  if (sum < 0) return 0;
  for (int i = fr[t]; i != 0; i = fr[edge[i].u]) {
    edge[i].cap--, edge[i ^ 1].cap++;
    ans += edge[i].w;
  }
  return 1;
}
signed main() {
  cin >> n1 >> n2 >> m >> R >> B;
  scanf("%s%s", s1 + 1, s2 + 1);
  s = n1 + n2 + 1, t = n1 + n2 + 2, S = n1 + n2 + 3, T = n1 + n2 + 4;
  for (int i = 1; i <= m; i++) {
    int u = read(), v = read();
    d1[u]++, d2[v]++;
    d[u]++, d[v + n1]--;
    adde(u, v + n1, 1, R);
    id1[i] = ss;
    adde(v + n1, u, 1, B);
    id2[i] = ss;
  }
  for (int i = 1; i <= n1; i++) {
    if (!d1[i] && s1[i] != 'U') {
      cout << "-1\n";
      return 0;
    }
    if (s1[i] != 'U') {
      adde(s, i, d1[i] - 1, 0);
      if (s1[i] == 'R') d[i] -= d1[i] + 1, d[s] += d1[i] + 1;
    } else {
      adde(s, i, 2 * d1[i], 0);
    }
  }
  for (int i = 1; i <= n2; i++) {
    if (!d2[i] && s2[i] != 'U') {
      cout << "-1\n";
      return 0;
    }
    if (s2[i] != 'U') {
      adde(i + n1, t, d2[i] - 1, 0);
      if (s2[i] == 'R') d[i + n1] += d2[i] + 1, d[t] -= d2[i] + 1;
    } else {
      adde(i + n1, t, 2 * d2[i], 0);
    }
  }
  for (int i = 1; i <= T; i++) {
    if (d[i] > 0)
      sum += d[i], adde(i, T, d[i], 0);
    else if (d[i] < 0)
      adde(S, i, -d[i], 0);
  }
  adde(t, s, 0x3f3f3f3f, 0);
  while (spfa(S, T))
    ;
  if (sum) {
    cout << "-1\n";
    return 0;
  }
  cout << ans << endl;
  for (int i = 1; i <= m; i++) {
    if (edge[id1[i]].cap)
      printf("R");
    else if (edge[id2[i]].cap)
      printf("B");
    else
      printf("U");
  }
  return 0;
}
