#include <bits/stdc++.h>
using namespace std;
const char col[] = "BRWY";
set<vector<int> > VIS;
vector<int> need(10, 0);
int S, T, best;
int F[22][22], u[22];
int A[10], a[10], C[10][10], fir[10], sec[10], num[4][4];
char ans[13][15], tmp[13][15];
int tr[7][8], td[7][8], s[7][8], vis[7][8];
void init() {
  S = 20;
  T = 21;
  int i, j;
  for (i = 0; i < (22); i++)
    for (j = 0; j < (22); j++) F[i][j] = 0;
}
int find(int x, int flow) {
  if (x == T) return flow;
  u[x] = 1;
  int i;
  for (i = 0; i < (22); i++)
    if (F[x][i] && !u[x]) {
      int tmp = find(i, min(flow, F[x][i]));
      F[x][i] -= tmp;
      F[i][x] += tmp;
      return tmp;
    }
  return 0;
}
void maxflow(int &ret) {
  memset(u, 0, sizeof u);
  int flow = find(S, 56);
  while (flow) {
    memset(u, 0, sizeof u);
    ret += flow;
    flow = find(S, 56);
  }
}
void solve() {
  int i, j, k, l;
  if (VIS.count(need)) return;
  VIS.insert(need);
  for (i = 0; i < (10); i++) A[i] = a[i];
  for (i = 0; i < (10); i++)
    for (j = 0; j < (10); j++) C[i][j] = 0;
  int ret = 0;
  for (i = 0; i < (10); i++) {
    C[i][i] = min(need[i], A[i]);
    ret += 2 * C[i][i];
  }
  if (ret / 2 + 28 <= best) return;
  init();
  for (i = 0; i < (10); i++) {
    if (A[i] > need[i]) F[S][i] += A[i] - need[i];
    if (A[i] < need[i]) F[i + 10][T] += need[i] - A[i];
  }
  for (i = 0; i < (10); i++)
    for (j = 0; j < (10); j++)
      if (fir[i] == fir[j] || fir[i] == sec[j] || sec[i] == fir[j] ||
          sec[i] == sec[j]) {
        k = min(F[S][i], F[j + 10][T]);
        F[S][i] -= k;
        F[j + 10][T] -= k;
        F[i][j + 10] += 56;
        ret += k;
        C[i][j] += k;
      }
  maxflow(ret);
  if (ret > best) {
    best = ret;
    for (i = 0; i < (13); i++)
      for (j = 0; j < (15); j++) ans[i][j] = tmp[i][j];
    for (i = 0; i < (10); i++)
      for (j = 0; j < (10); j++) C[i][j] += F[j + 10][i];
    for (i = 0; i < (7); i++)
      for (j = 0; j < (8); j++)
        if (tr[i][j]) {
          k = num[s[i][j]][s[i][j + 1]];
          for (l = 0; l < (10); l++)
            if (C[l][k]) {
              C[l][k]--;
              A[l]--;
              if (s[i][j] == fir[l] || s[i][j + 1] == sec[l]) {
                ans[i + i][j + j] = col[fir[l]];
                ans[i + i][j + j + 2] = col[sec[l]];
              } else {
                ans[i + i][j + j] = col[sec[l]];
                ans[i + i][j + j + 2] = col[fir[l]];
              }
              break;
            }
        }
    for (i = 0; i < (7); i++)
      for (j = 0; j < (8); j++)
        if (td[i][j]) {
          k = num[s[i][j]][s[i + 1][j]];
          for (l = 0; l < (10); l++)
            if (C[l][k]) {
              C[l][k]--;
              A[l]--;
              if (s[i][j] == fir[l] || s[i + 1][j] == sec[l]) {
                ans[i + i][j + j] = col[fir[l]];
                ans[i + i + 2][j + j] = col[sec[l]];
              } else {
                ans[i + i][j + j] = col[sec[l]];
                ans[i + i + 2][j + j] = col[fir[l]];
              }
              break;
            }
        }
    for (i = 0; i < (7); i++)
      for (j = 0; j < (8); j++)
        if (ans[i + i][j + j] == '.')
          for (l = 0; l < (10); l++)
            if (A[l]) {
              if (tr[i][j]) {
                A[l]--;
                ans[i + i][j + j] = col[fir[l]];
                ans[i + i][j + j + 2] = col[sec[l]];
              } else {
                A[l]--;
                ans[i + i][j + j] = col[fir[l]];
                ans[i + i + 2][j + j] = col[sec[l]];
              }
              break;
            }
  }
}
void dfs(int x, int y) {
  if (x == 7) {
    solve();
    return;
  }
  if (y == 8) {
    dfs(x + 1, 0);
    return;
  }
  if (vis[x][y]) {
    dfs(x, y + 1);
    return;
  }
  if (y < 7 && !vis[x][y + 1]) {
    vis[x][y] = vis[x][y + 1] = 1;
    need[num[s[x][y]][s[x][y + 1]]]++;
    tmp[x + x][y + y + 1] = '-';
    tr[x][y] = 1;
    dfs(x, y + 1);
    vis[x][y] = vis[x][y + 1] = 0;
    need[num[s[x][y]][s[x][y + 1]]]--;
    tmp[x + x][y + y + 1] = '.';
    tr[x][y] = 0;
  }
  if (x < 6 && !vis[x + 1][y]) {
    vis[x][y] = vis[x + 1][y] = 1;
    need[num[s[x][y]][s[x + 1][y]]]++;
    tmp[x + x + 1][y + y] = '|';
    td[x][y] = 1;
    dfs(x, y + 1);
    vis[x][y] = vis[x + 1][y] = 0;
    need[num[s[x][y]][s[x + 1][y]]]--;
    tmp[x + x + 1][y + y] = '.';
    td[x][y] = 0;
  }
}
int main() {
  int i, j;
  for (i = 0; i < (7); i++)
    for (j = 0; j < (8); j++) {
      char x;
      cin >> x;
      if (x == 'B') s[i][j] = 0;
      if (x == 'R') s[i][j] = 1;
      if (x == 'W') s[i][j] = 2;
      if (x == 'Y') s[i][j] = 3;
    }
  int tt = 0;
  for (i = 0; i < (4); i++)
    for (j = 3; j >= i; j--) {
      cin >> a[tt];
      fir[tt] = i;
      sec[tt] = j;
      num[i][j] = num[j][i] = tt++;
    }
  memset(tmp, '.', sizeof tmp);
  best = -1;
  dfs(0, 0);
  cout << best << endl;
  for (i = 0; i < (13); i++) {
    for (j = 0; j < (15); j++) cout << ans[i][j];
    cout << endl;
  }
}
