Problem: Little Gerald and his coach Mike play an interesting game. At the beginning of the game there is a pile consisting of n candies and a pile consisting of m stones. Gerald and Mike move in turns, Mike goes first. During his move Mike checks how many candies and stones Gerald has eaten. Let Gerald eat a candies and b stones. Then Mike awards Gerald f(a, b) prize points. Gerald during his move either eats a candy from the pile of candies or a stone from the pile of stones. As Mike sees that Gerald has eaten everything apart one candy and one stone, he awards points for the last time and the game ends. Gerald is not allowed to eat all the candies, and he is not allowed to eat all the stones too. Tell Gerald how to play to get the largest possible number of points: it is required to find one of the possible optimal playing strategies for Gerald.

Input

The first line contains three integers n, m, p (1 ≤ n, m ≤ 20000, 1 ≤ p ≤ 109). The second line contains n integers x0, x1, ..., xn - 1 (0 ≤ xi ≤ 20000). The third line contains m integers y0, y1, ..., ym - 1 (0 ≤ yi ≤ 20000). The value of f(a, b) is calculated as a remainder of the division of the sum xa + yb by number p.

Output

Print on the first line the only number: the maximal number of points Gerald can earn. Print on the second line a sting consisting of n + m - 2 characters, each of which is either a "C" or "S", the i-th character should be "C" if Gerald's i-th move should be eating a candy and "S" if he should eat a stone.

Examples

Input

2 2 10
0 0
0 1


Output

2
SC


Input

3 3 10
0 2 0
0 0 2


Output

10
CSSC


Input

3 3 2
0 1 1
1 1 0


Output

4
SCSC

Note

In the first test if Gerald's first move is eating a stone, he will receive a point for it and if he eats a candy, he will get zero pints. In any way Gerald will get 0 points before his first move, and 1 after his second one. This, the maximum number of points Gerald can get equals to 2, and for that he should first eat a stone, then a candy.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:65777216")
using namespace std;
int n, m, p;
int x[22222];
int y[22222];
int d[10007][650];
int d1[20000];
int d2[20000];
string res;
bool first = true;
void go() {
  if (n == 0 && m == 0) return;
  if (n == 0) {
    res.push_back('S');
    m--;
    go();
    return;
  }
  if (m == 0) {
    res.push_back('C');
    n--;
    go();
    return;
  }
  if (n == 10000 && first) {
    first = false;
    return;
  }
  int row = n;
  if (row > 10000) row -= 10000;
  int md = m % 31;
  int dv = m / 31;
  if (d[row][dv] & (1 << md)) {
    res.push_back('S');
    m--;
    go();
  } else {
    res.push_back('C');
    n--;
    go();
  }
}
int solve() {
  memset(d1, 0, sizeof(d1));
  memset(d2, 0, sizeof(d2));
  memset(d, 0, sizeof(d));
  int *f1 = d1;
  int *f2 = d2;
  for (int i(0); i < (n); i++) {
    int md = -1;
    int dv = 0;
    for (int j(0); j < (m); j++) {
      md++;
      if (md >= 31) md -= 31, dv++;
      int row = i;
      if (row > 10000) row -= 10000;
      if (d[row][dv] & (1 << md)) d[row][dv] ^= (1 << md);
      f1[j] = (x[i] + y[j]);
      if (f1[j] >= p) f1[j] -= p;
      int v1 = j ? f1[j - 1] : -1;
      int v2 = i ? f2[j] : -1;
      if (v1 == -1 && v2 == -1) continue;
      if (v1 > v2) {
        f1[j] += v1;
        d[row][dv] |= (1 << md);
      } else {
        f1[j] += v2;
      }
    }
    swap(f1, f2);
  }
  return f2[m - 1];
}
bool check(string s, int val) {
  int t = (x[0] + y[0]) % p;
  int a = 0, b = 0;
  for (int i(0); i < (s.size()); i++) {
    if (s[i] == 'C')
      a++;
    else
      b++;
    t += (x[a] + y[b]) % p;
  }
  if (t != val) {
    puts("FUCK");
    return 0;
  } else
    puts("OK");
  return 1;
}
int main() {
  cin >> n >> m >> p;
  for (int i(0); i < (n); i++) {
    scanf("%d", x + i);
    x[i] %= p;
  }
  for (int i(0); i < (m); i++) {
    scanf("%d", y + i);
    y[i] %= p;
  }
  res = "";
  int qq = solve();
  cout << qq << endl;
  n--, m--;
  go();
  n++, m++;
  solve();
  n--, m--;
  go();
  reverse(res.begin(), res.end());
  printf("%s\n", res.c_str());
  return 0;
}