#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pli = pair<ll, int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
int n, m, p;
int x[N], y[N], dp1[N], dp2[N];
string s;
int ans;
void divide(int a, int b, int c, int d) {
  if (a == b) {
    for (int i = c + 1; i <= d; i++) ans += (x[a] + y[i]) % p, s += 'S';
    ans += (x[a] + y[c]) % p;
    return;
  }
  for (int i = c; i <= d; i++) dp1[i] = dp2[i] = 0;
  int mid = (a + b) >> 1;
  for (int i = a; i <= mid; i++)
    for (int j = c; j <= d; j++)
      dp1[j] = max(dp1[j], dp1[j - 1]) + (x[i] + y[j]) % p;
  for (int i = b; i != mid; --i)
    for (int j = d; j >= c; j--)
      dp2[j] = max(dp2[j], dp2[j + 1]) + (x[i] + y[j]) % p;
  int pos = 0, maxn = -INF;
  for (int i = c; i <= d; i++)
    if (dp1[i] + dp2[i] > maxn) maxn = dp1[i] + dp2[i], pos = i;
  divide(a, mid, c, pos);
  s += 'C';
  divide(mid + 1, b, pos, d);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> p;
  for (int i = 1; i <= n; i++) cin >> x[i];
  for (int i = 1; i <= m; i++) cin >> y[i];
  divide(1, n, 1, m);
  cout << ans << '\n';
  cout << s << '\n';
  return 0;
}
