#include <bits/stdc++.h>
using namespace std;
const int maxn = 20005;
int x[maxn], y[maxn];
int f[maxn], g[maxn];
string ans;
int n, m, p, ret;
void init() {
  scanf("%d%d%d", &n, &m, &p);
  for (int i = 0; i < n; i++) scanf("%d", &x[i]);
  for (int i = 0; i < m; i++) scanf("%d", &y[i]);
}
inline int Fmax(int x, int y) { return x > y ? x : y; }
int solve(int l0, int r0, int l1, int r1) {
  int ret = 0;
  if (l0 == r0) {
    ret += ((x[l0] + y[r1]) % p);
    for (int i = l1; i < r1; i++) ans += 'S', ret += ((x[l0] + y[i]) % p);
    return ret;
  }
  int mid = (l0 + r0) >> 1;
  for (int i = l1; i <= r1; i++) f[i] = g[i] = 0;
  for (int i = l0; i <= mid; i++) {
    f[l1] += ((x[i] + y[l1]) % p);
    for (int j = l1 + 1; j <= r1; j++)
      f[j] = Fmax(f[j], f[j - 1]) + ((x[i] + y[j]) % p);
  }
  for (int i = r0; i > mid; i--) {
    g[r1] += ((x[i] + y[r1]) % p);
    for (int j = r1 - 1; j >= l1; j--)
      g[j] = Fmax(g[j], g[j + 1]) + ((x[i] + y[j]) % p);
  }
  int p = 0;
  for (int i = l1; i <= r1; i++)
    if (f[i] + g[i] >= ret) ret = f[i] + g[i], p = i;
  solve(l0, mid, l1, p);
  ans += 'C';
  solve(mid + 1, r0, p, r1);
  return ret;
}
void work() { ret = solve(0, n - 1, 0, m - 1); }
void print() {
  printf("%d\n", ret);
  cout << ans << endl;
}
int main() {
  init();
  work();
  print();
  return 0;
}
