#include <bits/stdc++.h>
using namespace std;
bitset<20010> flag[20010 >> 1];
char ans[20010 * 2];
int top;
int nRow, nCol, mod, mid, va[20010], vb[20010];
int F[20010], temp[20010];
void read() {
  scanf("%d %d %d", &nRow, &nCol, &mod);
  mid = nRow >> 1;
  for (int i = 1; i <= nRow; i++) scanf("%d", &va[i]);
  for (int i = 1; i <= nCol; i++) scanf("%d", &vb[i]);
}
void work(int t) {
  for (int i = 1; i <= nCol; i++) temp[i] = 0;
  for (int i = 1; i <= nRow; i++) {
    for (int j = 1; j <= nCol; j++) F[j] = -1;
    if (i > mid * t) flag[i - mid * t].reset();
    for (int j = 1; j <= nCol; j++) {
      if (j > 1) F[j] = F[j - 1];
      if (F[j] < temp[j]) {
        F[j] = temp[j];
        if (i > mid * t) flag[i - mid * t][j] = 1;
      }
      temp[j] = F[j] = F[j] + (va[i] + vb[j]) % mod;
    }
  }
  if (t) printf("%d\n", F[nCol]);
  while (nRow > mid * t && (nRow > 1 || nCol > 1)) {
    if (flag[nRow - mid * t][nCol])
      ans[++top] = 'C', nRow--;
    else
      ans[++top] = 'S', nCol--;
  }
}
void print() {
  for (int i = top; i >= 1; i--) printf("%c", ans[i]);
  printf("\n");
}
int main() {
  read();
  work(1), work(0);
  print();
  return 0;
}
