#include <bits/stdc++.h>
using namespace std;
inline int _pow(int a, int b) {
  int tmp = 1;
  for (; b; b >>= 1) {
    if (b & 1) tmp = (long long)tmp * a % 1000000007;
    a = (long long)a * a % 1000000007;
  }
  return tmp;
}
template <class T>
inline void R(T &xx) {
  xx = 0;
  char ch = getchar();
  bool F = 0;
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') F = 1, ch = getchar();
  while (ch >= '0' && ch <= '9')
    xx = xx + xx + (xx << 3) + ch - 48, ch = getchar();
  if (F) xx = -xx;
}
int n, m, p, x[20011], y[20011], f[20011], g[20011];
string s;
int work(int l, int r, int u, int d) {
  int ans = 0, k;
  if (l == r) {
    for (int i = (u); i < (int)(d); i++)
      s.push_back('S'), ans += ((x[l] + y[i]) % p);
    return ans += ((x[l] + y[d]) % p);
  }
  int mid = l + r >> 1;
  for (int i = (u); i <= (d); i++) f[i] = g[i] = 0;
  for (int i = (l); i <= (mid); i++) {
    f[u] += ((x[i] + y[u]) % p);
    for (int j = (u + 1); j <= (d); j++)
      f[j] = max(f[j - 1], f[j]) + ((x[i] + y[j]) % p);
  }
  for (int i = (r); i >= (mid + 1); i--) {
    g[d] += ((x[i] + y[d]) % p);
    for (int j = (d - 1); j >= (u); j--)
      g[j] = max(g[j + 1], g[j]) + ((x[i] + y[j]) % p);
  }
  for (int i = (u); i <= (d); i++)
    if (f[i] + g[i] >= ans) ans = f[i] + g[i], k = i;
  work(l, mid, u, k);
  s.push_back('C');
  work(mid + 1, r, k, d);
  return ans;
}
int main() {
  R(n), R(m), R(p);
  for (int i = 0; i < (int)(n); i++) R(x[i]);
  for (int i = 0; i < (int)(m); i++) R(y[i]);
  printf("%d\n", work(0, n - 1, 0, m - 1));
  cout << s << endl;
  return 0;
}
