#include <bits/stdc++.h>
using namespace std;
long long f1[2][20001], f2[2][20001];
int x[20001], y[20001];
long long ans = -1;
string str;
int p;
void work(int x1, int y1, int x2, int y2) {
  if (x2 - x1 + y2 - y1 == 1) {
    str += x1 == x2 ? 'S' : 'C';
    if (ans < 0) ans = (x[x1] + y[y1]) % p + (x[x2] + y[y2]) % p;
  } else if (x1 < x2 || y1 < y2) {
    int s1 = (x2 - x1 + y2 - y1) / 2, s2 = x2 - x1 + y2 - y1 - s1, t = -1;
    for (int i = 0; i <= s1; i++)
      for (int j = max(x1, x1 - (y2 - y1) + i); j <= min(x2, x1 + i); j++)
        f1[i & 1][j] = max(j > x1 ? f1[~i & 1][j - 1] : 0,
                           j < x1 + i ? f1[~i & 1][j] : 0) +
                       (x[j] + y[y1 + i - (j - x1)]) % p;
    for (int i = 0; i <= s2; i++)
      for (int j = max(x1, x2 - i); j <= min(x2, x2 + (y2 - y1) - i); j++)
        f2[i & 1][j] = max(j < x2 ? f2[~i & 1][j + 1] : 0,
                           j > x2 - i ? f2[~i & 1][j] : 0) +
                       (x[j] + y[y2 - i + (x2 - j)]) % p;
    for (int i = max(x1, x1 - (y2 - y1) + s1); i <= min(x2, x1 + s1); i++)
      if (t < 0 ||
          f1[s1 & 1][i] + f2[s2 & 1][i] - (x[i] + y[y1 + s1 - (i - x1)]) % p >
              f1[s1 & 1][t] + f2[s2 & 1][t] -
                  (x[t] + y[y1 + s1 - (t - x1)]) % p)
        t = i;
    if (ans < 0)
      ans = f1[s1 & 1][t] + f2[s2 & 1][t] - (x[t] + y[y1 + s1 - (t - x1)]) % p;
    work(x1, y1, t, y1 + s1 - (t - x1));
    work(t, y2 - s2 + (x2 - t), x2, y2);
  } else if (ans < 0)
    ans = (x[x1] + y[y1]) % p;
}
int main() {
  int n, m;
  cin >> 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]);
  work(0, 0, n - 1, m - 1);
  cout << ans << endl << str << endl;
  return 0;
}
