#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
/*
#define cin fin
#define cout fout

ifstream fin("input.txt");
ofstream fout("output.txt");*/

#define SI(x) cin>>x
#define DI(x, y) cin>>x>>y
#define TI(x, y, z) cin>>x>>y>>z
#define FI(w, x, y, z) cin>>w>>x>>y>>z

#define SO(x) cout<<x<<endl
#define DO(x, y) cout<<x<<" "<<y<<endl
#define TO(x, y, z) cout<<x<<" "<<y<<" "<<z<<endl
#define FO(w, x, y, z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<endl

#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

#define pr pair<lli, lli>
//#define V(x) vector<x>
#define pb(x) push_back(x)
#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend());
#define mp(x, y) make_pair(x, y)
#define fi first
#define se second
#define mll(x, y) map<lli x, lli y>

#define F(i, a, n) for(i=a;i<n;i++)
#define B(i, a, n) for(i=n-1;i>=a;i--)

#define mod 1000000007
#define pi 3.141592653589793238

//GCD
lli gcd(lli a, lli b){
    if(b < a)    {
        lli temp = a;
        a = b;
        b = temp;
    }
    if(a == 0){
        return b;
    }
    return gcd(b%a,a);
}

//LCM
lli lcm(lli a, lli b){
    return (a*b/gcd(a,b));
}

//Factorial
lli fact(lli x){
    lli ans = 1;
    if(x == 0){
        return 1;
    }
    while(x > 0){
        ans = (ans*x)%mod;
        x--;
    }
    return ans%mod;
}

//power a^b
lli power(lli a, lli b){
    lli ans = 1;
    while(b > 0){
        if(b%2 == 1){
            ans *= a;
            ans = ans;
        }
        b/=2;
        a*=a;
        a = a;
    }
    return ans;
}

//binary of a number
vector <lli> getbinary(lli x){
    vector <lli> bin(20000,0);
    lli iter = 0;
    while(x > 0){
        if(x%2 == 1){
            bin[iter] = 1;
        }
        else{
            bin[iter] = 0;
        }
        iter++;
        x/=2;
    }
    return bin;
}
int main(){
    FASTER;
    lli n, m, k, i, j, l;
    TI(n, m, k);
    char c, d[n][m][k+1];
    lli a[n][m], b[n][m][k+1];
    F(i, 0, n){
        F(j, 0, m){
            SI(c);
            a[i][j]=c-'0';
            F(l, 0, k+1){
                b[i][j][l]=-1;
            }
        }
    }
    F(i, 0, m){
        b[n-1][i][a[n-1][i]%(k+1)]=a[n-1][i];
    }
    for(i=n-2;i>=0;i--){
        F(j, 0, m){
            if(j!=0){
                F(l, 0, k+1){
                    if(b[i+1][j-1][l]!=-1){
                        if(b[i+1][j-1][l]+a[i][j]>b[i][j][b[i+1][j-1][l]%(k+1)]){
                            b[i][j][(b[i+1][j-1][l]+a[i][j])%(k+1)]=b[i+1][j-1][l]+a[i][j];
                            d[i][j][(b[i+1][j-1][l]+a[i][j])%(k+1)]='R';
                        }
                        else{
                            d[i][j][(b[i+1][j-1][l]+a[i][j])%(k+1)]='L';
                        }
                    }
                }
            }
            if(j!=m-1){
                F(l, 0, k+1){
                    if(b[i+1][j+1][l]!=-1){
                        if(b[i+1][j+1][l]+a[i][j]>b[i][j][b[i+1][j+1][l]%(k+1)]){
                            b[i][j][(b[i+1][j+1][l]+a[i][j])%(k+1)]=b[i+1][j+1][l]+a[i][j];
                            d[i][j][(b[i+1][j+1][l]+a[i][j])%(k+1)]='L';
                        }
                        else{
                            d[i][j][(b[i+1][j+1][l]+a[i][j])%(k+1)]='R';
                        }
                    }
                }
            }
        }
    }
    l=-1;
    j=0;
    F(i, 0, m){
        if(b[0][i][0]>l){
            l=b[0][i][0];
            j=i;
        }
    }
    SO(l);
    if(l!=-1){
        vector<char> e;
        l=0;
        F(i, 0, n){
            e.pb(d[i][j][l]);
            l-=a[i][j];
            l%=(k+1);
            if(d[i][j][l]=='R' && i!=n-1){
                j--;
            }
            else if(i!=n-1){
                j++;
            }
        }
        SO(j+1);
        for(i=e.size()-2;i>=0;i--)
            cout<<e.at(i);
    }
}


#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <queue>
#include <memory.h>
#include <stack>
#define mp make_pair
#define pb push_back
#define setval(a,v) memset(a,v,sizeof(a))

#if ( _WIN32 || __WIN32__ )
    #define LLD "%I64d"
#else
    #define LLD "%lld"
#endif

using namespace std;

typedef long long int64;
typedef long double ld;

int t[110][110][15];
int a[110][110];
int n,m,k;

void gen(int x,int y,int ost){
//  cerr<<x<<" "<<y<<" "<<ost<<endl;
    if (x==0){
        printf("%d\n",y+1);
        return;
    }
    int ost1=ost;
    ost-=a[x][y];
    ost+=1000*k;
    ost%=k;
    if (y==0){
        gen(x-1,y+1,ost);
        printf("L");
        return;
    }
    if (y==m-1){
        gen(x-1,y-1,ost);
        printf("R");
        return;
    }
    if (t[x-1][y+1][ost]+a[x][y]==t[x][y][ost1]){
        gen(x-1,y+1,ost);
        printf("L");
        return;
    }
    gen(x-1,y-1,ost);
    printf("R");
    return;
}

int main()
{
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
    cin>>n>>m>>k;
    k++;
    for (int i=n-1;i>=0;i--)
        for (int j=0;j<m;j++)
            {
                char c;
                scanf(" %c ",&c);
                a[i][j]=c-'0';
            }
    for (int x=0;x<n;x++)
        for (int i=0;i<m;i++)
            for (int j=0;j<k;j++)
                t[x][i][j]=-(1<<29);
    for (int i=0;i<m;i++)
        t[0][i][a[0][i]%k]=a[0][i];

    for (int i=1;i<n;i++){
        for (int j=0;j<m;j++)
            for (int l=0;l<k;l++){
                if (j!=0)
                    t[i][j][l]=max(t[i][j][l],t[i-1][j-1][(l-a[i][j]+1000*k)%k]+a[i][j]);
                if (j!=m-1)
                    t[i][j][l]=max(t[i][j][l],t[i-1][j+1][(l-a[i][j]+1000*k)%k]+a[i][j]);
            //  cerr<<i<<" "<<j<<" "<<l<<" "<<t[i][j][l]<<endl;
            }
        }

    int ans=-(1<<29);
    for (int i=0;i<m;i++)
        ans=max(ans,t[n-1][i][0]);
    if (ans<0){
        printf("-1\n");
        return 0;
    }
    cout<<ans<<endl;
    for (int i=0;i<m;i++)
        if (t[n-1][i][0]==ans){
            gen(n-1,i,0);
            return 0;
        }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
/*
#define cin fin
#define cout fout

ifstream fin("input.txt");
ofstream fout("output.txt");*/

#define SI(x) cin>>x
#define DI(x, y) cin>>x>>y
#define TI(x, y, z) cin>>x>>y>>z
#define FI(w, x, y, z) cin>>w>>x>>y>>z

#define SO(x) cout<<x<<endl
#define DO(x, y) cout<<x<<" "<<y<<endl
#define TO(x, y, z) cout<<x<<" "<<y<<" "<<z<<endl
#define FO(w, x, y, z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<endl

#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

#define pr pair<lli, lli>
//#define V(x) vector<x>
#define pb(x) push_back(x)
#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend());
#define mp(x, y) make_pair(x, y)
#define fi first
#define se second
#define mll(x, y) map<lli x, lli y>

#define F(i, a, n) for(i=a;i<n;i++)
#define B(i, a, n) for(i=n-1;i>=a;i--)

#define mod 1000000007
#define pi 3.141592653589793238

//GCD
lli gcd(lli a, lli b){
    if(b < a)    {
        lli temp = a;
        a = b;
        b = temp;
    }
    if(a == 0){
        return b;
    }
    return gcd(b%a,a);
}

//LCM
lli lcm(lli a, lli b){
    return (a*b/gcd(a,b));
}

//Factorial
lli fact(lli x){
    lli ans = 1;
    if(x == 0){
        return 1;
    }
    while(x > 0){
        ans = (ans*x)%mod;
        x--;
    }
    return ans%mod;
}

//power a^b
lli power(lli a, lli b){
    lli ans = 1;
    while(b > 0){
        if(b%2 == 1){
            ans *= a;
            ans = ans;
        }
        b/=2;
        a*=a;
        a = a;
    }
    return ans;
}

//binary of a number
vector <lli> getbinary(lli x){
    vector <lli> bin(20000,0);
    lli iter = 0;
    while(x > 0){
        if(x%2 == 1){
            bin[iter] = 1;
        }
        else{
            bin[iter] = 0;
        }
        iter++;
        x/=2;
    }
    return bin;
}
int main(){
    FASTER;
    lli n, m, k, i, j, l;
    TI(n, m, k);
    char c, d[n][m][k+1];
    lli a[n][m], b[n][m][k+1];
    F(i, 0, n){
        F(j, 0, m){
            SI(c);
            a[i][j]=c-'0';
            F(l, 0, k+1){
                b[i][j][l]=-1;
                d[i][j][l]='R';
            }
        }
    }
    F(i, 0, m){
        b[n-1][i][a[n-1][i]%(k+1)]=a[n-1][i];
    }
    for(i=n-2;i>=0;i--){
        F(j, 0, m){
            F(l, 0, k+1){
                if(j!=0 && j!=m-1){
                    if(b[i+1][j-1][l]>b[i+1][j+1][l]){
                        b[i][j][(l+a[i][j])%(k+1)]=b[i+1][j-1][l]+a[i][j];
                        d[i][j][(l+a[i][j])%(k+1)]='R';
                    }
                    else{
                        b[i][j][(l+a[i][j])%(k+1)]=b[i+1][j+1][l]+a[i][j];
                        d[i][j][(l+a[i][j])%(k+1)]='L';
                    }
                }
                else if(j==0){
                    b[i][j][(l+a[i][j])%(k+1)]=b[i+1][j+1][l]+a[i][j];
                    d[i][j][(l+a[i][j])%(k+1)]='L';
                }
                else{
                    b[i][j][(l+a[i][j])%(k+1)]=b[i+1][j-1][l]+a[i][j];
                    d[i][j][(l+a[i][j])%(k+1)]='R';
                }
            }
            /*if(j!=0){
                F(l, 0, k+1){
                    if(b[i+1][j-1][l]!=-1){
                        if(b[i+1][j-1][l]+a[i][j]>=b[i][j][(b[i+1][j-1][l]+a[i][j])%(k+1)]){
                            b[i][j][(b[i+1][j-1][l]+a[i][j])%(k+1)]=b[i+1][j-1][l]+a[i][j];
                            d[i][j][(b[i+1][j-1][l]+a[i][j])%(k+1)]='R';
                        }
                        else{
                            d[i][j][(b[i+1][j-1][l]+a[i][j])%(k+1)]='L';
                        }
                    }
                }
            }
            if(j!=m-1){
                F(l, 0, k+1){
                    if(b[i+1][j+1][l]!=-1){
                        if(b[i+1][j+1][l]+a[i][j]>=b[i][j][(b[i+1][j+1][l]+a[i][j])%(k+1)]){
                            b[i][j][(b[i+1][j+1][l]+a[i][j])%(k+1)]=b[i+1][j+1][l]+a[i][j];
                            d[i][j][(b[i+1][j+1][l]+a[i][j])%(k+1)]='L';
                        }
                        else{
                            d[i][j][(b[i+1][j+1][l]+a[i][j])%(k+1)]='R';
                        }
                    }
                }
            }*/
        }
    }
    l=-1;
    j=0;
    F(i, 0, m){
        if(b[0][i][0]>l){
            l=b[0][i][0];
            j=i;
        }
    }
    SO(l);
    if(l!=-1){
        vector<char> e;
        l=0;
        F(i, 0, n-1){
            e.pb(d[i][j][l]);
            lli l1=l;
            l-=a[i][j];
            l%=(k+1);
            if(d[i][j][l1]=='R' && i!=n-1){
                j--;
            }
            else if(i!=n-1){
                j++;
            }
        }
        SO(j+1);
        for(i=e.size()-1;i>=0;i--)
            cout<<e.at(i);
    }
}


#include <bits/stdc++.h>

/// STILL TOP 1?

using namespace std;

typedef long long nis;

const int N = (int) 1e2 + 7;
const int INF = (int) 1e9 + 7;
const int P = (int) 9e2 + 7;

bool dp[N][N][P];
int p[N][N][P];
int f[N][N];

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  k++;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char x;
      cin >> x;
      f[i][j] = x - '0';
    }
  }
  for (int j = 1; j <= m; j++)
    dp[0][j][0] = true;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int aim = f[i][j]; aim < P; aim++) {
        int sx = i - 1, sy = j - 1, fx = i - 1, fy = j + 1;
        if (sy > 0 && dp[sx][sy][aim - f[i][j]]) {
          dp[i][j][aim] = true;
          p[i][j][aim] = sy;
        }
        if (fy <= m && dp[fx][fy][aim - f[i][j]]) {
          dp[i][j][aim] = true;
          p[i][j][aim] = fy;
        }
      }
    }
  }
  int ans = -1, sj = 0;
  for (int j = 1; j <= m; j++) {
    for (int aim = k; aim < P; aim += k) {
      if (dp[n][j][aim] && aim > ans) {
        ans = aim;
        sj = j;
      }
    }
  }
  if (ans == -1)
    return (cout << ans, 0);
  cout << ans << '\n' << sj << '\n';
  vector<char> seq;
  int x = n, val = ans;
  while (x > 1) {
    int prev = p[x][sj][val];
    if (prev < sj)
      seq.push_back('R');
    else
      seq.push_back('L');
    val -= f[x][sj], x--, sj = prev;
  }
  reverse(seq.begin(), seq.end());
  for (auto x : seq)
    cout << x;
  return 0;
}


#include <bits/stdc++.h>

/// STILL TOP 1?

using namespace std;

typedef long long nis;

const int N = (int) 1e2 + 7;
const int INF = (int) 1e9 + 7;
const int P = (int) 9e2 + 7;

bool dp[N][N][P];
int p[N][N][P];
int f[N][N];

int main() {
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      for (int k = 0; k < P; k++)
        dp[i][j][k] = false;
  int n, m, k;
  cin >> n >> m >> k;
  k++;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char x;
      cin >> x;
      f[i][j] = x - '0';
    }
  }
  for (int j = 1; j <= m; j++)
    dp[0][j][0] = true;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int aim = f[i][j]; aim < P; aim++) {
        int sx = i - 1, sy = j - 1, fx = i - 1, fy = j + 1;
        if (dp[sx][sy][aim - f[i][j]]) {
          dp[i][j][aim] = true;
          p[i][j][aim] = sy;
        }
        if (dp[fx][fy][aim - f[i][j]]) {
          dp[i][j][aim] = true;
          p[i][j][aim] = fy;
        }
      }
    }
  }
  int ans = -1, sj = 0;
  for (int j = 1; j <= m; j++) {
    for (int aim = k; aim < P; aim += k) {
      if (dp[n][j][aim] && aim > ans) {
        ans = aim;
        sj = j;
      }
    }
  }
  if (ans == -1)
    return (cout << ans, 0);
  cout << ans << '\n' << sj << '\n';
  vector<char> seq;
  int x = n, val = ans;
  while (x > 1) {
    int prev = p[x][sj][val];
    if (prev < sj)
      seq.push_back('R');
    else
      seq.push_back('L');
    val -= f[x][sj], x--, sj = prev;
  }
  reverse(seq.begin(), seq.end());
  for (auto x : seq)
    cout << x;
  return 0;
}


#include <bits/stdc++.h>

/// STILL TOP 1?

using namespace std;

typedef long long nis;

const int N = (int) 1e2 + 7;
const int INF = (int) 1e9 + 7;
const int P = (int) 9e2 + 7;

bool dp[N][N][P];
int p[N][N][P];
int f[N][N];

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  k++;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char x;
      cin >> x;
      f[i][j] = x - '0';
    }
  }
  for (int j = 1; j <= m; j++)
    dp[0][j][0] = true;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int aim = f[i][j]; aim < P; aim++) {
        int sx = i - 1, sy = j - 1, fx = i - 1, fy = j + 1;
        if (dp[sx][sy][aim - f[i][j]]) {
          dp[i][j][aim] = true;
          p[i][j][aim] = sy;
        }
        if (dp[fx][fy][aim - f[i][j]]) {
          dp[i][j][aim] = true;
          p[i][j][aim] = fy;
        }
      }
    }
  }
  int ans = -1, sj = 0;
  for (int j = 1; j <= m; j++) {
    for (int aim = k; aim < P; aim += k) {
      if (dp[n][j][aim] && aim > ans) {
        ans = aim;
        sj = j;
      }
    }
  }
  if (ans == -1)
    return (cout << ans, 0);
  cout << ans << '\n' << sj << '\n';
  vector<char> seq;
  int x = n, val = ans;
  while (x > 1) {
    int prev = p[x][sj][val];
    if (prev < sj)
      seq.push_back('R');
    else
      seq.push_back('L');
    val -= f[x][sj], x--, sj = prev;
  }
  reverse(seq.begin(), seq.end());
  for (auto x : seq)
    cout << x;
  return 0;
}


#include <bits/stdc++.h>

/// STILL TOP 1?

using namespace std;

typedef long long nis;

const int N = (int) 1e2 + 7;
const int INF = (int) 1e9 + 7;
const int P = (int) 9e2 + 7;

bool dp[N][N][P];
int p[N][N][P];
int f[N][N];

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  k++;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char x;
      cin >> x;
      f[i][j] = x - '0';
    }
  }
  for (int j = 1; j <= m; j++)
    dp[0][j][0] = true;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int aim = f[i][j]; aim < P; aim++) {
        int sx = i - 1, sy = j - 1, fx = i - 1, fy = j + 1;
        if (sy > 0 && dp[sx][sy][aim - f[i][j]]) {
          dp[i][j][aim] = true;
          p[i][j][aim] = sy;
        }
        if (fy <= m && dp[fx][fy][aim - f[i][j]]) {
          dp[i][j][aim] = true;
          p[i][j][aim] = fy;
        }
      }
    }
  }
  int ans = -1, sj = 0;
  for (int j = 1; j <= m; j++) {
    for (int aim = 0; aim < P; aim += k) {
      if (dp[n][j][aim] && aim > ans) {
        ans = aim;
        sj = j;
      }
    }
  }
  if (ans == -1)
    return (cout << ans, 0);
  cout << ans << '\n' << sj << '\n';
  vector<char> seq;
  int x = n, val = ans;
  while (x > 1) {
    int prev = p[x][sj][val];
    if (prev < sj)
      seq.push_back('L');
    else
      seq.push_back('R');
    val -= f[x][sj], x--, sj = prev;
  }
  for (auto x : seq)
    cout << x;
  return 0;
}


#include <bits/stdc++.h>

/// STILL TOP 1?

using namespace std;

typedef long long nis;

const int N = (int) 1e2 + 7;
const int INF = (int) 1e9 + 7;
const int P = (int) 9e2 + 7;

bool dp[N][N][P];
int p[N][N][P];
int f[N][N];

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  k++;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char x;
      cin >> x;
      f[i][j] = x - '0';
    }
  }
  for (int j = 1; j <= m; j++)
    dp[0][j][0] = true;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int aim = f[i][j]; aim < P; aim++) {
        int sx = i - 1, sy = j - 1, fx = i - 1, fy = j + 1;
        if (sy > 0 && dp[sx][sy][aim - f[i][j]]) {
          dp[i][j][aim] = true;
          p[i][j][aim] = sy;
        }
        if (fy <= m && dp[fx][fy][aim - f[i][j]]) {
          dp[i][j][aim] = true;
          p[i][j][aim] = fy;
        }
      }
    }
  }
  int ans = -1, sj = 0;
  for (int j = 1; j <= m; j++) {
    for (int aim = k; aim < P; aim += k) {
      if (dp[n][j][aim] && aim > ans) {
        ans = aim;
        sj = j;
      }
    }
  }
  if (ans == -1)
    return (cout << ans, 0);
  cout << ans << '\n' << sj << '\n';
  vector<char> seq;
  int x = n, val = ans;
  while (x > 1) {
    int prev = p[x][sj][val];
    if (prev < sj)
      seq.push_back('L');
    else
      seq.push_back('R');
    val -= f[x][sj], x--, sj = prev;
  }
  for (auto x : seq)
    cout << x;
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long int ar[102][102],n,m,k;
long long int dp[102][102][11],visit[102][102][11];
char path[102][102];
long long int rec(long long int i,long long int j,long long int summod)
{
    //cout<<i<<" "<<j<<"\n";
    if(i<1 || i>n || j<1 || j>m)
        return -100000000000;
    if(i==1)
    {
        if(((summod+ar[i][j])%(k+1))==0)
        {
            //cout<<ar[i][j]<<"\n";
            return ar[i][j];
        }
        else
            return -10000000000;
    }
    if(visit[i][j][summod]!=0)
        return dp[i][j][summod];
    long long int a=ar[i][j]+rec(i-1,j-1,(summod+ar[i][j])%(k+1));
    if(dp[i][j][summod]<a)
    {
        dp[i][j][summod]=a;
        path[i][j]='L';
    }
    long long int b=ar[i][j]+rec(i-1,j+1,(summod+ar[i][j])%(k+1));
    if(dp[i][j][summod]<b)
    {
        dp[i][j][summod]=b;
        path[i][j]='R';
    }
    visit[i][j][summod]=1;
    if(dp[i][j][summod]!=-1)
        return dp[i][j][summod];
    else
        return -10000000000;
}
int main()
{
    long long int i,j,x,max1=-1,b,z;
    char ch;
    cin>>n>>m>>k;
    for(i=1;i<=n;i++)
    {
        cin>>x;
        for(j=m;j>=1;j--)
        {
            ar[i][j]=x%10;
            x=x/10;
        }
    }
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=m;j++)
        {
            for(z=0;z<=10;z++)
            {
                dp[i][j][z]=-1;
            }
        }
    }
    for(i=1;i<=m;i++)
    {
        long long int a=rec(n,i,0);
        //cout<<"a"<<" "<<a<<"\n";
        if(a>max1)
        {
            max1=a;
            b=i;
        }
    }
    if(max1==-1)
        cout<<-1;
    else
    {
        i=n;
        j=b;
        cout<<max1<<"\n";
        cout<<b<<"\n";
        while(i>1)
        {
            ch=path[i][j];
            if(ch=='L')
            {
                i=i-1;
                j=j-1;
            }
            if(ch=='R')
            {
                i=i-1;
                j=j+1;
            }
            if(j<1 || j>m)
            {
                if(ch=='L')
                {
                    j=j+2;
                    ch='R';
                }
                else
                {
                    j=j-2;
                    ch='L';
                }
            }
            cout<<ch;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
long long int ar[102][102],n,m,k;
long long int dp[102][102][11],visit[102][102][11];
char path[102][102][11];
long long int rec(long long int i,long long int j,long long int summod)
{
    //cout<<i<<" "<<j<<"\n";
    if(i<1 || i>n || j<1 || j>m)
        return -100000000000;
    if(i==1)
    {
        if(((summod+ar[i][j])%(k+1))==0)
        {
            //cout<<ar[i][j]<<"\n";
            return ar[i][j];
        }
        else
            return -10000000000;
    }
    if(visit[i][j][summod]!=0)
        return dp[i][j][summod];
    long long int a=ar[i][j]+rec(i-1,j-1,(summod+ar[i][j])%(k+1));
    if(dp[i][j][summod]<a)
    {
        dp[i][j][summod]=a;
        path[i][j][summod]='L';
    }
    long long int b=ar[i][j]+rec(i-1,j+1,(summod+ar[i][j])%(k+1));
    if(dp[i][j][summod]<b)
    {
        dp[i][j][summod]=b;
        path[i][j][summod]='R';
    }
    visit[i][j][summod]=1;
    if(dp[i][j][summod]!=-1)
        return dp[i][j][summod];
    else
        return -10000000000;
}
int main()
{
    long long int i,j,x,max1=-1,b,z,sum=0;
    char ch,arr[102][102];
    cin>>n>>m>>k;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            cin>>arr[i][j];
            ar[i][j]=(int)arr[i][j]-48;
            //cout<<ar[i][j];
        }
    }
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=m;j++)
        {
            for(z=0;z<=10;z++)
            {
                dp[i][j][z]=-1;
            }
        }
    }
    for(i=1;i<=m;i++)
    {
        long long int a=rec(n,i,0);
        //cout<<"a"<<" "<<a<<"\n";
        if(a>max1)
        {
            max1=a;
            b=i;
        }
    }
    if(max1==-1)
        cout<<-1;
    else
    {
        i=n;
        j=b;
        cout<<max1<<"\n";
        cout<<b<<"\n";
        while(i>1)
        {
            ch=path[i][j][sum];
            sum=((sum+ar[i][j])%(k+1));
            if(ch=='L')
            {
                i=i-1;
                j=j-1;
            }
            if(ch=='R')
            {
                i=i-1;
                j=j+1;
            }
            if(j<1 || j>m)
            {
                if(ch=='L')
                {
                    j=j+2;
                    ch='R';
                }
                else
                {
                    j=j-2;
                    ch='L';
                }
            }
            cout<<ch;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
long long int ar[102][102],n,m,k;
long long int dp[102][102][11],visit[102][102][11];
char path[102][102][11];
long long int rec(long long int i,long long int j,long long int summod)
{
    //cout<<i<<" "<<j<<"\n";
    if(i<1 || i>n || j<1 || j>m)
        return -100000000000;
    if(i==1)
    {
        if(((summod+ar[i][j])%(k+1))==0)
        {
            //cout<<"hello"<<"\n";
            return ar[i][j];
        }
        else
            return -10000000000;
    }
    if(visit[i][j][summod]!=0)
    {
        if(dp[i][j][summod]==-1)
            return -10000000000;
        else
            return dp[i][j][summod];
    }
    long long int a=ar[i][j]+rec(i-1,j-1,(summod+ar[i][j])%(k+1));
    if(dp[i][j][summod]<a)
    {
        //cout<<"a"<<" "<<i<<" "<<a<<" "<<j<<"\n";
        dp[i][j][summod]=a;
        path[i][j][summod]='L';
    }
    long long int b=ar[i][j]+rec(i-1,j+1,(summod+ar[i][j])%(k+1));
    if(dp[i][j][summod]<b)
    {
        //cout<<"b";
        dp[i][j][summod]=b;
        path[i][j][summod]='R';
    }
    visit[i][j][summod]=1;
    if(dp[i][j][summod]!=-1)
    {
        //cout<<i<<" "<<j<<"\n";
        return dp[i][j][summod];
    }
    else
        return -10000000000;
}
int main()
{
    long long int i,j,x,max1=-1,b,z,sum=0;
    char ch,arr[102][102];
    cin>>n>>m>>k;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            cin>>arr[i][j];
            ar[i][j]=(int)arr[i][j]-48;
            //cout<<ar[i][j];
        }
    }
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=m;j++)
        {
            for(z=0;z<=10;z++)
            {
                dp[i][j][z]=-1;
            }
        }
    }
    for(i=1;i<=m;i++)
    {
        long long int a=rec(n,i,0);
        //cout<<"a"<<" "<<a<<"\n";
        if(a>max1)
        {
            max1=a;
            b=i;
        }
    }
    if(max1==-1)
        cout<<-1;
    else
    {
        i=n;
        j=b;
        cout<<max1<<"\n";
        cout<<b<<"\n";
        while(i>1)
        {
            ch=path[i][j][sum];
            sum=((sum+ar[i][j])%(k+1));
            if(ch=='L')
            {
                i=i-1;
                j=j-1;
            }
            if(ch=='R')
            {
                i=i-1;
                j=j+1;
            }
            if(j<1 || j>m)
            {
                if(ch=='L')
                {
                    j=j+2;
                    ch='R';
                }
                else
                {
                    j=j-2;
                    ch='L';
                }
            }
            cout<<ch;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
long long int ar[102][102],n,m,k;
long long int dp[102][102][11],visit[102][102][11];
char path[102][102][11];
long long int rec(long long int i,long long int j,long long int summod)
{
    //cout<<i<<" "<<j<<"\n";
    if(i<1 || i>n || j<1 || j>m)
        return -100000000000;
    if(i==1)
    {
        if(((summod+ar[i][j])%(k+1))==0)
        {
            //cout<<ar[i][j]<<"\n";
            return ar[i][j];
        }
        else
            return -10000000000;
    }
    if(visit[i][j][summod]!=0)
        return dp[i][j][summod];
    long long int a=ar[i][j]+rec(i-1,j-1,(summod+ar[i][j])%(k+1));
    if(dp[i][j][summod]<a)
    {
        dp[i][j][summod]=a;
        path[i][j][summod]='L';
    }
    long long int b=ar[i][j]+rec(i-1,j+1,(summod+ar[i][j])%(k+1));
    if(dp[i][j][summod]<b)
    {
        dp[i][j][summod]=b;
        path[i][j][summod]='R';
    }
    visit[i][j][summod]=1;
    if(dp[i][j][summod]!=-1)
        return dp[i][j][summod];
    else
        return -10000000000;
}
int main()
{
    long long int i,j,x,max1=-1,b,z,sum=0;
    char ch;
    cin>>n>>m>>k;
    for(i=1;i<=n;i++)
    {
        cin>>x;
        for(j=m;j>=1;j--)
        {
            ar[i][j]=x%10;
            x=x/10;
        }
    }
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=m;j++)
        {
            for(z=0;z<=10;z++)
            {
                dp[i][j][z]=-1;
            }
        }
    }
    for(i=1;i<=m;i++)
    {
        long long int a=rec(n,i,0);
        //cout<<"a"<<" "<<a<<"\n";
        if(a>max1)
        {
            max1=a;
            b=i;
        }
    }
    if(max1==-1)
        cout<<-1;
    else
    {
        i=n;
        j=b;
        cout<<max1<<"\n";
        cout<<b<<"\n";
        while(i>1)
        {
            ch=path[i][j][sum];
            sum=((sum+ar[i][j])%(k+1));
            if(ch=='L')
            {
                i=i-1;
                j=j-1;
            }
            if(ch=='R')
            {
                i=i-1;
                j=j+1;
            }
            if(j<1 || j>m)
            {
                if(ch=='L')
                {
                    j=j+2;
                    ch='R';
                }
                else
                {
                    j=j-2;
                    ch='L';
                }
            }
            cout<<ch;
        }
    }
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define MOD2 1494318097
#define SEED 131
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

#define MAXN 105
#define MAXK 15

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unordered_map<int,int> umii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

mt19937 g1(time(0));

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ll randlong(ll a,ll b){return uniform_int_distribution<long long>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int num_rows,num_cols,K,dp[MAXN][MAXN][MAXK];
int board[MAXN][MAXN],res;
char par[MAXN][MAXN][MAXK];
stack<char> s;

int main(){
	scanf("%d %d %d",&num_rows,&num_cols,&K); K++;
	for(int i=1; i<=num_rows; i++){
		for(int k=1; k<=num_cols; k++){
			char c; scanf(" %c",&c);
			board[i][k] = c-'0';
		}
	}
	memset(dp,-0x3f,sizeof dp);
	for(int i=1; i<=num_cols; i++)
		dp[num_rows][i][board[num_rows][i]%K] = board[num_rows][i];
	for(int i=num_rows-1; i>=1; i--){
		for(int k=1; k<=num_cols; k++){
			for(int m=0; m<K; m++){
				int want = (m-(board[i][k]%K)+K)%K;
				if(dp[i+1][k-1][want]+board[i][k] > dp[i][k][m]){
					dp[i][k][m] = dp[i+1][k-1][want]+board[i][k];
					par[i][k][m] = 'R';
				}
				if(dp[i+1][k+1][want]+board[i][k] > dp[i][k][m]){
					dp[i][k][m] = dp[i+1][k+1][want]+board[i][k];
					par[i][k][m] = 'L';
				}
			}
		}
	}
	for(int i=1; i<=num_cols; i++)
		if(dp[1][i][0] > dp[1][res][0])
			res = i;
	if(dp[1][res][0] < 0) return 0*printf("-1\n");
	printf("%d\n",dp[1][res][0]);
	int col = res, mod = 0;
	for(int i=1; i<num_rows; i++){
		int nxt = (mod-(board[i][col]%K)+K)%K;
		s.push(par[i][col][mod]);
		if(par[i][col][mod] == 'L') col++;
		else col--;
		mod = nxt;
	}
	printf("%d\n",(int)s.size());
	while(s.size()){
		printf("%c",s.top());
		s.pop();
	}
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define MOD2 1494318097
#define SEED 131
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

#define MAXN 105
#define MAXK 15

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unordered_map<int,int> umii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

mt19937 g1(time(0));

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ll randlong(ll a,ll b){return uniform_int_distribution<long long>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int num_rows,num_cols,K,dp[MAXN][MAXN][MAXK];
int board[MAXN][MAXN],res;
char par[MAXN][MAXN][MAXK];
stack<char> s;

int main(){
	scanf("%d %d %d",&num_rows,&num_cols,&K); K++;
	for(int i=1; i<=num_rows; i++){
		for(int k=1; k<=num_cols; k++){
			char c; scanf(" %c",&c);
			board[i][k] = c-'0';
		}
	}
	memset(dp,-0x3f,sizeof dp);
	for(int i=1; i<=num_cols; i++)
		dp[num_rows][i][board[num_rows][i]%K] = board[num_rows][i];
	for(int i=num_rows-1; i>=1; i--){
		for(int k=1; k<=num_cols; k++){
			for(int m=0; m<K; m++){
				int want = (m-(board[i][k]%K)+K)%K;
				if(dp[i+1][k-1][want]+board[i][k] > dp[i][k][m]){
					dp[i][k][m] = dp[i+1][k-1][want]+board[i][k];
					par[i][k][m] = 'R';
				}
				if(dp[i+1][k+1][want]+board[i][k] > dp[i][k][m]){
					dp[i][k][m] = dp[i+1][k+1][want]+board[i][k];
					par[i][k][m] = 'L';
				}
			}
		}
	}
	for(int i=1; i<=num_cols; i++)
		if(dp[1][i][0] > dp[1][res][0])
			res = i;
	if(dp[1][res][0] < 0) return 0*printf("-1\n");
	printf("%d\n",dp[1][res][0]);
	int col = res, mod = 0;
	for(int i=1; i<num_rows; i++){
		int nxt = (mod-(board[i][col]%K)+K)%K;
		s.push(par[i][col][mod]);
		if(par[i][col][mod] == 'L') col++;
		else col--;
		mod = nxt;
	}
	printf("%d\n",col);
	while(s.size()){
		printf("%c",s.top());
		s.pop();
	}
}


#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <iostream>
#include <functional>
#include <string>
using namespace std;

#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define rep(i,n,s) for(int i=s;i<n;i++)
typedef long long ll;

int dp[110][110][12],n,m,k;
short a[110][110];
bool ch[110][110][12];
string s[110];

bool check(int x,int y)
{
	return (0<=x && x<=n-1 && 0<=y && y<=n-1);
}

int F(int a,int b)
{
	return (a%k-b%k+k)%k;
}

int main()
{
	ios_base::sync_with_stdio(0);
	int ans=-1,ans2;
	cin>>n>>m>>k;
	k++;
	rep(i,n,0)
		rep(j,n,0)
			fill(dp[i][j],dp[i][j]+11,-1);
	rep(i,n,0)
	{
		cin>>s[i];
		rep(j,n,0)
			a[i][j]=s[i][j]-'0';
	}
	rep(i,n,0)
		dp[0][i][a[0][i]%k]=a[0][i];
	rep(i,n,1)
		rep(j,n,0)
			rep(h,k,0)
			{
				int o=F(h,a[i][j]);
				if(check(i-1,j-1) && dp[i-1][j-1][o]!=-1)
					if(dp[i-1][j-1][o]+a[i][j]>dp[i][j][h])
						dp[i][j][h]=dp[i-1][j-1][o]+a[i][j];
				if(check(i-1,j+1) && dp[i-1][j+1][o]!=-1)
					if(dp[i-1][j+1][o]+a[i][j]>dp[i][j][h])
					{
						dp[i][j][h]=dp[i-1][j+1][o]+a[i][j];
						ch[i][j][h]=1;
					}
				//cout<<i<<" "<<j<<" "<<h<<" "<<dp[i][j][h]<<endl;
			}
	rep(i,n,0)
		if(dp[n-1][i][0]>ans)
			ans=dp[n-1][i][0],ans2=i;
	if(ans==-1)
	{
		cout<<-1<<endl;
		return 0;
	}
	cout<<ans<<endl<<ans2+1<<endl;
	int h=0;
	while(--n)
	{
		cout<<(ch[n][ans2][h]?'R':'L');
		int t=h;
		h=F(h,a[n][ans2]);
		ans2+=(ch[n][ans2][t]?1:-1);
	}
	cout<<endl;
}


#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <iostream>
#include <functional>
#include <string>
using namespace std;

#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define rep(i,n,s) for(int i=s;i<n;i++)
typedef long long ll;

int dp[110][110][12],n,m,k;
short a[110][110];
bool ch[110][110][12];
string s[110];

bool check(int x,int y)
{
	return (0<=x && x<=n-1 && 0<=y && y<=m-1);
}

int F(int a,int b)
{
	return (a%k-b%k+k)%k;
}

int main()
{
	ios_base::sync_with_stdio(0);
	int ans=-1,ans2;
	cin>>n>>m>>k;
	k++;
	rep(i,n,0)
		rep(j,m,0)
			fill(dp[i][j],dp[i][j]+11,-1);
	rep(i,n,0)
	{
		cin>>s[i];
		rep(j,m,0)
			a[i][j]=s[i][j]-'0';
	}
	rep(i,m,0)
		dp[0][i][a[0][i]%k]=a[0][i];
	rep(i,n,1)
		rep(j,m,0)
			rep(h,k,0)
			{
				int o=F(h,a[i][j]);
				if(check(i-1,j-1) && dp[i-1][j-1][o]!=-1)
					if(dp[i-1][j-1][o]+a[i][j]>dp[i][j][h])
						dp[i][j][h]=dp[i-1][j-1][o]+a[i][j];
				if(check(i-1,j+1) && dp[i-1][j+1][o]!=-1)
					if(dp[i-1][j+1][o]+a[i][j]>dp[i][j][h])
					{
						dp[i][j][h]=dp[i-1][j+1][o]+a[i][j];
						ch[i][j][h]=1;
					}
				//cout<<i<<" "<<j<<" "<<h<<" "<<dp[i][j][h]<<endl;
			}
	rep(i,m,0)
		if(dp[n-1][i][0]>ans)
			ans=dp[n-1][i][0],ans2=i;
	if(ans==-1)
	{
		cout<<-1<<endl;
		return 0;
	}
	cout<<ans<<endl<<ans2+1<<endl;
	int h=0;
	while(--n)
	{
		cout<<(ch[n][ans2][h]?'R':'L');
		int t=h;
		h=F(h,a[n][ans2]);
		ans2+=(ch[n][ans2][t]?1:-1);
	}
	cout<<endl;
}


#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <iostream>
#include <functional>
#include <string>
using namespace std;

#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define rep(i,n,s) for(int i=s;i<n;i++)
typedef long long ll;

int dp[110][110][12],n,m,k;
short a[110][110];
bool ch[110][110][12];
string s[110];

bool check(int x,int y)
{
	return (0<=x && x<=n-1 && 0<=y && y<=n-1);
}

int F(int a,int b)
{
	return (a%k-b%k+k)%k;
}

int main()
{
	ios_base::sync_with_stdio(0);
	int ans=-1,ans2;
	rep(i,n,0)
		rep(j,0,n)
			fill(dp[i][j],dp[i][j]+11,-1);
	cin>>n>>m>>k;
	k++;
	rep(i,n,0)
	{
		cin>>s[i];
		rep(j,n,0)
			a[i][j]=s[i][j]-'0';
	}
	rep(i,n,0)
		dp[0][i][a[0][i]%k]=a[0][i];
	rep(i,n,1)
		rep(j,n,0)
			rep(h,k,0)
			{
				int o=F(h,a[i][j]);
				if(check(i-1,j-1) && dp[i-1][j-1][o]!=-1)
					if(dp[i-1][j-1][o]+a[i][j]>dp[i][j][h])
						dp[i][j][h]=dp[i-1][j-1][o]+a[i][j];
				if(check(i-1,j+1) && dp[i-1][j+1][o]!=-1)
					if(dp[i-1][j+1][o]+a[i][j]>dp[i][j][h])
					{
						dp[i][j][h]=dp[i-1][j+1][o]+a[i][j];
						ch[i][j][h]=1;
					}
				//cout<<i<<" "<<j<<" "<<h<<" "<<dp[i][j][h]<<endl;
			}
	rep(i,n,0)
		if(dp[n-1][i][0]>ans)
			ans=dp[n-1][i][0],ans2=i;
	if(ans==-1)
	{
		cout<<-1<<endl;
		return 0;
	}
	cout<<ans<<endl<<ans2+1<<endl;
	int h=0;
	while(--n)
	{
		cout<<(ch[n][ans2][h]?'R':'L');
		int t=h;
		h=F(h,a[n][ans2]);
		ans2+=(ch[n][ans2][t]?1:-1);
	}
	cout<<endl;
}


#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <iostream>
#include <functional>
#include <string>
using namespace std;

#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define rep(i,n,s) for(int i=s;i<n;i++)
typedef long long ll;

int dp[110][110][12],n,m,k;
short a[110][110];
bool ch[110][110][12];
string s[110];

bool check(int x,int y)
{
	return (0<=x && x<=n-1 && 0<=y && y<=n-1);
}

int F(int a,int b)
{
	return (a%k-b%k+k)%k;
}

int main()
{
	ios_base::sync_with_stdio(0);
	int ans=-1,ans2;
	memset(dp,-1,sizeof(dp));
	cin>>n>>m>>k;
	k++;
	rep(i,n,0)
	{
		cin>>s[i];
		rep(j,n,0)
			a[i][j]=s[i][j]-'0';
	}
	rep(i,n,0)
		dp[0][i][a[0][i]%k]=a[0][i];
	rep(i,n,1)
		rep(j,n,0)
			rep(h,k,0)
			{
				int o=F(h,a[i][j]);
				if(check(i-1,j-1) && dp[i-1][j-1][o]!=-1)
					if(dp[i-1][j-1][o]+a[i][j]>dp[i][j][h])
						dp[i][j][h]=dp[i-1][j-1][o]+a[i][j];
				if(check(i-1,j+1) && dp[i-1][j+1][o]!=-1)
					if(dp[i-1][j+1][o]+a[i][j]>dp[i][j][h])
					{
						dp[i][j][h]=dp[i-1][j+1][o]+a[i][j];
						ch[i][j][h]=1;
					}
				//cout<<i<<" "<<j<<" "<<h<<" "<<dp[i][j][h]<<endl;
			}
	rep(i,n,0)
		if(dp[n-1][i][0]>ans)
			ans=dp[n-1][i][0],ans2=i;
	if(ans==-1)
	{
		cout<<-1<<endl;
		return 0;
	}
	cout<<ans<<endl<<ans2+1<<endl;
	int h=0;
	while(--n)
	{
		cout<<(ch[n][ans2][h]?'R':'L');
		int t=h;
		h=F(h,a[n][ans2]);
		ans2+=(ch[n][ans2][t]?1:-1);
	}
	cout<<endl;
}


#include<bits/stdc++.h>
using namespace std;

const int maxn = 105;

int dp[maxn][maxn][15];

char mat[maxn][maxn];

int go[maxn][maxn][15];

int main()
{
    int n,m,k;
    scanf("%d %d %d",&n,&m,&k);
    k++;
    for(int i = 0; i < n ; i++)
    {
        scanf("%s",mat[i]);
    }
    memset(dp,-1,sizeof(dp));
    for(int i = 0; i < m; i++)
    {
        dp[n-1][i][(mat[n-1][i] - '0') % k] = mat[n-1][i] - '0';
    }
    for(int i = n-1; i > 0; i--)
    {
        for(int j = 0; j < m; j++)
        {
            for(int l = 0; l < k; l++)
            {
                if(dp[i][j][l] == -1)
                    continue;
                if(j+1 < m)
                {
                    int val = dp[i][j][l] + (mat[i-1][j+1] - '0');
                    if(val > dp[i-1][j+1][val % k])
                    {
                        dp[i-1][j+1][val % k] = val;
                        go[i-1][j+1][val % k] = 'R';
                    }
                }
                if(j - 1 >= 0)
                {
                    int val = dp[i][j][l] + (mat[i-1][j-1] - '0');
                    if(val > dp[i-1][j-1][val % k])
                    {
                        dp[i-1][j-1][val % k] = val;
                        go[i-1][j-1][val % k] = 'L';
                    }
                }
            }
        }
    }
    int ans = 0;
    int pos = -1;
    for(int i = 1; i <= m; i++)
    {
        if( dp[0][i][0] > ans)
        {
            ans = dp[0][i][0];
            pos = i;
        }
    }

    if(pos == -1)
    {
        puts("-1");
        return 0;
    }

    printf("%d\n",ans);
    int i = 0;
    string res = "";
    int rem = 0;
    while(i < n-1)
    {
        res += go[i][pos][rem];
        if(go[i][pos][rem] == 'L')
        {
            rem -= mat[i][pos] - '0';
            while(rem < 0)
                rem += k;
            pos++;
        }
        else
        {
            rem -= mat[i][pos] - '0';
            while(rem < 0)
                rem += k;
            pos--;
        }
        i++;
    }

    printf("%d\n",pos + 1);
    reverse(res.begin(),res.end());
    printf("%s\n",res.c_str());

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

const int maxn = 105;

int dp[maxn][maxn];

char mat[maxn][maxn];

int go[maxn][maxn];

int main()
{
    int n,m,k;
    scanf("%d %d %d",&n,&m,&k);
    for(int i = 1; i <= n ; i++)
    {
        scanf("%s",mat[i]+1);
    }
    for(int i = n; i >= 1; i--)
    {
        for(int j = 1; j <= m; j++)
        {
            int val = dp[i][j] + (mat[i][j] - '0');
            if(val > dp[i-1][j+1])
            {
                dp[i-1][j+1] = val;
                go[i-1][j+1] = 'R';
            }

            if(val > dp[i-1][j-1])
            {
                dp[i-1][j-1] = val;
                go[i-1][j-1] = 'L';
            }
        }
    }
    int ans = 0;
    int pos = -1;
    for(int i = 1; i <= m; i++)
    {
        if( dp[0][i] > ans && dp[0][i] % (k+1) == 0 )
        {
            ans = dp[0][i];
            pos = i;
        }
    }

    if(pos == -1)
    {
        puts("-1");
        return 0;
    }

    cout << ans << endl;
    int i = 0;
    string res = "";
    while(i < n)
    {
        res += go[i][pos];
        if(go[i][pos] == 'L')
            pos++;
        else
            pos--;
        i++;
    }

    printf("%d\n",pos);
    reverse(res.begin(),res.end());
    res.pop_back();
    printf("%s\n",res.c_str());

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

const int maxn = 105;

int dp[maxn][maxn][15];

char mat[maxn][maxn];

int go[maxn][maxn][15];

int main()
{
    int n,m,k;
    scanf("%d %d %d",&n,&m,&k);
    k++;
    for(int i = 0; i < n ; i++)
    {
        scanf("%s",mat[i]);
    }
    memset(dp,-1,sizeof(dp));
    for(int i = 0; i < m; i++)
    {
        dp[n-1][i][(mat[n-1][i] - '0') % k] = mat[n-1][i] - '0';
    }
    for(int i = n-1; i > 0; i--)
    {
        for(int j = 0; j < m; j++)
        {
            for(int l = 0; l < k; l++)
            {
                if(dp[i][j][l] == -1)
                    continue;
                if(j+1 < m)
                {
                    int val = dp[i][j][l] + (mat[i-1][j+1] - '0');
                    if(val > dp[i-1][j+1][val % k])
                    {
                        dp[i-1][j+1][val % k] = val;
                        go[i-1][j+1][val % k] = 'R';
                    }
                }
                if(j-1 > 0)
                {
                    int val = dp[i][j][l] + (mat[i-1][j-1] - '0');
                    if(val > dp[i-1][j-1][val % k])
                    {
                        dp[i-1][j-1][val % k] = val;
                        go[i-1][j-1][val % k] = 'L';
                    }
                }
            }
        }
    }
    int ans = 0;
    int pos = -1;
    for(int i = 1; i <= m; i++)
    {
        if( dp[0][i][0] > ans)
        {
            ans = dp[0][i][0];
            pos = i;
        }
    }

    if(pos == -1)
    {
        puts("-1");
        return 0;
    }

    cout << ans << endl;
    int i = 0;
    string res = "";
    int rem = 0;
    while(i < n-1)
    {
        res += go[i][pos][rem];
        if(go[i][pos][rem] == 'L')
        {
            rem -= mat[i][pos] - '0';
            while(rem < 0)
                rem += k;
            pos++;
        }
        else
        {
            rem -= mat[i][pos] - '0';
            while(rem < 0)
                rem += k;
            pos--;
        }
        i++;
    }

    printf("%d\n",pos + 1);
    reverse(res.begin(),res.end());
    printf("%s\n",res.c_str());

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

const int maxn = 105;

int dp[maxn][maxn][15];

char mat[maxn][maxn];

int go[maxn][maxn][15];

int main()
{
    int n,m,k;
    scanf("%d %d %d",&n,&m,&k);
    k++;
    for(int i = 0; i < n ; i++)
    {
        scanf("%s",mat[i]);
    }
    memset(dp,-1,sizeof(dp));
    for(int i = 0; i < m; i++)
    {
        dp[n-1][i][(mat[n-1][i] - '0') % k] = mat[n-1][i] - '0';
    }
    for(int i = n-1; i > 0; i--)
    {
        for(int j = 0; j < m; j++)
        {
            for(int l = 0; l < k; l++)
            {
                if(dp[i][j][l] == -1)
                    continue;
                if(j+1 < m)
                {
                    int val = dp[i][j][l] + (mat[i-1][j+1] - '0');
                    if(val > dp[i-1][j+1][val % k])
                    {
                        dp[i-1][j+1][val % k] = val;
                        go[i-1][j+1][val % k] = 'R';
                    }
                }
                if(j - 1 >= 0)
                {
                    int val = dp[i][j][l] + (mat[i-1][j-1] - '0');
                    if(val > dp[i-1][j-1][val % k])
                    {
                        dp[i-1][j-1][val % k] = val;
                        go[i-1][j-1][val % k] = 'L';
                    }
                }
            }
        }
    }
    int ans = -1;
    int pos = -1;
    for(int i = 0; i < m; i++)
    {
        if( dp[0][i][0] > ans)
        {
            ans = dp[0][i][0];
            pos = i;
        }
    }

    if(pos == -1)
    {
        puts("-1");
        return 0;
    }

    printf("%d\n",ans);
    int i = 0;
    string res = "";
    int rem = 0;
    while(i < n-1)
    {
        res += go[i][pos][rem];
        if(go[i][pos][rem] == 'L')
        {
            rem -= mat[i][pos] - '0';
            while(rem < 0)
                rem += k;
            pos++;
        }
        else
        {
            rem -= mat[i][pos] - '0';
            while(rem < 0)
                rem += k;
            pos--;
        }
        i++;
    }

    printf("%d\n",pos + 1);
    reverse(res.begin(),res.end());
    printf("%s\n",res.c_str());

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

const int maxn = 105;

int dp[maxn][maxn][15];

char mat[maxn][maxn];

int go[maxn][maxn][15];

int main()
{
    int n,m,k;
    scanf("%d %d %d",&n,&m,&k);
    k++;
    for(int i = 0; i < n ; i++)
    {
        scanf("%s",mat[i]);
    }
    memset(dp,-1,sizeof(dp));
    for(int i = 0; i < m; i++)
    {
        dp[n-1][i][(mat[n-1][i] - '0') % k] = mat[n-1][i] - '0';
    }
    for(int i = n-1; i > 0; i--)
    {
        for(int j = 0; j < m; j++)
        {
            for(int l = 0; l < k; l++)
            {
                if(dp[i][j][l] == -1)
                    continue;
                if(j+1 < m)
                {
                    int val = dp[i][j][l] + (mat[i-1][j+1] - '0');
                    if(val > dp[i-1][j+1][val % k])
                    {
                        dp[i-1][j+1][val % k] = val;
                        go[i-1][j+1][val % k] = 'R';
                    }
                }
                if(j - 1 >= 0)
                {
                    int val = dp[i][j][l] + (mat[i-1][j-1] - '0');
                    if(val > dp[i-1][j-1][val % k])
                    {
                        dp[i-1][j-1][val % k] = val;
                        go[i-1][j-1][val % k] = 'L';
                    }
                }
            }
        }
    }
    int ans = 0;
    int pos = -1;
    for(int i = 0; i < m; i++)
    {
        if( dp[0][i][0] > ans)
        {
            ans = dp[0][i][0];
            pos = i;
        }
    }

    if(pos == -1)
    {
        puts("-1");
        return 0;
    }

    printf("%d\n",ans);
    int i = 0;
    string res = "";
    int rem = 0;
    while(i < n-1)
    {
        res += go[i][pos][rem];
        if(go[i][pos][rem] == 'L')
        {
            rem -= mat[i][pos] - '0';
            while(rem < 0)
                rem += k;
            pos++;
        }
        else
        {
            rem -= mat[i][pos] - '0';
            while(rem < 0)
                rem += k;
            pos--;
        }
        i++;
    }

    printf("%d\n",pos + 1);
    reverse(res.begin(),res.end());
    printf("%s\n",res.c_str());

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define in ({ll x=0;int n=0,c=getchar();for(;!isdigit(c);c=getchar()) n=c=='-';for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
#define inchar ({char c=getchar();while(c==' '||c=='\n') c=getchar();c;})

#define ll long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=b;a<=i;i--)
#define rr(x) " "<<#x<<'='<<x<<" "

#define bit(x,i) ((x>>(i-1))&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))
#define pow2(x) (1ll<<x)

#define mt make_tuple
#define pi pair<int,int>
#define x first
#define y second

#define VEC(i,a) for(auto&i:a)
#define pb push_back
#define allv(a) a.begin(),a.end()
#define endv(a) (int)a.size()-1
////////////////////////////////////////// NIRO
const int N=105;
int n,m,k;
int a[N][N];
struct dp
{
    int v=-1e9,o;
};
dp f[N][N][15];

void CAPNHAP(int x,int y,int X,int Y,int o)
{
    if(1<=x&&x<=n&&1<=y&&y<=n) {}else return;
    FOR(kk,0,k-1) if(f[X][Y][kk].v>=0)
    {
        int v=f[X][Y][kk].v+a[x][y];
        int vk=v%k;
        if(f[x][y][vk].v<v) f[x][y][vk].v=v,f[x][y][vk].o=o;
    }
}

int UPMOD(int x)
{
    x%=k;x+=k;
    return x%k;
}

void GO(int x,int y,int kk)
{
    int o=f[x][y][kk].o;
    if(x!=n)
    {
        int xx=x+1;
        int yy=o?y-1:y+1;
        int k2=UPMOD(kk-a[x][y]);
        GO(xx,yy,k2);
        cout<<"LR"[o];
    }
    else cout<<y<<"\n";

}
main()
{
    //freopen("nr.inp","r",stdin);
    n=in,m=in,k=in+1;
    FOR(i,1,n) FOR(j,1,m) a[i][j]=inchar-'0';

    FOR(j,1,m) f[n][j][a[n][j]%k].v=a[n][j];
    ROF(i,2,n) FOR(j,1,m)
    {
        CAPNHAP(i-1,j-1,i,j,0);
        CAPNHAP(i-1,j+1,i,j,1);
    }
    ll res=-1e9,ii,jj;
    FOR(j,1,m) if(res<f[1][j][0].v) res=f[1][j][0].v,ii=1,jj=j;

    if(res<0) cout<<"-1";
    else
    {
        cout<<res<<"\n";
        GO(ii,jj,0);
    }
}


#include<bits/stdc++.h>
using namespace std;

#define in ({ll x=0;int n=0,c=getchar();for(;!isdigit(c);c=getchar()) n=c=='-';for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
#define inchar ({char c=getchar();while(c==' '||c=='\n') c=getchar();c;})

#define ll long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=b;a<=i;i--)
#define rr(x) " "<<#x<<'='<<x<<" "

#define bit(x,i) ((x>>(i-1))&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))
#define pow2(x) (1ll<<x)

#define mt make_tuple
#define pi pair<int,int>
#define x first
#define y second

#define VEC(i,a) for(auto&i:a)
#define pb push_back
#define allv(a) a.begin(),a.end()
#define endv(a) (int)a.size()-1
////////////////////////////////////////// NIRO
const int N=105;
int n,m,k;
int a[N][N];
struct dp
{
    int v=-1e9,o;
};
dp f[N][N][15];

void CAPNHAP(int x,int y,int X,int Y,int o)
{
    if(1<=x&&x<=n&&1<=y&&y<=n) {}else return;
    FOR(kk,0,k-1) if(f[X][Y][kk].v>=0)
    {
        int v=f[X][Y][kk].v+a[x][y];
        int vk=v%k;
        if(f[x][y][vk].v<v) f[x][y][vk]={v,o};
    }
}

int UPMOD(int x)
{
    x%=k;x+=k;
    return x%k;
}

void GO(int x,int y,int kk)
{
    int o=f[x][y][kk].o;
    if(x!=n)
    {
        int xx=x+1;
        int yy=o?y-1:y+1;
        int k2=UPMOD(kk-a[x][y]);
        GO(xx,yy,k2);

        cout<<"LR"[o];
    }
    else cout<<y<<"\n";
}
main()
{
    //freopen("nr.inp","r",stdin);
    n=in,m=in,k=in+1;
    FOR(i,1,n) FOR(j,1,n) a[i][j]=inchar-'0';

    FOR(j,1,n) f[n][j][a[n][j]%k]={a[n][j],0};
    ROF(i,2,n) FOR(j,1,n)
    {
        CAPNHAP(i-1,j-1,i,j,0);
        CAPNHAP(i-1,j+1,i,j,1);
    }
    ll res=-1e9,ii,jj;
    FOR(j,1,n) if(res<f[1][j][0].v) res=f[1][j][0].v,ii=1,jj=j;
    if(res<0) cout<<"-1";
    else
    {
        cout<<res<<"\n";
        GO(ii,jj,0);
    }
}


#include<bits/stdc++.h>
using namespace std;

#define in ({ll x=0;int n=0,c=getchar();for(;!isdigit(c);c=getchar()) n=c=='-';for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
#define inchar ({char c=getchar();while(c==' '||c=='\n') c=getchar();c;})

#define ll long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=b;a<=i;i--)
#define rr(x) " "<<#x<<'='<<x<<" "

#define bit(x,i) ((x>>(i-1))&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))
#define pow2(x) (1ll<<x)

#define mt make_tuple
#define pi pair<int,int>
#define x first
#define y second

#define VEC(i,a) for(auto&i:a)
#define pb push_back
#define allv(a) a.begin(),a.end()
#define endv(a) (int)a.size()-1
////////////////////////////////////////// NIRO
const int N=105;
int n,m,k;
int a[N][N];
struct dp
{
    int v=-1e9,o;
};
dp f[N][N][15];

void CAPNHAP(int x,int y,int X,int Y,int o)
{
    if(1<=x&&x<=n&&1<=y&&y<=n) {}else return;
    FOR(kk,0,k-1) if(f[X][Y][kk].v>=0)
    {
        int v=f[X][Y][kk].v+a[x][y];
        int vk=v%k;
        if(f[x][y][vk].v<v) f[x][y][vk].v=v,f[x][y][vk].o=o;
    }
}

int UPMOD(int x)
{
    x%=k;x+=k;
    return x%k;
}

void GO(int x,int y,int kk)
{
    int o=f[x][y][kk].o;
    if(x!=n)
    {
        int xx=x+1;
        int yy=o?y-1:y+1;
        int k2=UPMOD(kk-a[x][y]);
        GO(xx,yy,k2);
        cout<<"RL"[o];
    }
    else cout<<y<<"\n";

}
main()
{
    //freopen("nr.inp","r",stdin);
    n=in,m=in,k=in+1;
    FOR(i,1,n) FOR(j,1,m) a[i][j]=inchar-'0';

    FOR(j,1,m) f[n][j][a[n][j]%k].v=a[n][j];
    ROF(i,2,n) FOR(j,1,m)
    {
        CAPNHAP(i-1,j-1,i,j,0);
        CAPNHAP(i-1,j+1,i,j,1);
    }
    ll res=-1e9,ii,jj;
    FOR(j,1,m) if(res<f[1][j][0].v) res=f[1][j][0].v,ii=1,jj=j;

    if(0) FOR(kk,0,k-1)
    {
        cout<<"\n===========" rr(kk) "\n";
        FOR(i,1,n) FOR(j,1,m) cout<<f[i][j][kk].v<<" \n"[j==n];
    }

    if(0) FOR(kk,0,k-1)
    {
        cout<<"\n===========" rr(kk) "\n";
        FOR(i,1,n) FOR(j,1,m) cout<<f[i][j][kk].o<<" \n"[j==n];
    }

    if(res<0) cout<<"-1";
    else
    {
        cout<<res<<"\n";
        GO(ii,jj,0);
    }
}


#include<bits/stdc++.h>
using namespace std;

#define in ({ll x=0;int n=0,c=getchar();for(;!isdigit(c);c=getchar()) n=c=='-';for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
#define inchar ({char c=getchar();while(c==' '||c=='\n') c=getchar();c;})

#define ll long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=b;a<=i;i--)
#define rr(x) " "<<#x<<'='<<x<<" "

#define bit(x,i) ((x>>(i-1))&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))
#define pow2(x) (1ll<<x)

#define mt make_tuple
#define pi pair<int,int>
#define x first
#define y second

#define VEC(i,a) for(auto&i:a)
#define pb push_back
#define allv(a) a.begin(),a.end()
#define endv(a) (int)a.size()-1
////////////////////////////////////////// NIRO
const int N=105;
int n,m,k;
int a[N][N];
struct dp
{
    int v=-1e9,o;
};
dp f[N][N][15];

void CAPNHAP(int x,int y,int X,int Y,int o)
{
    if(1<=x&&x<=n&&1<=y&&y<=m) {}else return;
    FOR(kk,0,k-1) if(f[X][Y][kk].v>=0)
    {
        int v=f[X][Y][kk].v+a[x][y];
        int vk=v%k;
        if(f[x][y][vk].v<v) f[x][y][vk].v=v,f[x][y][vk].o=o;
    }
}

int UPMOD(int x)
{
    x%=k;x+=k;
    return x%k;
}

void GO(int x,int y,int kk)
{
    int o=f[x][y][kk].o;
    if(x!=n)
    {
        int xx=x+1;
        int yy=o?y-1:y+1;
        int k2=UPMOD(kk-a[x][y]);
        GO(xx,yy,k2);
        cout<<"LR"[o];
    }
    else cout<<y<<"\n";

}
main()
{
    //freopen("nr.inp","r",stdin);
    n=in,m=in,k=in+1;
    FOR(i,1,n) FOR(j,1,m) a[i][j]=inchar-'0';

    FOR(j,1,m) f[n][j][a[n][j]%k].v=a[n][j];
    ROF(i,2,n) FOR(j,1,m)
    {
        CAPNHAP(i-1,j-1,i,j,0);
        CAPNHAP(i-1,j+1,i,j,1);
    }
    ll res=-1e9,ii,jj;
    FOR(j,1,m) if(res<f[1][j][0].v) res=f[1][j][0].v,ii=1,jj=j;

    if(res<0) cout<<"-1";
    else
    {
        cout<<res<<"\n";
        GO(ii,jj,0);
    }
}


#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>

#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pretime float(clock()-clk)/CLOCKS_PER_SEC
#define max2(a,b) ((a)>(b) ? (a) : (b))
#define min2(a,b) ((a)<(b) ? (a) : (b))
#define rep(i,a,b) for(i=a;i<=b;++i)
#define rev(i,a,b) for(i=a;i>=b;--i)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define ll long long int
#define ins insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
#define inf 1000000000000000

using namespace std;
typedef vector<ll>   vll;
typedef vector<int>   vi;
typedef set<ll>      sll;
typedef set<int>      si;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
clock_t clk=clock();

ll i,j;
void solve(void);

int main()
{
  // speedio;
   int t=1;
  // cin>>t;
   while(t--)
     solve();

  return 0;
}
//
ll dp[105][105][1005],a[105][105],n,m,k;

ll compute(ll x,ll y,ll s)
{
	// cout<<x<<' '<<y<<'\n';
	if(x<0 || y<0 || y>=m || x>=n) return -1;
	ll sum=s+a[x][y];

	if(x==0 && sum%(k+1)==0) return dp[x][y][s]=sum;
	if(x==0 && sum%(k+1)!=0) return -1;

    if(dp[x][y][s]!=-1) return dp[x][y][s];

	ll ans=-1;

	ll t1=compute(x-1,y-1,sum);
	ll t2=compute(x-1,y+1,sum);

	ans=max2(t1,t2);
    if(ans==-1) return ans;
    return dp[x][y][s]=ans;
}

void solve()
{
    cin>>n>>m>>k;
    char c[n][m];
	rep(i,0,n-1) rep(j,0,m-1) cin>>c[i][j];
	rep(i,0,n-1) rep(j,0,m-1) a[i][j]=c[i][j]-'0';

    // rep(i,0,n-1) rep(j,0,m-1) cout<<a[i][j]<<' ';
    ll max=-1;
    memset(dp,-1,sizeof(dp));

    rep(i,0,m-1)
     {
     	ll t=compute(n-1,i,0);
     	max=max2(max,t);
     }

     if(max==-1) cout<<"-1\n";
     else
     {
     	cout<<max<<'\n';

       ll idx=-1;
         rep(j,0,m-1)
          if(dp[n-1][j][0]==max) idx=j;

          cout<<idx+1<<'\n';
          ll sum=0;
          j=idx;
          sum+=a[n-1][j];

          rev(i,n-2,0)
          {
          	ll nind;
            if(j-1>=0 && j-1<m && dp[i][j-1][sum]==max)
            	nind=j-1;
            else if(j+1<m && j+1>=0 && dp[i][j+1][sum]==max)
            	nind=j+1;

              if(nind>j) cout<<'R';
              else cout<<'L';

              j=nind;
              sum+=a[i][j];
         }

     }
}


#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>

#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pretime float(clock()-clk)/CLOCKS_PER_SEC
#define max2(a,b) ((a)>(b) ? (a) : (b))
#define min2(a,b) ((a)<(b) ? (a) : (b))
#define rep(i,a,b) for(i=a;i<=b;++i)
#define rev(i,a,b) for(i=a;i>=b;--i)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define ll long long int
#define ins insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
#define inf 1000000000000000

using namespace std;
typedef vector<ll>   vll;
typedef vector<int>   vi;
typedef set<ll>      sll;
typedef set<int>      si;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
clock_t clk=clock();

ll i,j;
void solve(void);

int main()
{
  // speedio;
   int t=1;
  // cin>>t;
   while(t--)
     solve();

  return 0;
}
//
ll dp[105][105][1005],a[105][105],n,m,k;

ll compute(ll x,ll y,ll s)
{
	// cout<<x<<' '<<y<<'\n';
	if(x<0 || y<0 || y>=m || x>=n) return -inf;
	ll sum=s+a[x][y];

	if(x==0 && sum%(k+1)==0) return dp[x][y][s]=sum;
	if(x==0 && sum%(k+1)!=0) return dp[x][y][s]=-inf;

    if(dp[x][y][s]!=-1) return dp[x][y][s];

	ll ans=-2*inf;

	ll t1=compute(x-1,y-1,sum);
	ll t2=compute(x-1,y+1,sum);

	ans=max2(t1,t2);
    return dp[x][y][s]=ans;
}

void solve()
{
    cin>>n>>m>>k;
    char c[n][m];
	rep(i,0,n-1) rep(j,0,m-1) cin>>c[i][j];
	rep(i,0,n-1) rep(j,0,m-1) a[i][j]=c[i][j]-'0';

    // rep(i,0,n-1) rep(j,0,m-1) cout<<a[i][j]<<' ';
    ll max=-inf;
    memset(dp,-1,sizeof(dp));

    rep(i,0,m-1)
     {
     	ll t=compute(n-1,i,0);
     	max=max2(max,t);
     }

     if(max==-inf) cout<<"-1\n";
     else
     {
     	cout<<max<<'\n';

       ll idx=-1;
         rep(j,0,m-1)
          if(dp[n-1][j][0]==max) idx=j;

          cout<<idx+1<<'\n';
          ll sum=0;
          j=idx;
          sum+=a[n-1][j];

          rev(i,n-2,0)
          {
          	ll nind;
            if(j-1>=0 && j-1<m && dp[i][j-1][sum]==max)
            	nind=j-1;
            else if(j+1<m && j+1>=0 && dp[i][j+1][sum]==max)
            	nind=j+1;

              if(nind>j) cout<<'R';
              else cout<<'L';

              j=nind;
              sum+=a[i][j];
         }

     }
}


#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>

#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pretime float(clock()-clk)/CLOCKS_PER_SEC
#define max2(a,b) ((a)>(b) ? (a) : (b))
#define min2(a,b) ((a)<(b) ? (a) : (b))
#define rep(i,a,b) for(i=a;i<=b;++i)
#define rev(i,a,b) for(i=a;i>=b;--i)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define ll long long int
#define ins insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
#define inf 1000000000000000

using namespace std;
typedef vector<ll>   vll;
typedef vector<int>   vi;
typedef set<ll>      sll;
typedef set<int>      si;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
clock_t clk=clock();

ll i,j;
void solve(void);

int main()
{
  // speedio;
   int t=1;
  // cin>>t;
   while(t--)
     solve();

  return 0;
}
//
ll dp[105][105][1005],a[105][105],n,m,k;

ll compute(ll x,ll y,ll s)
{
	// cout<<x<<' '<<y<<'\n';
	if(x<0 || y<0 || y>=m || x>=n) return -1;
	ll sum=s+a[x][y];

	if(x==0 && sum%(k+1)==0) return dp[x][y][s]=sum;
	if(x==0 && sum%(k+1)!=0) return -1;

    if(dp[x][y][s]!=-1) return dp[x][y][s];

	ll ans=-1;

	ll t1=compute(x-1,y-1,sum);
	ll t2=compute(x-1,y+1,sum);

	ans=max2(t1,t2);
    if(ans==-1) return ans;
    return dp[x][y][s]=ans;
}

void solve()
{
    cin>>n>>m>>k;
    char c[n][m];
	rep(i,0,n-1) rep(j,0,m-1) cin>>c[i][j];
	rep(i,0,n-1) rep(j,0,m-1) a[i][j]=c[i][j]-'0';

    // rep(i,0,n-1) rep(j,0,m-1) cout<<a[i][j]<<' ';
    ll max=-1;
    memset(dp,-1,sizeof(dp));

    rep(i,0,m-1)
     {
     	ll t=compute(n-1,i,0);
     	max=max2(max,t);
     }

     if(max==-1) cout<<"-1\n";
     else
     {
     	cout<<max<<'\n';

        ll sum=0; vector< pll > v;
     	rev(i,n-1,0)
     	{
     		ll max1=0,idx=-1;
     	 rep(j,0,m-1)
     	   if(max1<=dp[i][j][sum])
             {
             	max1=dp[i][j][sum];
             	idx=j;
             }
           v.pb({i+1,idx+1});
           sum+=a[i][idx];

     	}

  // cout<<dp[0][0][14]<<" "<<dp[0][2][14]<<'\n';

     	cout<<v[0].se<<'\n';
     	rep(i,1,sz(v)-1)
     	 if(v[i].se>v[i-1].se) cout<<'R';
     	 else cout<<'L';
     	 cout<<'\n';
     }
}


//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
int n, m, k;
char str[105][105];
int memo[105][105][12];

int solve(int i, int j, int s) {
	if (j < 1 || j > m)
		return -1e9;
	if (i == n) {
		if ((s + (str[i][j] - '0')) % k)
			return -1e9;
		return str[i][j] - '0';
	}
	int &res = memo[i][j][s];
	if (~res)
		return res;
	res = -1e9;
	s = (s + (str[i][j] - '0')) % k;
	res = (str[i][j] - '0')
			+ max(solve(i + 1, j + 1, s), solve(i + 1, j - 1, s));
	return res;
}
void print(int i, int j, int s) {

	if (i == n) {
		return;
	}
	int res = memo[i][j][s];

	s = (s + (str[i][j] - '0')) % k;
	if ((str[i][j] - '0') + solve(i + 1, j + 1, s) == res) {
		printf("R");
		print(i + 1, j + 1, s);
		return;
	}
	printf("L");
	print(i + 1, j - 1, s);
}
int main() {
	//freopen("in.txt", "rt", stdin);
	scanf("%d %d %d", &n, &m, &k);
	++k;
	for (int i = 1; i <= n; ++i) {
		scanf(" %s", str[i] + 1);
	}
	memset(memo, -1, sizeof memo);
	int best = -1, mx = -1e9;
	for (int i = 1; i <= m; ++i) {
		int v = solve(1, i, 0);
		if (v > mx) {
			mx = v;
			best = i;
		}
	}

	if (mx > 0 && !best) {
		printf("%d\n%d\n", mx, best);
		print(1, best, 0);
	} else {
		puts("-1");
	}
}


//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
int n, m, k;
char str[105][105];
int memo[105][105][12];

int solve(int i, int j, int s) {
	if (j < 1 || j > m)
		return -1e9;
	if (i == n) {
		if ((s + (str[i][j] - '0')) % k)
			return -1e9;
		return str[i][j] - '0';
	}
	int &res = memo[i][j][s];
	if (~res)
		return res;
	res = -1e9;
	s = (s + (str[i][j] - '0')) % k;
	res = (str[i][j] - '0')
			+ max(solve(i + 1, j + 1, s), solve(i + 1, j - 1, s));
	return res;
}
void print(int i, int j, int s) {

	if (i == n) {
		return;
	}
	int res = memo[i][j][s];

	s = (s + (str[i][j] - '0')) % k;
	if ((str[i][j] - '0') + solve(i + 1, j + 1, s) == res) {
		printf("R");
		print(i + 1, j + 1, s);
		return;
	}
	printf("L");
	print(i + 1, j - 1, s);
}
int main() {
	//freopen("in.txt", "rt", stdin);
	scanf("%d %d %d", &n, &m, &k);
	++k;
	for (int i = 1; i <= n; ++i) {
		scanf(" %s", str[i] + 1);
	}
	memset(memo, -1, sizeof memo);
	int best = -1, mx = -1e9;
	for (int i = m; i > 0; --i) {
		int v = solve(1, i, 0);
		if (v > mx && v >= 0) {
			mx = v;
			best = i;
		}
	}

	if (mx >= 0 && best > 0) {
		printf("%d\n%d\n", mx, best);
		print(1, best, 0);
	} else {
		puts("-1");
	}
}


//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
int n, m, k;
char str[105][105];
int memo[105][105][12];

int solve(int i, int j, int s) {
	if (j < 1 || j > m)
		return -1e9;
	if (i == n) {
		if ((s + (str[i][j] - '0')) % k)
			return -1e9;
		return str[i][j] - '0';
	}
	int &res = memo[i][j][s];
	if (~res)
		return res;
	res = -1e9;
	s = (s + (str[i][j] - '0')) % k;
	res = (str[i][j] - '0')
			+ max(solve(i + 1, j + 1, s), solve(i + 1, j - 1, s));
	return res;
}
void print(int i, int j, int s) {

	if (i == n) {
		return;
	}
	int res = memo[i][j][s];

	s = (s + (str[i][j] - '0')) % k;
	if ((str[i][j] - '0') + solve(i + 1, j + 1, s) == res) {
		printf("R");
		print(i + 1, j + 1, s);
		return;
	}
	printf("L");
	print(i + 1, j - 1, s);
}
int main() {
	//freopen("in.txt", "rt", stdin);
	scanf("%d %d %d", &n, &m, &k);
	++k;
	for (int i = n; i > 0; --i) {
		scanf(" %s", str[i] + 1);
	}
	memset(memo, -1, sizeof memo);
	int best = -1, mx = -1e9;
	for (int i = 1; i <= m; ++i) {
		int v = solve(1, i, 0);
		if (v > mx && v >= 0) {
			mx = v;
			best = i;
		}
	}

	if (mx >= 0 && best > 0) {
		printf("%d\n%d\n", mx, best);
		print(1, best, 0);
	} else {
		puts("-1");
	}
}


//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
int n, m, k;
char str[105][105];
int memo[105][105][12];

int solve(int i, int j, int s) {
	if (j < 1 || j > m)
		return -2e9;
	if (i == n) {
		if ((s + (str[i][j] - '0')) % k)
			return -2e9;
		return str[i][j] - '0';
	}
	int &res = memo[i][j][s];
	if (~res)
		return res;
	res = -2e9;
	s = (s + (str[i][j] - '0')) % k;
	res = (str[i][j] - '0')
			+ max(solve(i + 1, j + 1, s), solve(i + 1, j - 1, s));
	return res;
}
void print(int i, int j, int s) {

	if (i == n) {
		return;
	}
	int res = memo[i][j][s];

	s = (s + (str[i][j] - '0')) % k;
	if ((str[i][j] - '0') + solve(i + 1, j + 1, s) == res) {
		printf("R");
		print(i + 1, j + 1, s);
		return;
	}
	printf("L");
	print(i + 1, j - 1, s);
}
int main() {
	//freopen("in.txt", "rt", stdin);
	scanf("%d %d %d", &n, &m, &k);
	++k;
	for (int i = 1; i <= n; ++i) {
		scanf(" %s", str[i] + 1);
	}
	memset(memo, -1, sizeof memo);
	int best = -1, mx = -1e9;
	for (int i = 1; i <= m; ++i) {
		int v = solve(1, i, 0);
		if (v > mx) {
			mx = v;
			best = i;
		}
	}

	if (mx > 0) {
		printf("%d\n%d\n", mx, best);
		print(1, best, 0);
	} else {
		puts("-1");
	}
}


//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
int n, m, k;
char str[105][105];
int memo[105][105][12];

int solve(int i, int j, int s) {
	if (j < 1 || j > m)
		return -1e9;
	if (i == n) {
		if ((s + (str[i][j] - '0')) % k)
			return -1e9;
		return str[i][j] - '0';
	}
	int &res = memo[i][j][s];
	if (~res)
		return res;
	res = -1e9;
	s = (s + (str[i][j] - '0')) % k;
	res = (str[i][j] - '0')
			+ max(solve(i + 1, j + 1, s), solve(i + 1, j - 1, s));
	return res;
}
void print(int i, int j, int s) {

	if (i == n) {
		return;
	}
	int res = memo[i][j][s];

	s = (s + (str[i][j] - '0')) % k;
	if ((str[i][j] - '0') + solve(i + 1, j + 1, s) == res) {
		printf("R");
		print(i + 1, j + 1, s);
		return;
	}
	printf("L");
	print(i + 1, j - 1, s);
}
int main() {
	//freopen("in.txt", "rt", stdin);
	scanf("%d %d %d", &n, &m, &k);
	++k;
	for (int i = 1; i <= n; ++i) {
		scanf(" %s", str[i] + 1);
	}
	memset(memo, -1, sizeof memo);
	int best = -1, mx = -1e9;
	for (int i = 1; i <= m; ++i) {
		int v = solve(1, i, 0);
		if (v > mx) {
			mx = v;
			best = i;
		}
	}

	if (mx > 0 && best > 0) {
		printf("%d\n%d\n", mx, best);
		print(1, best, 0);
	} else {
		puts("-1");
	}
}


//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
int n, m, k;
char str[105][105];
int memo[105][105][12];

int solve(int i, int j, int s) {
	if (j < 1 || j > m)
		return -1e9;
	if (i == n) {
		if ((s + (str[i][j] - '0')) % k)
			return -1e9;
		return str[i][j] - '0';
	}
	int &res = memo[i][j][s];
	if (~res)
		return res;
	res = -1e9;
	s = (s + (str[i][j] - '0')) % k;
	res = (str[i][j] - '0')
			+ max(solve(i + 1, j + 1, s), solve(i + 1, j - 1, s));
	return res;
}
void print(int i, int j, int s) {

	if (i == n) {
		return;
	}
	int res = memo[i][j][s];

	s = (s + (str[i][j] - '0')) % k;
	if ((str[i][j] - '0') + solve(i + 1, j + 1, s) == res) {
		printf("R");
		print(i + 1, j + 1, s);
		return;
	}
	printf("L");
	print(i + 1, j - 1, s);
}
int main() {
	//freopen("in.txt", "rt", stdin);
	scanf("%d %d %d", &n, &m, &k);
	++k;
	for (int i = 1; i <= n; ++i) {
		scanf(" %s", str[i] + 1);
	}
	memset(memo, -1, sizeof memo);
	int best = -1, mx = -1e9;
	for (int i = 1; i <= m; ++i) {
		int v = solve(1, i, 0);
		if (v > mx && v >= 0) {
			mx = v;
			best = i;
		}
	}

	if (mx >= 0 && best > 0) {
		printf("%d\n%d\n", mx, best);
		print(1, best, 0);
	} else {
		puts("-1");
	}
}


#include <iostream>
#include <map>
#include <ctime>
#include <vector>
#include <climits>
#include <algorithm>
#include <random>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define inf 0x3f3f3f3f
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define rep(i, a, n) for( int i = a; i <= n; ++ i)
#define per(i, a, n) for( int i = n; i >= a; -- i)
#define ONLINE_JUDGE
using namespace std;
typedef long long ll;
const int mod=1e9+7;
template<typename T>void write(T x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
    {
        write(x/10);
    }
    putchar(x%10+'0');
}

template<typename T> void read(T &x)
{
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;};
ll ksm(ll a,ll n){//看是否要mod
	ll ans=1;
	while(n){
		if(n&1) ans=((ans%mod)*(a%mod))%mod;
		a=((a%mod)*(a%mod))%mod;
		n>>=1;
	}
	return ans%mod;
}
//==============================================================
#define int ll
const int maxn=105;
int mp[maxn][maxn],n,m,k;
ll dp[maxn][maxn][2][20];
int vis[maxn][maxn];
struct Edge{
    int dir,from,r;
    Edge(int d=0,int f=0,int rr=0){
        dir=d;
        from=f;
        r=rr;
    }
}path[maxn][maxn][2][20];
int dir[2][2]={-1,-1,-1,1};
void solve(int x,int y){
    if(vis[x][y]) return;
    vis[x][y]=1;
    dp[x][y][0][mp[x][y]%(k+1)]=dp[x][y][1][mp[x][y]%(k+1)]=mp[x][y];
    if(x==1) return ;
    for(int i=0;i<2;i++){
        int dx=x+dir[i][0],dy=y+dir[i][1];
        if(dx<=0||dy<=0||dx>n||dy>m) continue;
        solve(dx,dy);
        int tmp[20];rep(j,0,20-1) tmp[j]=dp[x][y][i][j];
        rep(j,0,k){
            //if(max(dp[dx][dy][1][j],dp[dx][dy][0][j])==0) continue;
            rep(l,mp[x][y]%(k+1),k){
                //if(tmp[l]==0) continue;
                if(dp[x][y][i][(j+l)%(k+1)]<=max(dp[dx][dy][1][j],dp[dx][dy][0][j])+tmp[l]){
                    if(dp[dx][dy][1][j]+tmp[l]>=dp[x][y][i][(j+l)%(k+1)]){
                        path[x][y][i][(j+l)%(k+1)]=Edge(i,1,j);
                    }
                    else{
                        path[x][y][i][(j+l)%(k+1)]=Edge(i,0,j);
                    }
                }
                dp[x][y][i][(j+l)%(k+1)]=max(dp[x][y][i][(j+l)%(k+1)],max(dp[dx][dy][1][j],dp[dx][dy][0][j])+tmp[l]);
            }
        }
    }
}
char st[200],top=0;
void show_path(int sx,int sy,int sl,int sr){
    write(sy),putchar('\n');
    while(sx!=1){
        //cerr<<sx<<" "<<sy<<endl;
        Edge now=path[sx][sy][sl][sr];
        sr=now.r;
        if(max(dp[sx-1][sy-1][0][sr],dp[sx-1][sy-1][1][sr])>max(dp[sx-1][sy+1][0][sr],dp[sx-1][sy+1][1][sr])){
            if(dp[sx-1][sy-1][0][sr]>dp[sx-1][sy-1][1][sr]) sl=0;
            else sl=1;
            sx=sx-1,sy=sy-1;
            st[++top]='L';
        }
        else{
            if(dp[sx-1][sy+1][0][sr]>dp[sx-1][sy+1][1][sr]) sl=0;
            else sl=1;
            sx=sx-1,sy=sy+1;
            st[++top]='R';
        }
        /*if(now.dir==1) st[++top]='R';
        else st[++top]='L';*/
    }
    //cerr<<sx<<" "<<sy<<endl;
    rep(i,1,top){
        putchar(st[i]);
    }
}

signed main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	//===========================================================
    read(n),read(m),read(k);
    memset(dp,-inf,sizeof(dp));
    rep(i,1,n){
        rep(j,1,m){
            char t;cin>>t;
            mp[i][j]=t-'0';
        }
    }
    rep(i,1,m){
        solve(n,i);
    }
    ll res=-inf;
    int sx=0,sy=0,sl=0,sr=0;
    rep(i,1,m){
        if(res<=max(dp[n][i][0][0],dp[n][i][1][0])){
            if(dp[n][i][0][0]>=dp[n][i][1][0]){
                sx=n,sy=i,sl=0,sr=0;
            }
            else{
                sx=n,sy=i,sl=1,sr=0;
            }
        }
        res=max(res,max(dp[n][i][0][0],dp[n][i][1][0]));
    }
    /*rep(i,1,n){
        rep(j,1,m){
            rep(l,0,k){
                cerr<<dp[i][j][0][l]<<"|"<<dp[i][j][1][l]<<" ";
            }
            cerr<<"    ";
        }
        cerr<<endl;
    }
    Edge p=path[3][2][1][0];*/
    //cerr<<p.dir<<" "<<p.from<<" "<<p.r<<endl;
    if(res<=0){
        puts("-1");
        return 0;
    }
    write(res),putchar('\n');
    show_path(sx,sy,sl,sr);
	//===========================================================
	return 0;
}


#include <iostream>
#include <map>
#include <ctime>
#include <vector>
#include <climits>
#include <algorithm>
#include <random>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define inf 0x3f3f3f3f
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define rep(i, a, n) for(register int i = a; i <= n; ++ i)
#define per(i, a, n) for(register int i = n; i >= a; -- i)
//#define ONLINE_JUDGE
using namespace std;
typedef long long ll;
const int mod=1e9+7;
template<typename T>void write(T x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
    {
        write(x/10);
    }
    putchar(x%10+'0');
}

template<typename T> void read(T &x)
{
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;};
ll ksm(ll a,ll n){//看是否要mod
	ll ans=1;
	while(n){
		if(n&1) ans=((ans%mod)*(a%mod))%mod;
		a=((a%mod)*(a%mod))%mod;
		n>>=1;
	}
	return ans%mod;
}
//==============================================================
#define int ll
const int maxn=105;
int mp[maxn][maxn],n,m,k;
ll dp[maxn][maxn][2][20];
int vis[maxn][maxn];
struct Edge{
    int dir,from,r;
    Edge(int d=0,int f=0,int rr=0){
        dir=d;
        from=f;
        r=rr;
    }
}path[maxn][maxn][2][20];
int dir[2][2]={-1,-1,-1,1};
void solve(int x,int y){
    if(vis[x][y]) return;
    vis[x][y]=1;
    dp[x][y][0][mp[x][y]%(k+1)]=dp[x][y][1][mp[x][y]%(k+1)]=mp[x][y];
    if(x==1) return ;
    for(int i=0;i<2;i++){
        int dx=x+dir[i][0],dy=y+dir[i][1];
        if(dx<=0||dy<=0||dx>n||dy>m) continue;
        solve(dx,dy);
        int tmp[20];rep(j,0,20-1) tmp[j]=dp[x][y][i][j];
        rep(j,0,k){
            //if(max(dp[dx][dy][1][j],dp[dx][dy][0][j])==0) continue;
            rep(l,mp[x][y]%(k+1),k){
                //if(tmp[l]==0) continue;
                if(dp[x][y][i][(j+l)%(k+1)]<=max(dp[dx][dy][1][j],dp[dx][dy][0][j])+tmp[l]){
                    if(dp[dx][dy][1][j]+tmp[l]>=dp[x][y][i][(j+l)%(k+1)]){
                        path[x][y][i][(j+l)%(k+1)]=Edge(i,1,j);
                    }
                    else{
                        path[x][y][i][(j+l)%(k+1)]=Edge(i,0,j);
                    }
                }
                dp[x][y][i][(j+l)%(k+1)]=max(dp[x][y][i][(j+l)%(k+1)],max(dp[dx][dy][1][j],dp[dx][dy][0][j])+tmp[l]);
            }
        }
    }
}
char st[200],top=0;
void show_path(int sx,int sy,int sl,int sr){
    write(sy),putchar('\n');
    while(sx!=1){
        //cerr<<sx<<" "<<sy<<endl;
        Edge now=path[sx][sy][sl][sr];
        sr=now.r;
        if(max(dp[sx-1][sy-1][0][sr],dp[sx-1][sy-1][1][sr])>max(dp[sx-1][sy+1][0][sr],dp[sx-1][sy+1][1][sr])){
            if(dp[sx-1][sy-1][0][sr]>dp[sx-1][sy-1][1][sr]) sl=0;
            else sl=1;
            sx=sx-1,sy=sy-1;
            st[++top]='L';
        }
        else{
            if(dp[sx-1][sy+1][0][sr]>dp[sx-1][sy+1][1][sr]) sl=0;
            else sl=1;
            sx=sx-1,sy=sy+1;
            st[++top]='R';
        }
        /*if(now.dir==1) st[++top]='R';
        else st[++top]='L';*/
    }
    //cerr<<sx<<" "<<sy<<endl;
    rep(i,1,top){
        putchar(st[i]);
    }
}

signed main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	//===========================================================
    read(n),read(m),read(k);
    memset(dp,-inf,sizeof(dp));
    rep(i,1,n){
        rep(j,1,m){
            char t;cin>>t;
            mp[i][j]=t-'0';
        }
    }
    rep(i,1,m){
        solve(n,i);
    }
    ll res=0;
    int sx=0,sy=0,sl=0,sr=0;
    rep(i,1,m){
        if(res<=max(dp[n][i][0][0],dp[n][i][1][0])){
            if(dp[n][i][0][0]>=dp[n][i][1][0]){
                sx=n,sy=i,sl=0,sr=0;
            }
            else{
                sx=n,sy=i,sl=1,sr=0;
            }
        }
        res=max(res,max(dp[n][i][0][0],dp[n][i][1][0]));
    }
    /*rep(i,1,n){
        rep(j,1,m){
            rep(l,0,k){
                cerr<<dp[i][j][0][l]<<"|"<<dp[i][j][1][l]<<" ";
            }
            cerr<<"    ";
        }
        cerr<<endl;
    }
    Edge p=path[3][2][1][0];*/
    //cerr<<p.dir<<" "<<p.from<<" "<<p.r<<endl;
    if(res==0){
        puts("-1");
        return 0;
    }
    write(res),putchar('\n');
    show_path(sx,sy,sl,sr);
	//===========================================================
	return 0;
}


#include <iostream>
#include <map>
#include <ctime>
#include <vector>
#include <climits>
#include <algorithm>
#include <random>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define inf 0x3f3f3f3f
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define rep(i, a, n) for(register int i = a; i <= n; ++ i)
#define per(i, a, n) for(register int i = n; i >= a; -- i)
//#define ONLINE_JUDGE
using namespace std;
typedef long long ll;
const int mod=1e9+7;
template<typename T>void write(T x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
    {
        write(x/10);
    }
    putchar(x%10+'0');
}

template<typename T> void read(T &x)
{
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;};
ll ksm(ll a,ll n){//看是否要mod
	ll ans=1;
	while(n){
		if(n&1) ans=((ans%mod)*(a%mod))%mod;
		a=((a%mod)*(a%mod))%mod;
		n>>=1;
	}
	return ans%mod;
}
//==============================================================
#define int ll
const int maxn=105;
int mp[maxn][maxn],n,m,k;
ll dp[maxn][maxn][2][20];
int vis[maxn][maxn];
struct Edge{
    int dir,from,r;
    Edge(int d=0,int f=0,int rr=0){
        dir=d;
        from=f;
        r=rr;
    }
}path[maxn][maxn][2][20];
int dir[2][2]={-1,-1,-1,1};
void solve(int x,int y){
    if(vis[x][y]) return;
    vis[x][y]=1;
    dp[x][y][0][mp[x][y]%(k+1)]=dp[x][y][1][mp[x][y]%(k+1)]=mp[x][y];
    if(x==1) return ;
    for(int i=0;i<2;i++){
        int dx=x+dir[i][0],dy=y+dir[i][1];
        if(dx<=0||dy<=0||dx>n||dy>m) continue;
        solve(dx,dy);
        int tmp[20];rep(j,0,20-1) tmp[j]=dp[x][y][i][j];
        rep(j,0,k){
            //if(max(dp[dx][dy][1][j],dp[dx][dy][0][j])==0) continue;
            rep(l,mp[x][y]%(k+1),k){
                //if(tmp[l]==0) continue;
                if(dp[x][y][i][(j+l)%(k+1)]<=max(dp[dx][dy][1][j],dp[dx][dy][0][j])+tmp[l]){
                    if(dp[dx][dy][1][j]+tmp[l]>=dp[x][y][i][(j+l)%(k+1)]){
                        path[x][y][i][(j+l)%(k+1)]=Edge(i,1,j);
                    }
                    else{
                        path[x][y][i][(j+l)%(k+1)]=Edge(i,0,j);
                    }
                }
                dp[x][y][i][(j+l)%(k+1)]=max(dp[x][y][i][(j+l)%(k+1)],max(dp[dx][dy][1][j],dp[dx][dy][0][j])+tmp[l]);
            }
        }
    }
}
char st[200],top=0;
void show_path(int sx,int sy,int sl,int sr){
    write(sy),putchar('\n');
    while(sx!=1){
        //cerr<<sx<<" "<<sy<<endl;
        Edge now=path[sx][sy][sl][sr];
        sr=now.r;
        if(max(dp[sx-1][sy-1][0][sr],dp[sx-1][sy-1][1][sr])>max(dp[sx-1][sy+1][0][sr],dp[sx-1][sy+1][1][sr])){
            if(dp[sx-1][sy-1][0][sr]>dp[sx-1][sy-1][1][sr]) sl=0;
            else sl=1;
            sx=sx-1,sy=sy-1;
            st[++top]='L';
        }
        else{
            if(dp[sx-1][sy+1][0][sr]>dp[sx-1][sy+1][1][sr]) sl=0;
            else sl=1;
            sx=sx-1,sy=sy+1;
            st[++top]='R';
        }
        /*if(now.dir==1) st[++top]='R';
        else st[++top]='L';*/
    }
    //cerr<<sx<<" "<<sy<<endl;
    rep(i,1,top){
        putchar(st[i]);
    }
}

signed main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	//===========================================================
    read(n),read(m),read(k);
    memset(dp,-inf,sizeof(dp));
    rep(i,1,n){
        rep(j,1,m){
            char t;cin>>t;
            mp[i][j]=t-'0';
        }
    }
    rep(i,1,m){
        solve(n,i);
    }
    ll res=-inf;
    int sx=0,sy=0,sl=0,sr=0;
    rep(i,1,m){
        if(res<=max(dp[n][i][0][0],dp[n][i][1][0])){
            if(dp[n][i][0][0]>=dp[n][i][1][0]){
                sx=n,sy=i,sl=0,sr=0;
            }
            else{
                sx=n,sy=i,sl=1,sr=0;
            }
        }
        res=max(res,max(dp[n][i][0][0],dp[n][i][1][0]));
    }
    /*rep(i,1,n){
        rep(j,1,m){
            rep(l,0,k){
                cerr<<dp[i][j][0][l]<<"|"<<dp[i][j][1][l]<<" ";
            }
            cerr<<"    ";
        }
        cerr<<endl;
    }
    Edge p=path[3][2][1][0];*/
    //cerr<<p.dir<<" "<<p.from<<" "<<p.r<<endl;
    if(res==-inf){
        puts("-1");
        return 0;
    }
    write(res),putchar('\n');
    show_path(sx,sy,sl,sr);
	//===========================================================
	return 0;
}


#include <iostream>
#include <map>
#include <ctime>
#include <vector>
#include <climits>
#include <algorithm>
#include <random>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define inf 0x3f3f3f3f
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define rep(i, a, n) for(register int i = a; i <= n; ++ i)
#define per(i, a, n) for(register int i = n; i >= a; -- i)
//#define ONLINE_JUDGE
using namespace std;
typedef long long ll;
const int mod=1e9+7;
template<typename T>void write(T x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
    {
        write(x/10);
    }
    putchar(x%10+'0');
}

template<typename T> void read(T &x)
{
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;};
ll ksm(ll a,ll n){//看是否要mod
	ll ans=1;
	while(n){
		if(n&1) ans=((ans%mod)*(a%mod))%mod;
		a=((a%mod)*(a%mod))%mod;
		n>>=1;
	}
	return ans%mod;
}
//==============================================================
#define int ll
const int maxn=105;
int mp[maxn][maxn],n,m,k;
ll dp[maxn][maxn][2][20];
int vis[maxn][maxn];
struct Edge{
    int dir,from,r;
    Edge(int d=0,int f=0,int rr=0){
        dir=d;
        from=f;
        r=rr;
    }
}path[maxn][maxn][2][20];
int dir[2][2]={-1,-1,-1,1};
void solve(int x,int y){
    if(vis[x][y]) return;
    vis[x][y]=1;
    dp[x][y][0][mp[x][y]%(k+1)]=dp[x][y][1][mp[x][y]%(k+1)]=mp[x][y];
    if(x==1) return ;
    for(int i=0;i<2;i++){
        int dx=x+dir[i][0],dy=y+dir[i][1];
        if(dx<=0||dy<=0||dx>n||dy>m) continue;
        solve(dx,dy);
        int tmp[20];rep(j,0,20-1) tmp[j]=dp[x][y][i][j];
        rep(j,0,k){
            if(max(dp[dx][dy][1][j],dp[dx][dy][0][j])==0) continue;
            rep(l,0,k){
                if(tmp[l]==0) continue;
                if(dp[x][y][i][(j+l)%(k+1)]<=max(dp[dx][dy][1][j],dp[dx][dy][0][j])+tmp[l]){
                    if(dp[dx][dy][1][j]+tmp[l]>=dp[x][y][i][(j+l)%(k+1)]){
                        path[x][y][i][(j+l)%(k+1)]=Edge(i,1,j);
                    }
                    else{
                        path[x][y][i][(j+l)%(k+1)]=Edge(i,0,j);
                    }
                }
                dp[x][y][i][(j+l)%(k+1)]=max(dp[x][y][i][(j+l)%(k+1)],max(dp[dx][dy][1][j],dp[dx][dy][0][j])+tmp[l]);
            }
        }
    }
}
char st[200],top=0;
void show_path(int sx,int sy,int sl,int sr){
    write(sy),putchar('\n');
    while(sx!=1){
        //cerr<<sx<<" "<<sy<<endl;
        Edge now=path[sx][sy][sl][sr];
        sr=now.r;
        if(max(dp[sx-1][sy-1][0][sr],dp[sx-1][sy-1][1][sr])>max(dp[sx-1][sy+1][0][sr],dp[sx-1][sy+1][1][sr])){
            sx=sx-1,sy=sy-1;
            st[++top]='L';
        }
        else{
            sx=sx-1,sy=sy+1;
            st[++top]='R';
        }
        /*if(now.dir==1) st[++top]='R';
        else st[++top]='L';*/
    }
    //cerr<<sx<<" "<<sy<<endl;
    rep(i,1,top){
        putchar(st[i]);
    }
}

signed main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	//===========================================================
    read(n),read(m),read(k);
    rep(i,1,n){
        rep(j,1,m){
            char t;cin>>t;
            mp[i][j]=t-'0';
        }
    }
    rep(i,1,m){
        solve(n,i);
    }
    ll res=0;
    int sx=0,sy=0,sl=0,sr=0;
    rep(i,1,m){
        if(res<=max(dp[n][i][0][0],dp[n][i][1][0])){
            if(dp[n][i][0][0]>=dp[n][i][1][0]){
                sx=n,sy=i,sl=0,sr=0;
            }
            else{
                sx=n,sy=i,sl=1,sr=0;
            }
        }
        res=max(res,max(dp[n][i][0][0],dp[n][i][1][0]));
    }
    /*rep(i,1,n){
        rep(j,1,m){
            rep(l,0,k){
                cerr<<dp[i][j][0][l]<<"|"<<dp[i][j][1][l]<<" ";
            }
            cerr<<"    ";
        }
        cerr<<endl;
    }
    Edge p=path[3][2][1][0];*/
    //cerr<<p.dir<<" "<<p.from<<" "<<p.r<<endl;
    if(res==0){
        puts("-1");
        return 0;
    }
    write(res),putchar('\n');
    show_path(sx,sy,sl,sr);
	//===========================================================
	return 0;
}


#include <iostream>
#include <map>
#include <ctime>
#include <vector>
#include <climits>
#include <algorithm>
#include <random>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define inf 0x3f3f3f3f
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define rep(i, a, n) for(register int i = a; i <= n; ++ i)
#define per(i, a, n) for(register int i = n; i >= a; -- i)
//#define ONLINE_JUDGE
using namespace std;
typedef long long ll;
const int mod=1e9+7;
template<typename T>void write(T x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
    {
        write(x/10);
    }
    putchar(x%10+'0');
}

template<typename T> void read(T &x)
{
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;};
ll ksm(ll a,ll n){//看是否要mod
	ll ans=1;
	while(n){
		if(n&1) ans=((ans%mod)*(a%mod))%mod;
		a=((a%mod)*(a%mod))%mod;
		n>>=1;
	}
	return ans%mod;
}
//==============================================================
#define int ll
const int maxn=105;
int mp[maxn][maxn],n,m,k;
ll dp[maxn][maxn][2][20];
int vis[maxn][maxn];
struct Edge{
    int dir,from,r;
    Edge(int d=0,int f=0,int rr=0){
        dir=d;
        from=f;
        r=rr;
    }
}path[maxn][maxn][2][20];
int dir[2][2]={-1,-1,-1,1};
void solve(int x,int y){
    if(vis[x][y]) return;
    vis[x][y]=1;
    dp[x][y][0][mp[x][y]%(k+1)]=dp[x][y][1][mp[x][y]%(k+1)]=mp[x][y];
    if(x==1) return ;
    for(int i=0;i<2;i++){
        int dx=x+dir[i][0],dy=y+dir[i][1];
        if(dx<=0||dy<=0||dx>n||dy>m) continue;
        solve(dx,dy);
        int tmp[20];rep(j,0,20-1) tmp[j]=dp[x][y][i][j];
        rep(j,0,k){
            //if(max(dp[dx][dy][1][j],dp[dx][dy][0][j])==0) continue;
            rep(l,mp[x][y]%(k+1),k){
                //if(tmp[l]==0) continue;
                if(dp[x][y][i][(j+l)%(k+1)]<=max(dp[dx][dy][1][j],dp[dx][dy][0][j])+tmp[l]){
                    if(dp[dx][dy][1][j]+tmp[l]>=dp[x][y][i][(j+l)%(k+1)]){
                        path[x][y][i][(j+l)%(k+1)]=Edge(i,1,j);
                    }
                    else{
                        path[x][y][i][(j+l)%(k+1)]=Edge(i,0,j);
                    }
                }
                dp[x][y][i][(j+l)%(k+1)]=max(dp[x][y][i][(j+l)%(k+1)],max(dp[dx][dy][1][j],dp[dx][dy][0][j])+tmp[l]);
            }
        }
    }
}
char st[200],top=0;
void show_path(int sx,int sy,int sl,int sr){
    write(sy),putchar('\n');
    while(sx!=1){
        //cerr<<sx<<" "<<sy<<endl;
        Edge now=path[sx][sy][sl][sr];
        sr=now.r;
        if(max(dp[sx-1][sy-1][0][sr],dp[sx-1][sy-1][1][sr])>max(dp[sx-1][sy+1][0][sr],dp[sx-1][sy+1][1][sr])){
            if(dp[sx-1][sy-1][0][sr]>dp[sx-1][sy-1][1][sr]) sl=0;
            else sl=1;
            sx=sx-1,sy=sy-1;
            st[++top]='L';
        }
        else{
            if(dp[sx-1][sy+1][0][sr]>dp[sx-1][sy+1][1][sr]) sl=0;
            else sl=1;
            sx=sx-1,sy=sy+1;
            st[++top]='R';
        }
        /*if(now.dir==1) st[++top]='R';
        else st[++top]='L';*/
    }
    //cerr<<sx<<" "<<sy<<endl;
    rep(i,1,top){
        putchar(st[i]);
    }
}

signed main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	//===========================================================
    read(n),read(m),read(k);
    memset(dp,-inf,sizeof(dp));
    rep(i,1,n){
        rep(j,1,m){
            char t;cin>>t;
            mp[i][j]=t-'0';
        }
    }
    rep(i,1,m){
        solve(n,i);
    }
    ll res=0;
    int sx=0,sy=0,sl=0,sr=0;
    rep(i,1,m){
        if(res<=max(dp[n][i][0][0],dp[n][i][1][0])){
            if(dp[n][i][0][0]>=dp[n][i][1][0]){
                sx=n,sy=i,sl=0,sr=0;
            }
            else{
                sx=n,sy=i,sl=1,sr=0;
            }
        }
        res=max(res,max(dp[n][i][0][0],dp[n][i][1][0]));
    }
    /*rep(i,1,n){
        rep(j,1,m){
            rep(l,0,k){
                cerr<<dp[i][j][0][l]<<"|"<<dp[i][j][1][l]<<" ";
            }
            cerr<<"    ";
        }
        cerr<<endl;
    }
    Edge p=path[3][2][1][0];*/
    //cerr<<p.dir<<" "<<p.from<<" "<<p.r<<endl;
    if(res==-inf){
        puts("-1");
        return 0;
    }
    write(res),putchar('\n');
    show_path(sx,sy,sl,sr);
	//===========================================================
	return 0;
}


#include <iostream>
#include <map>
#include <ctime>
#include <vector>
#include <climits>
#include <algorithm>
#include <random>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define inf 0x3f3f3f3f
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define rep(i, a, n) for(register int i = a; i <= n; ++ i)
#define per(i, a, n) for(register int i = n; i >= a; -- i)
//#define ONLINE_JUDGE
using namespace std;
typedef long long ll;
const int mod=1e9+7;
template<typename T>void write(T x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
    {
        write(x/10);
    }
    putchar(x%10+'0');
}

template<typename T> void read(T &x)
{
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;};
ll ksm(ll a,ll n){//看是否要mod
	ll ans=1;
	while(n){
		if(n&1) ans=((ans%mod)*(a%mod))%mod;
		a=((a%mod)*(a%mod))%mod;
		n>>=1;
	}
	return ans%mod;
}
//==============================================================
#define int ll
const int maxn=105;
int mp[maxn][maxn],n,m,k;
ll dp[maxn][maxn][2][20];
int vis[maxn][maxn];
struct Edge{
    int dir,from,r;
    Edge(int d=0,int f=0,int rr=0){
        dir=d;
        from=f;
        r=rr;
    }
}path[maxn][maxn][2][20];
int dir[2][2]={-1,-1,-1,1};
void solve(int x,int y){
    if(vis[x][y]) return;
    vis[x][y]=1;
    dp[x][y][0][mp[x][y]%(k+1)]=dp[x][y][1][mp[x][y]%(k+1)]=mp[x][y];
    if(x==1) return ;
    for(int i=0;i<2;i++){
        int dx=x+dir[i][0],dy=y+dir[i][1];
        if(dx<=0||dy<=0||dx>n||dy>m) continue;
        solve(dx,dy);
        int tmp[20];rep(j,0,20-1) tmp[j]=dp[x][y][i][j];
        rep(j,0,k){
            //if(max(dp[dx][dy][1][j],dp[dx][dy][0][j])==0) continue;
            rep(l,mp[x][y]%(k+1),k){
                //if(tmp[l]==0) continue;
                if(dp[x][y][i][(j+l)%(k+1)]<=max(dp[dx][dy][1][j],dp[dx][dy][0][j])+tmp[l]){
                    if(dp[dx][dy][1][j]+tmp[l]>=dp[x][y][i][(j+l)%(k+1)]){
                        path[x][y][i][(j+l)%(k+1)]=Edge(i,1,j);
                    }
                    else{
                        path[x][y][i][(j+l)%(k+1)]=Edge(i,0,j);
                    }
                }
                dp[x][y][i][(j+l)%(k+1)]=max(dp[x][y][i][(j+l)%(k+1)],max(dp[dx][dy][1][j],dp[dx][dy][0][j])+tmp[l]);
            }
        }
    }
}
char st[200],top=0;
void show_path(int sx,int sy,int sl,int sr){
    write(sy),putchar('\n');
    while(sx!=1){
        //cerr<<sx<<" "<<sy<<endl;
        Edge now=path[sx][sy][sl][sr];
        sr=now.r;
        if(max(dp[sx-1][sy-1][0][sr],dp[sx-1][sy-1][1][sr])>max(dp[sx-1][sy+1][0][sr],dp[sx-1][sy+1][1][sr])){
            if(dp[sx-1][sy-1][0][sr]>dp[sx-1][sy-1][1][sr]) sl=0;
            else sl=1;
            sx=sx-1,sy=sy-1;
            st[++top]='L';
        }
        else{
            if(dp[sx-1][sy+1][0][sr]>dp[sx-1][sy+1][1][sr]) sl=0;
            else sl=1;
            sx=sx-1,sy=sy+1;
            st[++top]='R';
        }
        /*if(now.dir==1) st[++top]='R';
        else st[++top]='L';*/
    }
    //cerr<<sx<<" "<<sy<<endl;
    rep(i,1,top){
        putchar(st[i]);
    }
}

signed main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	//===========================================================
    read(n),read(m),read(k);
    memset(dp,-inf,sizeof(dp));
    rep(i,1,n){
        rep(j,1,m){
            char t;cin>>t;
            mp[i][j]=t-'0';
        }
    }
    rep(i,1,m){
        solve(n,i);
    }
    ll res=-inf;
    int sx=0,sy=0,sl=0,sr=0;
    rep(i,1,m){
        if(res<=max(dp[n][i][0][0],dp[n][i][1][0])){
            if(dp[n][i][0][0]>=dp[n][i][1][0]){
                sx=n,sy=i,sl=0,sr=0;
            }
            else{
                sx=n,sy=i,sl=1,sr=0;
            }
        }
        res=max(res,max(dp[n][i][0][0],dp[n][i][1][0]));
    }
    /*rep(i,1,n){
        rep(j,1,m){
            rep(l,0,k){
                cerr<<dp[i][j][0][l]<<"|"<<dp[i][j][1][l]<<" ";
            }
            cerr<<"    ";
        }
        cerr<<endl;
    }
    Edge p=path[3][2][1][0];*/
    //cerr<<p.dir<<" "<<p.from<<" "<<p.r<<endl;
    if(res<=0){
        puts("-1");
        return 0;
    }
    write(res),putchar('\n');
    show_path(sx,sy,sl,sr);
	//===========================================================
	return 0;
}