#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
int n, m, p;
int xx[N], yy[N];
void getdp(int t, int l, int d, int r, int dp[2][N], int op) {
  if (op == 0) {
    for (int i = t; i <= d; i++) {
      int x = i % 2;
      for (int j = l; j <= r; j++) {
        dp[x][j] = 0;
        if (i != t) dp[x][j] = max(dp[x][j], dp[x ^ 1][j]);
        if (j != l) dp[x][j] = max(dp[x][j], dp[x][j - 1]);
        dp[x][j] += (xx[i] + yy[j]) % p;
      }
    }
  } else {
    for (int i = d; i >= t; i--) {
      for (int j = r; j >= l; j--) {
        int x = i % 2;
        dp[x][j] = 0;
        if (i != d) dp[x][j] = max(dp[x][j], dp[x ^ 1][j]);
        if (j != r) dp[x][j] = max(dp[x][j], dp[x][j + 1]);
        dp[x][j] += (xx[i] + yy[j]) % p;
      }
    }
  }
}
int dp1[2][N], dp2[2][N];
void pri(int t, int l, int d, int r, int v) {
  if (t == d) {
    for (int i = 0; i < r - l; i++) {
      printf("S");
    }
    return;
  }
  int m1 = (t + d) / 2;
  getdp(t, l, m1, r, dp1, 0);
  getdp(m1 + 1, l, d, r, dp2, 1);
  int x = m1 % 2;
  for (int i = l; i <= r; i++)
    if (dp1[x][i] + dp2[x ^ 1][i] == v) {
      int v1 = dp1[x][i], v2 = dp2[x ^ 1][i];
      pri(t, l, m1, i, v1);
      printf("C");
      pri(m1 + 1, i, d, r, v2);
      return;
    }
}
int main() {
  while (scanf("%d%d%d", &n, &m, &p) != EOF) {
    for (int i = 0; i < n; i++) {
      scanf("%d", &xx[i]);
    }
    for (int i = 0; i < m; i++) {
      scanf("%d", &yy[i]);
    }
    n--;
    m--;
    getdp(0, 0, n, m, dp1, 0);
    printf("%d\n", dp1[n % 2][m]);
    pri(0, 0, n, m, dp1[n % 2][m]);
    printf("\n");
  }
  return 0;
}
