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>
using namespace std;
template <typename T, typename U>
std::istream& operator>>(std::istream& i, pair<T, U>& p) {
  i >> p.first >> p.second;
  return i;
}
template <typename T>
std::istream& operator>>(std::istream& i, vector<T>& t) {
  for (auto& v : t) {
    i >> v;
  }
  return i;
}
template <typename T, typename U>
std::ostream& operator<<(std::ostream& o, const pair<T, U>& p) {
  o << p.first << ' ' << p.second;
  return o;
}
template <typename T>
std::ostream& operator<<(std::ostream& o, const vector<T>& t) {
  if (t.empty()) o << '\n';
  for (size_t i = 0; i < t.size(); ++i) {
    o << t[i] << " \n"[i == t.size() - 1];
  }
  return o;
}
template <typename T>
using minheap = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using maxheap = priority_queue<T, vector<T>, less<T>>;
template <typename T>
bool in(T a, T b, T c) {
  return a <= b && b < c;
}
unsigned int logceil(long long first) {
  return first ? 8 * sizeof(long long) - __builtin_clzll(first) : 0;
}
namespace std {
template <typename T, typename U>
struct hash<pair<T, U>> {
  hash<T> t;
  hash<U> u;
  size_t operator()(const pair<T, U>& p) const {
    return t(p.first) ^ (u(p.second) << 7);
  }
};
}  // namespace std
template <typename T, typename F>
T bsh(T l, T h, const F& f) {
  T r = -1, m;
  while (l <= h) {
    m = (l + h) / 2;
    if (f(m)) {
      l = m + 1;
      r = m;
    } else {
      h = m - 1;
    }
  }
  return r;
}
template <typename F>
double bshd(double l, double h, const F& f, double p = 1e-9) {
  unsigned int r = 3 + (unsigned int)log2((h - l) / p);
  while (r--) {
    double m = (l + h) / 2;
    if (f(m)) {
      l = m;
    } else {
      h = m;
    }
  }
  return (l + h) / 2;
}
template <typename T, typename F>
T bsl(T l, T h, const F& f) {
  T r = -1, m;
  while (l <= h) {
    m = (l + h) / 2;
    if (f(m)) {
      h = m - 1;
      r = m;
    } else {
      l = m + 1;
    }
  }
  return r;
}
template <typename F>
double bsld(double l, double h, const F& f, double p = 1e-9) {
  unsigned int r = 3 + (unsigned int)log2((h - l) / p);
  while (r--) {
    double m = (l + h) / 2;
    if (f(m)) {
      h = m;
    } else {
      l = m;
    }
  }
  return (l + h) / 2;
}
template <typename T>
T gcd(T a, T b) {
  if (a < b) swap(a, b);
  return b ? gcd(b, a % b) : a;
}
template <typename T>
class vector2 : public vector<vector<T>> {
 public:
  vector2() {}
  vector2(size_t a, size_t b, T t = T())
      : vector<vector<T>>(a, vector<T>(b, t)) {}
};
template <typename T>
class vector3 : public vector<vector2<T>> {
 public:
  vector3() {}
  vector3(size_t a, size_t b, size_t c, T t = T())
      : vector<vector2<T>>(a, vector2<T>(b, c, t)) {}
};
template <typename T>
class vector4 : public vector<vector3<T>> {
 public:
  vector4() {}
  vector4(size_t a, size_t b, size_t c, size_t d, T t = T())
      : vector<vector3<T>>(a, vector3<T>(b, c, d, t)) {}
};
template <typename T>
class vector5 : public vector<vector4<T>> {
 public:
  vector5() {}
  vector5(size_t a, size_t b, size_t c, size_t d, size_t e, T t = T())
      : vector<vector4<T>>(a, vector4<T>(b, c, d, e, t)) {}
};
class ECandiesAndStones {
 public:
  void solve(istream& cin, ostream& cout) {
    int N, M, P;
    cin >> N >> M >> P;
    vector<int> X(N), Y(M);
    cin >> X >> Y;
    for (int& first : X) first %= P;
    for (int& second : Y) second %= P;
    vector<std::pair<int, int>> D(M, {0, 0});
    vector<vector<std::pair<int, int>>> R;
    vector<int> CH, W;
    int C = 120;
    D[0] = {(X[0] + Y[0]) % P, 0};
    for (int j = 0; j < M - 1; ++j)
      D[j + 1] =
          max(D[j + 1], {D[j].first + (X[0] + Y[j + 1]) % P, D[j].second});
    for (int i = 0; i < N; ++i) {
      if (i % C == 0 || i == N - 1) {
        CH.push_back(i);
        R.push_back(D);
        for (int j = 0; j < M; ++j) D[j].second = j;
      }
      if (i != N - 1) {
        vector<std::pair<int, int>> E(M, {0, 0});
        for (int j = 0; j < M; ++j) {
          E[j] = max(E[j], {D[j].first + (X[i + 1] + Y[j]) % P, D[j].second});
        }
        for (int j = 0; j < M - 1; ++j)
          E[j + 1] = max(E[j + 1],
                         {E[j].first + (X[i + 1] + Y[j + 1]) % P, E[j].second});
        swap(E, D);
      }
    }
    int Q = R.size();
    W.resize(Q);
    int w = M - 1;
    W[Q - 1] = w;
    for (int i = Q - 1; i >= 1; --i) W[i - 1] = w = R[i][w].second;
    R.clear();
    vector2<std::pair<int, int>> E(C + 1, M, {0, 0});
    string Ans;
    for (int i = 0; i < Q - 1; ++i) {
      int L = CH[i + 1] - CH[i];
      int l = W[i], r = W[i + 1] + 1;
      for (int i = 0; i <= L; ++i)
        for (int j = l; j < r; ++j) E[i][j] = {0, 0};
      E[0][l] = {100, l};
      for (int j = 0; j < L; ++j) {
        for (int k = l; k < r; ++k) {
          E[j + 1][k] = max(E[j + 1][k],
                            {E[j][k].first + (X[CH[i] + j + 1] + Y[k]) % P, k});
        }
        for (int k = l; k < r - 1; ++k) {
          E[j + 1][k + 1] =
              max(E[j + 1][k + 1],
                  {E[j + 1][k].first + (X[CH[i] + j + 1] + Y[k + 1]) % P,
                   E[j + 1][k].second});
        }
      }
      w = W[i + 1];
      string S;
      for (int j = L; j > 0; --j) {
        int t = E[j][w].second;
        S += string(w - t, 'S');
        S += 'C';
        w = t;
      }
      reverse(S.begin(), S.end());
      Ans += S;
    }
    string S;
    for (int a = 0; a < W[0]; ++a) S += 'S';
    Ans = S + Ans;
    int a = 0, b = 0, t = (X[0] + Y[0]) % P;
    for (char c : Ans) {
      if (c == 'C')
        ++a;
      else
        ++b;
      t += (X[a] + Y[b]) % P;
    }
    cout << t << '\n';
    cout << Ans << '\n';
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  ECandiesAndStones solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}