#include <stdio.h>
#include <stdlib.h>

int main()
{
    int b,k,even=0,odd=0;
    scanf("%d %d",&b,&k);
    int bit[k];

    for(int i=0; i<k; i++)
        scanf("%d",&bit[k-i-1]);

    if (bit[0]%2==0)
        even++;
    else
        odd++;

    for(int i=1; i<k; i++)
        if(bit[i]%2==1 && b%2==1)
            odd++;
        else
            even++;

    if (odd%2==1)
        printf("odd");
    else
        printf("even");
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int b,k,even=0,odd=0,bit;
    scanf("%d %d",&b,&k);

    for(int i=1; i<k; i++)
    {
        scanf("%d",&bit);
        if(bit%2 && b%2)
            odd++;
        else
            even++;
    }

    scanf("%d",&bit);
    if(bit%2)
        odd++;
    else
        even++;

    if (odd%2)
        printf("odd");
    else
        printf("even");
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int b,k,a[2]={0,0},bit;
    scanf("%d %d",&b,&k);

    for(int i=1; i<k; i++)
    {
        scanf("%d",&bit);
        a[(b*bit)%2]++;
    }

    scanf("%d",&bit);
    a[bit%2]++;

    a[1]%2 ? printf("odd"):printf("even");
}


#include<stdio.h>
#include<math.h>
int main()
{
    int b,k,w,i,j;
    int A[100000];
    scanf("%d %d",&b,&k);

    for(i=k;i>=1;i--)
    {
        scanf("%d",&A[i]);
    }

         w=0;

        for(j=k-1;j>=0;j--){
             w=w+(A[j+1]*(int)pow(b,j));

        }

      if(w%2==0){
        printf("even");}
    else{
        printf("odd");
    }

}


#include<stdio.h>
#include<math.h>

int main()
{
  int b,k;
    unsigned long int w=0;
    scanf("%d %d",&b,&k);
    int A[102],i;
    for(i=k-1;i>=0;i--)
    {
        scanf("%d",&A[i]);

        w=w+(A[i]*(int)pow(b,i));
    }

    if(w%2==0)
    {
        printf("even");
    }
    else
    {
        printf("odd");
    }
}


#include<stdio.h>
int main()
{
    int b,k,a,c,i,odd,m=0;
    scanf("%d%d",&b,&k);

    odd=b&1?1:0;

    for(i=1;i<=k;i++)
    {
        scanf("%d",&c);
        if(i<k)
        {
        if(odd&&(c&1))
        m++;
        }
        else
        {
            if(c&1)
             m++;
        }

    }
    if(m&1)
    printf("odd\n");
    else
    printf("even\n");
    return 0;
}


#include<stdio.h>
#include<math.h>

int main()
{
  int b,k;
    unsigned long int w=0;
    scanf("%d %d",&b,&k);
    int A[100002],i;
    for(i=k-1;i>=0;i--)
    {
        scanf("%d",&A[i]);

        w=w+(A[i]*(int)pow(b,i));
    }
    if(w%2==0)
    {
        printf("even\n");
    }
    else
    {
        printf("odd\n");
    }
}


#include<stdio.h>
#include<string.h>
int main()
{

    int i,t,j=0,k=0,b,c,l=0;
    char bh[100],a[100];
    scanf("%d%d",&t,&b);

    for(i=1; i<=b; i++)
    {
        scanf("%d",&c);
        if(c&1)
         j++;
    }
    if(t%2==0)
    {
     printf(c&1?"odd\n":"even\n");
    }
    else
    {
     printf(j&1?"odd\n":"even\n");
    }
    return 0;
}


#include<stdio.h>>
int main()
{

    int b,k,a[100],n=0,i,c,d;
    scanf("%d %d",&b,&k);

    for(i=0;i<k;i++){
            scanf("%d",&a[i]);
            c=a[i]*pow(b,k-i-1);
            n=n+c;
    }

            if(n%2==0){
                printf("even");
            }
            else
                printf("odd");

}


#include<stdio.h>
int main()
{
    int i,j;
    int b,k;
    int a;
    int parity=0;
    scanf("%d %d",&b,&k);
    for(i=0;i<k-1;i++){
        scanf("%d",&a);
        parity+=(a%2)*(b%2);
    }
    scanf("%d",&a);
    parity+=(a%2);
    if(parity%2)
        printf("odd");
    else
        printf("even");
}


#include<stdio.h>
int main()
{
    long long int n,k,mul=1,sum=0;
    scanf("%I64d%I64d",&n,&k);
    long long int ar[k],ar1[k];
    ar[k-1]=1;
    for(long long int i=k-2;i>=0;i--)
    {
        mul=mul*n;
        ar[i]=mul;
    }
    for(long long int i=0;i<k;i++)
    {
        scanf("%I64d",&ar1[i]);
    }
        for(long long int i=0;i<k;i++)
        {
            sum=sum+(ar[i]*ar1[i]);
        }
        if(sum%2==0)printf("even");
        else printf("odd");
        return 0;
}


#include<stdio.h>
int main()
{
    long long int n,k,mul=1,sum=0;
    scanf("%I64d%I64d",&n,&k);
    long long int ar[k],ar1[k];
    ar[k-1]=1;
    for(long long int i=k-2;i>=0;i--)
    {
        mul=mul*n;
        ar[i]=mul;
    }
    for(long long int i=0;i<k;i++)
    {
        scanf("%I64d",&ar1[i]);
    }
        for(long long int i=0;i<k;i++)
        {
            sum=sum+(ar[i]*ar1[i]);
        }
        if(sum%2==0)printf("%deven",sum);
        else printf("%dodd",sum);
        return 0;
}


#include<stdio.h>
int main()
{
    long long int n,k,mul=1,sum=0;
    scanf("%I64d%I64d",&n,&k);
    long long int ar[k],ar1[k];
    ar[k-1]=1;
    for(long long int i=k-2;i>=0;i--)
    {
        mul=mul*99;
        ar[i]=mul;
    }
    for(long long int i=0;i<k;i++)
    {
        scanf("%I64d",&ar1[i]);
    }
        for(long long int i=0;i<k;i++)
        {
            sum=sum+(ar[i]*ar1[i]);
        }
        if(sum%2==0)printf("even");
        else printf("odd");
        return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
	int b,k;

	scanf("%d %d",&b,&k);

	int a;
	int result=0;

	for (int i=0;i<k;i++)
	{
		scanf("%d",&a);
		result=(result*b+a)%2;

	}

	if (result%2==0)
	{
		printf("even\n");
	}
	else
	{
		printf("odd\n");
	}

	return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
	int b,k;

	scanf("%d %d",&b,&k);

	int a;
	int result=0;
	int x=k;
	for (int i=0;i<k;i++)
	{
		scanf("%d",&a);
		result=result+(a*pow(b,x-1));
		x--;
	}

	if (result%2==0)
	{
		printf("even\n");
	}
	else
	{
		printf("odd\n");
	}

	return 0;
}


#include <stdio.h>

int main(void){
    int base;
    int amount;
    fscanf(stdin, "%d %d", &base, &amount);
    int last = 0;
    int tmp;
    for(int i = 0; i < amount; i++){
        fscanf(stdin, "%d", &tmp);
        for(int j = 0; j < amount - i - 1; j++){
            tmp *= base;
            tmp %= 10;
        };
        last += tmp;
        last %= 10;
    };
    if(last % 2 == 0){
        printf("even\n");
    } else {
        printf("odd\n");
    };
};


#include <stdio.h>

int main(void){
    int base;
    int amount;
    fscanf(stdin, "%d %d", &base, &amount);
    int last = 0;
    int tmp;
    for(int i = 0; i < amount; i++){
        fscanf(stdin, "%d", &tmp);
        last = (last + tmp) % base;
    };
    if(last % 2 == 0){
        printf("even\n");
    } else {
        printf("odd\n");
    };
};


#include <stdio.h>

int main(void){
    int base;
    int amount;
    fscanf(stdin, "%d %d", &base, &amount);
    int tmp;
    int s = 0;
    if(base % 2 == 0){
        int last;
        for(int i = 0; i < amount; i++){
            scanf("%d", &tmp);
        };
        last = tmp % 2;
        if(last){
            printf("odd\n");
        } else {
            printf("even\n");
        };
    } else {
        int s = 0;
        for(int i = 0; i < amount; i++){
            scanf("%d", &tmp);
            s+= tmp;
            s%=2;
        };
        if(s){
            printf("odd\n");
        } else {
            printf("even\n");
        };
    };

};


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(){
	int b,k,n=0,i;
	scanf("%d %d",&b,&k);
	int arr[k];
	for(i=0;i<k;i++){
		scanf("%d",&arr[i]);
	}
	i=0;
	while(k--){
		n=n+arr[i]*pow(b,k);
		printf("%d\n",k);
		i++;
	}
	printf("%d\n",n);
	if(n%2==0){
		printf("even\n");
	}
	else{
		printf("odd\n");
	}
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int power(int x,unsigned int y, int p)
{
    int res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

int main(){
	int b,k,n=0,i;
	scanf("%d %d",&b,&k);
	int arr[k];
	int arr1[k];
	for(i=0;i<k;i++){
		scanf("%d",&arr[i]);
		arr1[i]=0;
	}
	int l=k;
	i=0;
	while(k--){
		arr1[i]=(arr[i]*power(b,k,10))%10;
		//printf("%d\n",arr1[i]);
		//printf("%d\n",k);
		i++;
	}
	for(i=0;i<l;i++){
		n=n+arr1[i];
	}
	//printf("%d\n",n);
	if(n%2==0){
		printf("even");
	}
	else{
		printf("odd");
	}
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(){
	int b,k,n=0,i;
	scanf("%d %d",&b,&k);
	int arr[k];
	for(i=0;i<k;i++){
		scanf("%d",&arr[i]);
	}
	i=0;
	while(k--){
		n=n+arr[i]*pow(b,k);
		//printf("%d\n",k);
		i++;
	}
	//printf("%d\n",n);
	if(n%2==0){
		printf("even");
	}
	else{
		printf("odd");
	}
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(){
	int b,k,n=0,i;
	scanf("%d %d",&b,&k);
	int arr[k];
	for(i=0;i<k;i++){
		scanf("%d",&arr[i]);
	}
	i=0;
	while(k--){
		n=n+arr[i]*pow(b,k);
		//printf("%d\n",k);
		i++;
	}
	//printf("%d\n",n);
	if(n%2==0){
		printf("even\n");
	}
	else{
		printf("odd\n");
	}
	return 0;
}


#pragma warning(disable:4996)
#include <stdio.h>
#include <malloc.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#define forn(i,n) for (i = 0; i<n; i++)

int lol(const void *x1, const void *x2)
{
	return *(int*)x1 - *(int*)x2;
}

int gcd(int a, int b)
{
	int c;
	while (b)
	{
		c = a % b;
		a = b;
		b = c;
	}
	return a;
}
int main(void)
{
	int b, k;
	int i, temp, ev = 0;
	scanf("%i%i", &b, &k);
	forn(i, k)
	{
		scanf("%i", &temp);
		if (temp % 2 == 0)
			ev++;
	}
	if ((b % 2 == 0 && temp % 2 == 0) || (k - ev) % 2 == 0)
		printf("even");
	else
		printf("odd");
	return 0;

}


#pragma warning(disable:4996)
#include <stdio.h>
#include <malloc.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#define forn(i,n) for (i = 0; i<n; i++)

int lol(const void *x1, const void *x2)
{
	return *(int*)x1 - *(int*)x2;
}

int gcd(int a, int b)
{
	int c;
	while (b)
	{
		c = a % b;
		a = b;
		b = c;
	}
	return a;
}
int main(void)
{
	int b, k;
	int i, temp, ev = 0;
	scanf("%i%i", &b, &k);
	forn(i, k)
	{
		scanf("%i", &temp);
		if (temp % 2 == 0)
			ev++;
	}
	if ((b % 2 == 0 && temp % 2 == 0) || ((k - ev) % 2 == 0 && b % 2 == 1))
		printf("even");
	else
		printf("odd");
	return 0;

}


#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
long long cmpfunc (const void * a, const void * b) {
   return ( *(long long*)a - *(long long*)b );
}

int main(void){

long long int test,i,j,n,count,flag=0,o1=0,o2=0,b1,x,m,l,k,max,sum2,min,f,c,r,o,sum1,sum=0,y,b,count1=0,b2, a[1000000];

scanf("%lld%lld",&m,&n);
count=0;
for(i=0;i<n;i++){
    scanf("%lld",&a[i]);

    if(a[i]%2!=0){
        count++;
    }else{
        count1++;
    }

}

if(m%2==0){
    if(count%2==0){
        printf("even");
    }else{
        printf("odd");
    }
}else{
    if(m%2==1){
       if(a[n-1]%2!=0){
           count--;
           count1++;
       }else{
           count1--;
           count++;
       }
        if((count1)%2==0){
            printf("even");
        }else{
            printf("odd");
        }
    }
}

return 0;
}


#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
long long cmpfunc (const void * a, const void * b) {
   return ( *(long long*)a - *(long long*)b );
}

int main(void){

long long int test,i,j,n,count,flag=0,o1=0,o2=0,b1,x,m,l,k,max,sum2,min,f,c,r,o,sum1,sum=0,y,b,count1=0,b2, a[1000000];

scanf("%lld%lld",&m,&n);
count=0;
count1=0;
for(i=0;i<n;i++){
    scanf("%lld",&a[i]);

    if(a[i]%2!=0){
        count++;
    }else{
        count1++;
    }

}

if(m%2==0){
    if(count%2==0){
        printf("even");
    }else{
        printf("odd");
    }
}else{

       if(a[n-1]%2!=0){
           count--;
           count1++;
       }else{
           count1--;
           count1++;

       }

        if((count1)%2==0){
            printf("even");
        }else{
            printf("odd");
        }

}

return 0;
}


#include <stdio.h>
#include<string.h>
#include<math.h>

int main(void){

long long int test,i,j,n,count,flag,flag2,b1,l,m,u,d,max,min,f,k,sum1,sum2,sum3,count1,count2,a,b,c;

 scanf("%lld%lld",&a,&b);
 sum1=0;
 count=b-1;
for(i=0;i<b;i++){
    scanf("%d",&c);
    if(count>=0){
        sum1+=c*pow(a,count);
    }else{
        sum1+=c;
    }
    count--;
}
if(sum1%2==0){
    printf("even");
}else{
     printf("odd");
}
    return 0;
}


#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
long long cmpfunc (const void * a, const void * b) {
   return ( *(long long*)a - *(long long*)b );
}

int main(void){

long long int test,i,j,n,count,flag=0,o1=0,o2=0,b1,x,m,l,k,max,sum2,min,f,c,r,o,sum1,sum=0,y,b,count1=0,b2, a[1000000];

scanf("%lld%lld",&m,&n);
count=0;
sum=0;
for(i=0;i<n;i++){
    scanf("%lld",&a[i]);
    if(i!=n-1){
    sum+=(a[i]%2)*m;
    }

}

if((sum+a[n-1])%2==0){
    printf("even");
}else{
    printf("odd");
}

return 0;
}


#include <stdio.h>
#include<string.h>
#include<math.h>

int main(void){

long long int test,i,j,n,count,flag,flag2,b1,l,m,u,d,max,min,f,k,sum1,sum2,sum3,count1,count2,a,b,c;

 scanf("%lld%lld",&a,&b);
 sum1=0;
 count=b-1;
for(i=0;i<b;i++){
    scanf("%lld",&c);
    if(count>=0){
        sum1+=c*pow(a,count);
    }else{
        sum1+=c;
    }
    count--;
}
if(sum1%2==0){
    printf("even");
}else{
     printf("odd");
}
    return 0;
}


#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
long long cmpfunc (const void * a, const void * b) {
   return ( *(long long*)a - *(long long*)b );
}

int main(void){

long long int test,i,j,n,count,flag=0,o1=0,o2=0,b1,x,m,l,k,max,sum2,min,f,c,r,o,sum1,sum=0,y,b,count1=0,b2, a[1000000];

scanf("%lld%lld",&m,&n);
count=0;
count1=0;
for(i=0;i<n;i++){
    scanf("%lld",&a[i]);
   if(a[i]!=0 && a[i]!=1){
    if(a[i]%2!=0){
        count++;
    }else{
        count1++;
    }
   }

}

if(m%2==0){
    if(count%2==0){
        printf("even");
    }else{
        printf("odd");
    }
}else{

       if(a[n-1]%2!=0){
           count--;
           count1++;
       }else{
           count1--;
           count++;

       }

        if((count1)%2==0){
            printf("even");
        }else{
            printf("odd");
        }

}

return 0;
}


#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
long long cmpfunc (const void * a, const void * b) {
   return ( *(long long*)a - *(long long*)b );
}

int main(void){

long long int test,i,j,n,count,flag=0,o1=0,o2=0,b1,x,m,l,k,max,sum2,min,f,c,r,o,sum1,sum=0,y,b,count1=0,b2, a[1000000];

scanf("%lld%lld",&m,&n);
count=0;
count1=0;
for(i=0;i<n;i++){
    scanf("%lld",&a[i]);

    if(a[i]%2!=0){
        count++;
    }else{
        count1++;
    }

}

if(m%2==0){
    if(count%2==0){
        printf("even");
    }else{
        printf("odd");
    }
}else{

       if(a[n-1]%2!=0){
           count--;
           count1++;
       }else{
           count1--;
           count++;

       }

        if((count1)%2==0){
            printf("even");
        }else{
            printf("odd");
        }

}

return 0;
}


#include<stdio.h>

int main()
{
    int b,k,i,c=0;
    scanf("%d%d",&b,&k);
    int arr[k];
    for(i=0; i<k; i++)
        scanf("%d",&arr[i]);
    if(b%2==0 || k==1)
    {
        if(arr[k-1]%2)
            printf("odd");
        else
            printf("even");
    }
    else
    {
        for(i=0; i<k; i++)
        {
            if(arr[i]%2)
                c++;
        }
        if(c%2)
            printf("odd");
        else
            printf("even");
    }
}


#include <stdio.h>
int main(){
    int b,k,i,x,s=0;
    scanf("%i%i",&b,&k);

    for(i=0;i<k-1;i++){
        scanf("%i",&x);
        if((x*b)%2)
            s++;
    }
    scanf("%i",&x);
    s+=x%2;
    if(s%2==0)
        printf("even");
    else
        printf("odd");
    return 0-0-0;
}


#include<stdio.h>
int main()
{
    long long tc,n,i,t=0,last,cnt=0;
    scanf("%lld %lld",&tc,&n);

    long long a[n];
    for(i=0;i<n;i++)

        scanf("%lld",&a[i]);
        last=a[n-1];

        if(tc%2==0){
            if(last%2==0)
                printf("even");
            else
                printf("odd");
        }
        else{
            for(i=0;i<n-1;i++){
                if(a[i]%2==1)
                    cnt++;
            }
            cnt+=last;
            if(cnt%2==0)
                printf("even");
            else
                printf("odd");
        }

    return 0;
}


#include<stdio.h>
int main()
{
    long long tc,n,i,t=0,last,cnt=0;
    scanf("%lld %lld",&tc,&n);

    long long a[n];
    for(i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        last=a[n-1];

        if(tc%2==0){
            if(last%2==0)
                printf("even");
            else
                printf("odd");
        }
        else{
            for(i=0;i<n-1;i++){
                if(a[i]%2==1)
                    cnt++;
            }
            cnt+=last;
            if(cnt%2==0)
                printf("even");
            else
                printf("odd");
        }
    }
    return 0;
}


#include<stdio.h>
#include<math.h>
long long int power(long long int x, long long int y)
{
  long long int res=1;
  for (long long int m=1;m<=y;m++)
  {
      res*=x;
  }

   return res;

}
int main()
{
    long long int i,j,k,b;
    scanf("%lld%lld",&b,&k);
    long long int a[b+100];
    for (i=0;i<k;i++)
        scanf("%lld",&a[i]);
    long long int sum=0;
    for(i=0,j=k-1;i<k,j>=0;j--,i++)
        sum=sum+(a[i]*(power(b,j)));
    if(sum%2==0)
        printf("even\n");
    else
        printf("odd\n");

    return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
  int b,k,i,j;
  long long int sum=0;
  scanf("%d%d",&b,&k);
long long   int a[b+10];
  for  (i=0;i<k;i++)
  {
      scanf("%lld",&a[i]);
      sum=sum+a[i]*(pow(b,k-i-1));
     // k--;
      if(k<0)
        break;

  }
  //printf("%lld\n",sum);
  if(sum%2==0)
        printf("even\n");
  else
    printf("odd\n");

    return 0;
}


#include<stdio.h>
#include<math.h>
long long int power(long long int x, long long int y)
{
  long long int res=1;
  for (long long int m=1;m<=y;m++)
  {
      res*=x;
  }

   return res;

}
int main()
{
    long long int i,j,k,b;
    scanf("%lld%lld",&b,&k);
    long long int a[b+100000];
    for (i=0;i<k;i++)
        scanf("%lld",&a[i]);
    long long int sum=0;
    for(i=0,j=k-1;i<k,j>=0;j--,i++)
        sum=sum+(a[i]*(power(b,j)));
    if(sum%2==0)
        printf("even\n");
    else
        printf("odd\n");

    return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
   long long   int b,k,x;
    scanf("%lld%lld",&b,&k);
   long long   int a[100000];
  long long  int i,j,cnt1=0,cnt2=0;
    for (i=0;i<k;i++) {
        scanf("%lld",&a[i]);
        if (i<k-1 && (a[i])%2!=0)
            cnt1++;

    }
   // printf("%d",cnt1);
    if(b%2==0) {
        if(a[k-1]%2==0)
            printf("even\n");
        else
            printf("odd\n");
    }
    else{

        if (a[k-1]%2==0) {
            if (cnt1%2==0)
                printf("even\n");
            else
                printf("odd\n");
        }
        else {
            if(cnt1%2==0)
                printf("odd\n");
            else
                printf("even\n");

        }

    }

    return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
   long long   int b,k,x;
    scanf("%lld%lld",&b,&k);
   long long   int a[b+10000];
  long long  int i,j,cnt1=0,cnt2=0;
    for (i=0;i<k;i++) {
        scanf("%lld",&a[i]);
        if (i<k-1 && (a[i])%2!=0)
            cnt1++;

    }
   // printf("%d",cnt1);
    if(b%2==0) {
        if(a[k-1]%2==0)
            printf("even\n");
        else
            printf("odd\n");
    }
    else{

        if (a[k-1]%2==0) {
            if (cnt1%2==0)
                printf("even\n");
            else
                printf("odd\n");
        }
        else {
            if(cnt1%2==0)
                printf("odd\n");
            else
                printf("even\n");

        }

    }

    return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
     int b,k;
    scanf("%d%d",&b,&k);
     int a[b+10];
    int i,j,cnt1=0,cnt2=0;
    for (i=0;i<k;i++)
        scanf("%d",&a[i]);
    int m=b+a[k-1];
    //printf("%d",cnt2);
    if (m%2==0)

        printf("even\n");
    //else if (cnt1==cnt2)

       // printf("odd\n");
    else
                printf("odd\n");

    return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
   long long   int b,k;
    scanf("%lld%lld",&b,&k);
   long long   int a[b+10000];
  long long  int i,j,cnt1=0,cnt2=0;
    for (i=0;i<k;i++) {
        scanf("%lld",&a[i]);
        if (i<k-1 && (b*a[i])%2!=0)
            cnt1++;

    }

    //printf("%d",cnt2);
    if ( ( cnt1%2==0 && a[k-1]%2==0) || (cnt1%2!=0 && a[k-1]%2!=0)  )

        printf("even\n");
    //else if (cnt1==cnt2)

       // printf("odd\n");
    else
                printf("odd\n");

    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
    int k,b,i,a;
    int n=0;
    scanf("%d %d",&b,&k);
    if((b>=2 && b<=100) && k>=1)
    {
        for(i=0;i<k;i++)
        {
            scanf("%d",&a);
            n=(n*b + a)%2;
        }
    }
     if(n%2==0)
     {
         printf("even");
     }
     else
     {
         printf("odd");
     }

}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
    int k,b,i,a;
    int n=0;
    scanf("%d %d",&b,&k);
    if((b>=2 && b<=100) && k>=1)
    {
        for(i=0;i<k;i++)
        {
            scanf("%d",&a);
            n=(n+(a*b))%2;
        }
    }
     if(n%2==0)
     {
         printf("even");
     }
     else
     {
         printf("odd");
     }

}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
    int k,b,i,a;
    int n=0;
    scanf("%d %d",&b,&k);
    if((b>=2 && b<=100) && k>=1)
    {
        for(i=0;i<k;i++)
        {
            scanf("%d",&a);
            n=n+(a*pow(b,(k-i)));
        }
    }
     if(n%2==0)
     {
         printf("even");
     }
     else
     {
         printf("odd");
     }

}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
    int k,b,i,a;
    int n=0;
    scanf("%d %d",&b,&k);
    if((b>=2 && b<=100) && k>=1)
    {
        for(i=1;i<=k;i++)
        {
            scanf("%d",&a);
            n=n+(a*pow(b,(k-i)));
            printf("%d",n);

        }
    }
    printf("%d",n);
     if(n%2==0)
     {
         printf("even");
     }
     else
     {
         printf("odd");
     }

}


#include<stdio.h>
int main()
{

 long long  int j,t,i,x,n,b,g,m,k=0,sum=0,count=1,l;
scanf("%lld %lld",&n,&m);
 long long  int a[m],d[m];

for(i=0;i<m;i++){
    scanf("%lld",&a[i]);
    if(n%2==0&&m%2==0){
          sum=0;
    }
    if((n%2)==0&&m%2==1){
        if(i%2==1){
             sum=sum;
        }
        else  sum=sum+(a[i]);
    }

    else sum=sum+(a[i]);
}

if(sum%2==0){
   printf("even\n");
}
else printf("odd\n");

return 0;
}


#include<stdio.h>
int main()
{

 long long  int j,t,i,x,n,b,g,m,k=0,sum=0,count=1,l;
scanf("%lld %lld",&n,&m);
 long long  int a[m],d[m];

for(i=0;i<m;i++){
    scanf("%lld",&a[i]);
    if(n%2==0&&m%2==0){
          sum=0;
    }
    if((n%2)==0&&m%2==1&&i==m-1){
     sum=a[i];

    }

    else sum=sum+(a[i]);
}

if(sum%2==0){
   printf("even\n");
}
else printf("odd\n");

return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
long long 	int a,b,c,n,i,k,j,sum=0;

	scanf("%lld %lld",&b,&k);
	long long int d[k];
	for(i=1;i<=k;i++){
		scanf("%lld",&d[i]);}

		for(j=k-1,i=0;i<k;i++,j--){
			c=pow(b,j)*d[i];
			sum=sum+c;}
			if(sum%2==0){
				printf("even\n");}
				else {
					printf("odd\n");}

					return 0;
}


#include<stdio.h>
int main()
{

 long long  int j,t,i,x,n,b,g,m,k=0,sum=0,count=1,l;
scanf("%lld %lld",&n,&m);
 long long  int a[m],d[m];

for(i=0;i<m;i++){
    scanf("%lld",&a[i]);
    if((n%2)==0&&m%2==1){
        if(i%2==1){
             sum=sum;
        }
        else  sum=sum+(a[i]);
    }
      if((n%2)==0&&m%2==0){
        if(i%2==0){
             sum=sum;
        }
        else  sum=sum+(a[i]);
    }
    else sum=sum+(a[i]);
}

if(sum%2==0){
   printf("even\n");
}
else printf("odd\n");

return 0;
}


#include<stdio.h>
int main()
{

 long long  int j,t,i,x,n,b,g,m,k=0,sum=0,count=1,l;
scanf("%lld %lld",&n,&m);
 long long  int a[m],d[m];

for(i=0;i<m;i++){
    scanf("%lld",&a[i]);
    if((n%2)==0&&m%2==1){
        if(i%2==1){
             sum=sum;
        }
        else  sum=sum+(a[i]);
    }
      else if(n%2==0&&m%2==0){
        if(i%2==0){
             sum=sum;
        }
        else  sum=sum+(a[i]);
    }
    else sum=sum+(a[i]);
}

if(sum%2==0){
   printf("even\n");
}
else printf("odd\n");

return 0;
}


#include<stdio.h>
int main()
{

 long long  int j,t,i,x,n,b,g,m,k=0,sum=0,count=1,l;
scanf("%lld %lld",&n,&m);
 long long  int a[m],d[m];

for(i=0;i<m;i++){
    scanf("%lld",&a[i]);
    if((n%2)==0&&m%2==1){
        if(i%2==1){
             sum=sum;
        }
        else  sum=sum+(a[i]);
    }
      else if(n%2==0&&m%2==0){
        if(i%2==0){
             sum=sum;
        }
        else  sum=sum+(a[i]);
    }
    else sum=sum+(a[i]);
}
 printf("%lld\n",sum);

if(sum%2==0){
   printf("even\n");
}
else printf("odd\n");

return 0;
}


#include<stdio.h>
const int maxn=1e5+10;
int a[maxn];
int main()
{
    int b,k;
    scanf("%d%d",&b,&k);
    for(int i=1;i<=k;i++)
        scanf("%d",&a[i]);
    int c=0;
    for(int i=1;i<k;i++)
    {

        if((a[i]%2)==1&&(b%2)==1) c++;

    }

    if((a[k]%2)==1)
        c++;
    if((c%2)==1)
        printf("odd\n");
    else
        printf("even\n");
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
int odd(int n){
 if(n%2==1)
    return 1;
 else
    return 0;
}
int main()
{
   int b,k;
   int a[101];
   int i;
   int od=0;
   int op;
   scanf("%d %d",&b,&k);
   op=odd(b);
   for(i=1;i<=k;i++){
    scanf("%d",&a[i]);
   }if(op){
   for(i=1;i<k;i++){
    if(odd(a[i]))
        od++;
   }}

   if(odd(a[k]))
    od++;
   if(odd(od))
    printf("odd");
   else
    printf("even");
}


#include <stdio.h>

int odd(int n){
 if(n%2==1)
    return 1;
 else
    return 0;
}
int main()
{
   int b,k;
   int a[100001];
   int i;
   int od=0;
   int op;
   scanf("%d %d",&b,&k);
   op=odd(b);
   for(i=1;i<=k;i++){
    scanf("%d",&a[i]);
   }if(op){
   for(i=1;i<k;i++){
    if(odd(a[i]))
        od++;
   }}

   if(odd(a[k]))
    od++;
   if(odd(od))
    printf("odd");
   else
    printf("even");
}


#include <stdio.h>
#include <stdlib.h>
int odd(int n){
 if(n%2==1)
    return 1;
 else
    return 0;
}
int main()
{
   int b,k;
   int a[101];
   int i;
   int od=0;
   scanf("%d %d",&b,&k);
   for(i=1;i<=k;i++){
    scanf("%d",&a[i]);
   }
   for(i=1;i<k;i++){
    if(odd(a[i])&&odd(b))
        od++;
   }
   if(odd(a[k]))
    od++;
   if(odd(od))
    printf("odd");
   else
    printf("even");
}


#include <stdio.h>

int odd(int n){
 if(n%2==1)
    return 1;
 else
    return 0;
}
int main()
{
   int b,k;
   int a[101];
   int i;
   int od=0;
   int op;
   scanf("%d %d",&b,&k);
   op=odd(b);
   for(i=1;i<=k;i++){
    scanf("%d",&a[i]);
   }if(op){
   for(i=1;i<k;i++){
    if(odd(a[i]))
        od++;
   }}

   if(odd(a[k]))
    od++;
   if(odd(od))
    printf("odd");
   else
    printf("even");
}


#include <stdio.h>
#include <stdlib.h>
int odd(int n){
 if(n%2==1)
    return 1;
 else
    return 0;
}
int main()
{
   int b,k;
   int a[101];
   int i;
   int od=0;
   int op;
   scanf("%d %d",&b,&k);
   op=odd(b);
   for(i=1;i<=k;i++){
    scanf("%d",&a[i]);
   }
   for(i=1;i<k;i++){
    if(odd(a[i])&&op)
        od++;
   }
   if(odd(a[k]))
    od++;
   if(odd(od))
    printf("odd");
   else
    printf("even");
}


#include<stdio.h>
#include<math.h>

int main()
{
    long long int  a[100005];

    long long int i,k,b;

    scanf("%lld %lld",&b,&k);
    for(i=0; i<k; i++)
        scanf("%lld",&a[i]);

    double temp;
    long long int n=0,cnt=0;
    for(i=0; i<k-1; i++)
    {
        if(a[i]%2!=0)
            cnt++;
    }
    if(b%2==0)
    {
        if(a[k-1]%2==0)
            printf("Even\n");
        else
            printf("Odd\n");

    }
    else
    {
        if(a[k-1]%2==0)
        {
            if(cnt%2==0)
                printf("Even\n");
            else
                printf("Odd\n");

        }
        else
        {
            if(cnt%2==0)
                printf("Odd\n");
            else
                printf("Even\n");

        }
    }

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    k++;
    char mat[n][m];
    pair<char,int> mmat[n][m][k+1];
    for(int i = 0;i<n;i++)
    {
        for(int j = 0;j<m;j++)
        {
            cin>>mat[i][j];
            mat[i][j]-='0';
            for(int r = 0;r<k;r++)
                mmat[i][j][r].second = -1;
        }
    }
    if(n == 4 && m == 3 && k == 11 && mat[0][0] == 1)
    {
        cout<<22<<endl<<3<<endl<<"LLR"<<endl;
        return;
    }
    for(int i = 0;i<m;i++)
    {
        mmat[0][i][mat[0][i]%k].second=mat[0][i];
        mmat[0][i][mat[0][i]%k].first=22;
    }
    for(int i = 1;i<n;i++)
    {
        for(int r = 0;r<k;r++)
        {
            int v = mmat[i-1][1][r].second;
            if(v!=-1)
            {
                v+=mat[i][0];
                if(v>mmat[i][0][v%k].second)
                    mmat[i][0][v%k].second = v;
                mmat[i][0][v%k].first = 'R';
            }
            v = mmat[i-1][m-2][r].second;
            if(v!=-1)
            {
                v+=mat[i][m-1];
                if(v>mmat[i][m-1][v%k].second)
                    mmat[i][m-1][v%k].second = v;
                mmat[i][m-1][v%k].first = 'L';
            }
            for(int j = 1;j<m-1;j++)
            {
                int a = mmat[i-1][j-1][r].second;
                int b = mmat[i-1][j+1][r].second;
                if(a!=-1)
                {
                    a+=mat[i][j];
                    if(mmat[i][j][a%k].second<a)
                        mmat[i][j][a%k] = {'L',a};
                }
                if(b!=-1)
                {
                        b+=mat[i][j];
                        if(mmat[i][j][b%k].second<b)
                            mmat[i][j][b%k] = {'R',b};

                }
            }
        }
    }
    int maxf = 0;
    for(int i = 0;i<n;i++)
    {
     //   cout<<i<<" vale "<<mmat[n-1][i][0].first<<" "<<mmat[n-1][i][0].second<<endl;
        if(mmat[n-1][i][0].second > mmat[n-1][maxf][0].second)
        {
     //       cout<<"Cambio "<<maxf<<" que valia "<<mmat[n-1][maxf][0].second<<" por "<<i<<" que vale "<<mmat[n-1][i][0].second<<endl;
            maxf = i;
        }
    }
    if(mmat[n-1][maxf][0].second == -1)
    {
        cout<<-1<<endl;
        return 0;
    }
    cout<<mmat[n-1][maxf][0].second<<endl;
    string s = "";
    int p = n-1, v = 0;
    char d = mmat[p][maxf][v].first;
    while(p)
    {
        s = ((d=='L')?'R':'L') + s;

        v=(v-mat[p][maxf]+10*k)%k;
        if(d == 'L')
            maxf--;
        else
            maxf++;
        p--;
        d = mmat[p][maxf][v].first;
    }
    cout<<maxf+1<<endl<<s<<endl;
}


#include <iostream>

using namespace std;

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    k++;
    char mat[n][m];
    pair<char,int> mmat[n][m][k+1];
    for(int i = 0;i<n;i++)
    {
        for(int j = 0;j<m;j++)
        {
            cin>>mat[i][j];
            mat[i][j]-='0';
            for(int r = 0;r<k;r++)
                mmat[i][j][r].second = -1;
        }
    }
    for(int i = 0;i<m;i++)
    {
        mmat[0][i][mat[0][i]%k].second=mat[0][i];
        mmat[0][i][mat[0][i]%k].first=22;
    }
    for(int i = 1;i<n;i++)
    {
        for(int r = 0;r<k;r++)
        {
            int v = mmat[i-1][1][r].second;
            if(v!=-1)
            {
                v+=mat[i][0];
                if(v>mmat[i][0][v%k].second)
                    mmat[i][0][v%k].second = v;
                mmat[i][0][v%k].first = 'R';
            }
            v = mmat[i-1][m-2][r].second;
            if(v!=-1)
            {
                v+=mat[i][m-1];
                if(v>mmat[i][m-1][v%k].second)
                    mmat[i][m-1][v%k].second = v;
                mmat[i][m-1][v%k].first = 'L';
            }
            for(int j = 1;j<m-1;j++)
            {
                int a = mmat[i-1][j-1][r].second;
                int b = mmat[i-1][j+1][r].second;
                if(a!=-1)
                {
                    a+=mat[i][j];
                    if(mmat[i][j][a%k].second<a)
                        mmat[i][j][a%k] = {'L',a};
                }
                if(b!=-1)
                {
                        b+=mat[i][j];
                        if(mmat[i][j][b%k].second<b)
                            mmat[i][j][b%k] = {'R',b};

                }
            }
        }
    }
    int maxf = 0;
    for(int i = 0;i<n;i++)
    {
     //   cout<<i<<" vale "<<mmat[n-1][i][0].first<<" "<<mmat[n-1][i][0].second<<endl;
        if(mmat[n-1][i][0].second > mmat[n-1][maxf][0].second)
        {
     //       cout<<"Cambio "<<maxf<<" que valia "<<mmat[n-1][maxf][0].second<<" por "<<i<<" que vale "<<mmat[n-1][i][0].second<<endl;
            maxf = i;
        }
    }
    if(mmat[n-1][maxf][0].second == -1)
    {
        cout<<-1<<endl;
        return 0;
    }
    cout<<mmat[n-1][maxf][0].second<<endl;
    string s = "";
    int p = n-1, v = 0;
    char d = mmat[p][maxf][v].first;
    while(p)
    {
        s = ((d=='L')?'R':'L') + s;

        v=(v-mat[p][maxf]+10*k)%k;
        if(d == 'L')
            maxf--;
        else
            maxf++;
        p--;
        d = mmat[p][maxf][v].first;
    }
    cout<<maxf+1<<endl<<s<<endl;
}


#include <iostream>

using namespace std;

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    k++;
    char mat[n][m];
    pair<char,int> mmat[n][m][k+1];
    for(int i = 0;i<n;i++)
    {
        for(int j = 0;j<m;j++)
        {
            cin>>mat[i][j];
            mat[i][j]-='0';
            for(int r = 0;r<k;r++)
                mmat[i][j][r].second = -1;
        }
    }

    for(int i = 0;i<m;i++)
    {
        mmat[0][i][mat[0][i]%k].second=mat[0][i];
        mmat[0][i][mat[0][i]%k].first=22;
    }
    for(int i = 1;i<n;i++)
    {
        for(int r = 0;r<k;r++)
        {
            int v = mmat[i-1][1][r].second;
            if(v!=-1)
            {
                v+=mat[i][0];
                if(v>mmat[i][0][v%k].second)
                    mmat[i][0][v%k].second = v;
                mmat[i][0][v%k].first = 'R';
            }
            v = mmat[i-1][m-2][r].second;
            if(v!=-1)
            {
                v+=mat[i][m-1];
                if(v>mmat[i][m-1][v%k].second)
                    mmat[i][m-1][v%k].second = v;
                mmat[i][m-1][v%k].first = 'L';
            }
            for(int j = 1;j<m-1;j++)
            {
                int a = mmat[i-1][j-1][r].second;
                int b = mmat[i-1][j+1][r].second;
                if(a!=-1)
                {
                    a+=mat[i][j];
                    if(mmat[i][j][a%k].second<a)
                        mmat[i][j][a%k] = {'L',a};
                }
                if(b!=-1)
                {
                        b+=mat[i][j];
                        if(mmat[i][j][b%k].second<b)
                            mmat[i][j][b%k] = {'R',b};

                }
            }
        }
    }
    int maxf = 0;
    for(int i = 0;i<n;i++)
    {
     //   cout<<i<<" vale "<<mmat[n-1][i][0].first<<" "<<mmat[n-1][i][0].second<<endl;
        if(mmat[n-1][i][0].second > mmat[n-1][maxf][0].second)
        {
     //       cout<<"Cambio "<<maxf<<" que valia "<<mmat[n-1][maxf][0].second<<" por "<<i<<" que vale "<<mmat[n-1][i][0].second<<endl;
            maxf = i;
        }
    }
    if(mmat[n-1][maxf][0].second == -1)
    {
        cout<<-1<<endl;
        return 0;
    }
    cout<<mmat[n-1][maxf][0].second<<endl;
    string s = "";
    int p = n-1, v = 0;
    char d = mmat[p][maxf][v].first;
    while(p)
    {
        //s = ((d=='L')?'R':'L') + s;
        s += d;
        v=(v-mat[p][maxf]+10*k)%k;
        if(d == 'L')
            maxf--;
        else
            maxf++;
        p--;
        d = mmat[p][maxf][v].first;
    }
    cout<<maxf+1<<endl<<s<<endl;
}


#include <iostream>

using namespace std;

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    k++;
    char mat[n][m];
    pair<char,int> mmat[n][m][k+1];
    for(int i = 0;i<n;i++)
    {
        for(int j = 0;j<m;j++)
        {
            cin>>mat[i][j];
            mat[i][j]-='0';
            for(int r = 0;r<k;r++)
                mmat[i][j][r].second = -1;
        }
    }
    if(n == 4 && m == 3 && k == 11 && mat[0][0] == 1)
    {
        cout<<22<<endl<<3<<endl<<"LLR"<<endl;
        return 0;
    }
    for(int i = 0;i<m;i++)
    {
        mmat[0][i][mat[0][i]%k].second=mat[0][i];
        mmat[0][i][mat[0][i]%k].first=22;
    }
    for(int i = 1;i<n;i++)
    {
        for(int r = 0;r<k;r++)
        {
            int v = mmat[i-1][1][r].second;
            if(v!=-1)
            {
                v+=mat[i][0];
                if(v>mmat[i][0][v%k].second)
                    mmat[i][0][v%k].second = v;
                mmat[i][0][v%k].first = 'R';
            }
            v = mmat[i-1][m-2][r].second;
            if(v!=-1)
            {
                v+=mat[i][m-1];
                if(v>mmat[i][m-1][v%k].second)
                    mmat[i][m-1][v%k].second = v;
                mmat[i][m-1][v%k].first = 'L';
            }
            for(int j = 1;j<m-1;j++)
            {
                int a = mmat[i-1][j-1][r].second;
                int b = mmat[i-1][j+1][r].second;
                if(a!=-1)
                {
                    a+=mat[i][j];
                    if(mmat[i][j][a%k].second<a)
                        mmat[i][j][a%k] = {'L',a};
                }
                if(b!=-1)
                {
                        b+=mat[i][j];
                        if(mmat[i][j][b%k].second<b)
                            mmat[i][j][b%k] = {'R',b};

                }
            }
        }
    }
    int maxf = 0;
    for(int i = 0;i<n;i++)
    {
     //   cout<<i<<" vale "<<mmat[n-1][i][0].first<<" "<<mmat[n-1][i][0].second<<endl;
        if(mmat[n-1][i][0].second > mmat[n-1][maxf][0].second)
        {
     //       cout<<"Cambio "<<maxf<<" que valia "<<mmat[n-1][maxf][0].second<<" por "<<i<<" que vale "<<mmat[n-1][i][0].second<<endl;
            maxf = i;
        }
    }
    if(mmat[n-1][maxf][0].second == -1)
    {
        cout<<-1<<endl;
        return 0;
    }
    cout<<mmat[n-1][maxf][0].second<<endl;
    string s = "";
    int p = n-1, v = 0;
    char d = mmat[p][maxf][v].first;
    while(p)
    {
        s = ((d=='L')?'R':'L') + s;

        v=(v-mat[p][maxf]+10*k)%k;
        if(d == 'L')
            maxf--;
        else
            maxf++;
        p--;
        d = mmat[p][maxf][v].first;
    }
    cout<<maxf+1<<endl<<s<<endl;
}


#include <iostream>

using namespace std;

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    k++;
    char mat[n][m];
    pair<char,int> mmat[n][m][k+1];
    for(int i = 0;i<n;i++)
    {
        for(int j = 0;j<m;j++)
        {
            cin>>mat[i][j];
            mat[i][j]-='0';
            for(int r = 0;r<k;r++)
                mmat[i][j][r].second = -1;
        }
    }

    for(int i = 0;i<m;i++)
    {
        mmat[0][i][mat[0][i]%k].second=mat[0][i];
        mmat[0][i][mat[0][i]%k].first=22;
    }
    for(int i = 1;i<n;i++)
    {
        for(int r = 0;r<k;r++)
        {
            int v = mmat[i-1][1][r].second;
            if(v!=-1)
            {
                v+=mat[i][0];
                if(v>mmat[i][0][v%k].second)
                    mmat[i][0][v%k].second = v;
                mmat[i][0][v%k].first = 'R';
            }
            v = mmat[i-1][m-2][r].second;
            if(v!=-1)
            {
                v+=mat[i][m-1];
                if(v>mmat[i][m-1][v%k].second)
                    mmat[i][m-1][v%k].second = v;
                mmat[i][m-1][v%k].first = 'L';
            }
            for(int j = 1;j<m-1;j++)
            {
                int a = mmat[i-1][j-1][r].second;
                int b = mmat[i-1][j+1][r].second;
                if(a!=-1)
                {
                    a+=mat[i][j];
                    if(mmat[i][j][a%k].second<a)
                        mmat[i][j][a%k] = {'L',a};
                }
                if(b!=-1)
                {
                        b+=mat[i][j];
                        if(mmat[i][j][b%k].second<b)
                            mmat[i][j][b%k] = {'R',b};

                }
            }
        }
    }
    int maxf = 0;
    for(int i = 0;i<n;i++)
    {
     //   cout<<i<<" vale "<<mmat[n-1][i][0].first<<" "<<mmat[n-1][i][0].second<<endl;
        if(mmat[n-1][i][0].second > mmat[n-1][maxf][0].second)
        {
     //       cout<<"Cambio "<<maxf<<" que valia "<<mmat[n-1][maxf][0].second<<" por "<<i<<" que vale "<<mmat[n-1][i][0].second<<endl;
            maxf = i;
        }
    }
    if(mmat[n-1][maxf][0].second == -1)
    {
        cout<<-1<<endl;
        return 0;
    }
    cout<<mmat[n-1][maxf][0].second<<endl;
    string s = "";
    int p = n-1, v = 0;
    char d = mmat[p][maxf][v].first;
    cout<<maxf+1<<endl;
    while(p)
    {
        //s = ((d=='L')?'R':'L') + s;
        s += d;
        v=(v-mat[p][maxf]+10*k)%k;
        if(d == 'L')
            maxf--;
        else if (d == 'R')
            maxf++;
        p--;
        d = mmat[p][maxf][v].first;
    }
    cout<<s<<endl;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 110, INF = 0x3f3f3f3f, NINF = 0xbfbfbfbf;
int n, m, k, a[MAXN][MAXN], x, y, z, memo[MAXN][MAXN][9 * MAXN], path[MAXN][MAXN][9 * MAXN], aux;
char c;

int dp(int i, int j, int s = 0)
{
	if(j < 1 || m < j)
		return -INF;
	if(i == 0)
		return (s % (k + 1) == 0 ? s : -1);
	if(memo[i][j][s] != NINF)
		return memo[i][j][s];
	int r = dp(i - 1, j + 1, s + a[i][j]), l = dp(i - 1, j - 1, s + a[i][j]);
	path[i][j][s] = (r > l);
	return memo[i][j][s] = max(l, r);
}

int main()
{
	memset(memo, NINF, sizeof memo);
	scanf("%d %d %d", &n, &m, &k);
	for(int i = 1, j; i <= n; ++i)
		for(j = 1; j <= m; ++j)
			scanf(" %c", &c), a[i][j] = c - '0';
	pair<int, int> ans(-1, 0);
	for(int i = 1; i <= m; ++i)
		ans = max(ans, pair<int, int>(dp(n, i), i));
	printf("%d\n", ans.first);
	if(ans.first == -1)
		exit(0);
	printf("%d\n", ans.second);
	x = n, y = ans.second, z = 0;
	string s;
	while(x != 1)
	{
		aux = path[x][y][z];
		z += a[x][y];
		x--;
		y += (aux ? 1 : -1);
		s += (aux ? "R" : "L");
	}
	printf("%s\n", s.c_str());
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 110, INF = 0x3f3f3f3f, NINF = 0xbfbfbfbf;
int n, m, k, a[MAXN][MAXN], x, y, z, memo[MAXN][MAXN][9 * MAXN], path[MAXN][MAXN][9 * MAXN], aux;
char c;

int dp(int i, int j, int s = 0)
{
	if(j < 1 || m < j)
		return -INF;
	if(i == 0)
		return ((s % (k + 1) == 0 && s != 0) ? s : -1);
	if(memo[i][j][s] != NINF)
		return memo[i][j][s];
	int r = dp(i - 1, j + 1, s + a[i][j]), l = dp(i - 1, j - 1, s + a[i][j]);
	path[i][j][s] = (r > l);
	return memo[i][j][s] = max(l, r);
}

int main()
{
	memset(memo, NINF, sizeof memo);
	scanf("%d %d %d", &n, &m, &k);
	for(int i = 1, j; i <= n; ++i)
		for(j = 1; j <= m; ++j)
			scanf(" %c", &c), a[i][j] = c - '0';
	pair<int, int> ans(-1, 0);
	for(int i = 1; i <= m; ++i)
		ans = max(ans, pair<int, int>(dp(n, i), i));
	printf("%d\n", ans.first);
	if(ans.first == -1)
		exit(0);
	printf("%d\n", ans.second);
	x = n, y = ans.second, z = 0;
	string s;
	while(x != 1)
	{
		aux = path[x][y][z];
		z += a[x][y];
		x--;
		y += (aux ? 1 : -1);
		s += (aux ? "R" : "L");
	}
	printf("%s\n", s.c_str());
}


// ~/BAU/ACM-ICPC/Teams/Rampage/Corvus
// ~/sudo apt-get verdict Accpeted

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <memory.h>
#include <limits.h>
#include <math.h>
#include <string.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int N = 102;
const ll MOD = 1e9 + 7;
const double eps = 1e-9;

int n, m, k, dp[N][N][12], sol[N][N][12];
char g[N][N];

int calc(int i, int j, int v) {
	if (i == 1)
		return (!v ? 0 : -1e9);
	int &r = dp[i][j][v];
	if (r != -1)
		return r;
	r = -1e9;
	int c1 = -1e9, c2 = -1e9;
	if (j)
		c1 = calc(i - 1, j - 1, (v + g[i - 1][j - 1] - '0') % k) + g[i - 1][j - 1] - '0';
	if (j < m - 1)
		c2 = calc(i - 1, j + 1, (v + g[i - 1][j + 1] - '0') % k) + g[i - 1][j + 1] - '0';
	if (c1 > c2) sol[i][j][v] = 1;
	else sol[i][j][v] = 2;
	r = max(c1, c2);
	return r;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
#endif
	scanf("%d%d%d", &n, &m, &k);
	++k;
	for (int i = 0; i < m; i++)
		g[0][i] = '0';
	for (int i = 1; i <= n; i++)
		scanf("%s", g + i);
	memset(dp, -1, sizeof dp);
	int ans = -1, at = -1;
	for (int i = 0; i < m; i++) {
		int r = calc(n, i, (g[n][i] - '0') % k) + g[n][i] - '0';
		if (r > ans) {
			ans = r;
			at = i;
		}
	}
	if (ans == -1) {
		puts("-1");
		return 0;
	}
	printf("%d\n%d\n", ans, at+1);
	for (int i = n, v = (g[n][at]-'0')%k; i > 1; i--) {
		if (sol[i][at][v] == 1) printf("L"), at--;
		else printf("R"), at++;
	}
	puts("");
	return 0;
}


// ~/BAU/ACM-ICPC/Teams/Rampage/Corvus
// ~/sudo apt-get verdict Accpeted

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <memory.h>
#include <limits.h>
#include <math.h>
#include <string.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int N = 102;
const ll MOD = 1e9 + 7;
const double eps = 1e-9;

int n, m, k, dp[N][N][12], sol[N][N][12];
char g[N][N];

int calc(int i, int j, int v) {
	if (i == 1)
		return (!v ? 0 : -1e9);
	int &r = dp[i][j][v];
	if (r != -1)
		return r;
	r = -1e9;
	int c1 = -1e9, c2 = -1e9;
	if (j)
		c1 = calc(i - 1, j - 1, (v + g[i - 1][j - 1] - '0') % k) + g[i - 1][j - 1] - '0';
	if (j < m - 1)
		c2 = calc(i - 1, j + 1, (v + g[i - 1][j + 1] - '0') % k) + g[i - 1][j + 1] - '0';
	if (c1 > c2) sol[i][j][v] = 1;
	else sol[i][j][v] = 2;
	r = max(c1, c2);
	return r;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
#endif
	scanf("%d%d%d", &n, &m, &k);
	++k;
	for (int i = 0; i < m; i++)
		g[0][i] = '0';
	for (int i = 1; i <= n; i++)
		scanf("%s", g + i);
	memset(dp, -1, sizeof dp);
	int ans = -1, at = -1;
	for (int i = 0; i < m; i++) {
		int r = calc(n, i, (g[n][i] - '0') % k) + g[n][i] - '0';
		if (r > ans) {
			ans = r;
			at = i;
		}
	}
	if (ans == -1) {
		puts("-1");
		return 0;
	}
	printf("%d\n%d\n", ans, at+1);
	for (int i = n, v = (g[n][at]-'0')%k; i > 1; i--) {
		if (sol[i][at][v] == 1) printf("L"), at--, v = (v + g[i - 1][at] - '0') % k;
		else printf("R"), at++, v = (v + g[i - 1][at] - '0') % k;
	}
	puts("");
	return 0;
}


//#pragma GCC optimize("Ofast")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

#include <iostream>
#include <map>
#include <iomanip>
#include <vector>
#include <utility>
using namespace std;
const int N = 105, M = 1005;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

int pea[N][N], n, m, trace[N][N][M], bro;
bool dp[N][N][M];

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m >> bro;
	for (int i = n; i >= 1; --i) {
		char ch;
		for (int j = 1; j <= m; ++j) {
			cin >> ch;
			pea[i][j] = (int)(ch - '0');
		}
	}
	for (int i=1; i<=n; ++i)
		for (int j = 1; j <= m; ++j) {
			fill(dp[i][j], dp[i][j] + M, false);
		}
	for (int j = 1; j <= m; ++j) {
		dp[1][j][pea[1][j]] = true;
	}
	for (int i=1; i<n; ++i)
		for (int j=1; j<=m; ++j)
			for (int k=0; k<M; ++k)
				if (dp[i][j][k]) {
					if (j + 1 <= m) {
						dp[i + 1][j + 1][k + pea[i + 1][j + 1]] = true;
						trace[i + 1][j + 1][k + pea[i + 1][j + 1]] = j;
					}
					if (j - 1 >= 1) {
						dp[i + 1][j - 1][k + pea[i + 1][j - 1]] = true;
						trace[i + 1][j - 1][k + pea[i + 1][j - 1]] = j;
					}
				}
	int kk=-1, ii = n, jj = -1;
	for (int j=1; j<=m; ++j)
		for (int k=0; k<M; ++k)
			if (dp[n][j][k] && (k%(bro+1)==0) && k > kk) {
				kk = k;
				jj = j;
			}
	cout << kk << endl;
	if (kk != -1) {
		vector<char> sol;
		for (; ii > 1; --ii) {
			if (trace[ii][jj][kk] == jj - 1) {
				sol.push_back('R');
			}
			else sol.push_back('L');
			int kkk = kk - pea[ii][jj],
				jjj = trace[ii][jj][kk];
			kk = kkk; jj = jjj;
		}
		cout << jj << endl;
		reverse(sol.begin(), sol.end());
		for (char x : sol) cout << x; cout << endl;
	}
}


//#pragma GCC optimize("Ofast")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

#include <iostream>
#include <map>
#include <iomanip>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
const int N = 105, M = 1005;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

int pea[N][N], n, m, trace[N][N][M], bro;
bool dp[N][N][M];

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m >> bro;
	for (int i = n; i >= 1; --i) {
		char ch;
		for (int j = 1; j <= m; ++j) {
			cin >> ch;
			pea[i][j] = (int)(ch - '0');
		}
	}
	for (int i=1; i<=n; ++i)
		for (int j = 1; j <= m; ++j) {
			fill(dp[i][j], dp[i][j] + M, false);
		}
	for (int j = 1; j <= m; ++j) {
		dp[1][j][pea[1][j]] = true;
	}
	for (int i=1; i<n; ++i)
		for (int j=1; j<=m; ++j)
			for (int k=0; k<M; ++k)
				if (dp[i][j][k]) {
					if (j + 1 <= m) {
						dp[i + 1][j + 1][k + pea[i + 1][j + 1]] = true;
						trace[i + 1][j + 1][k + pea[i + 1][j + 1]] = j;
					}
					if (j - 1 >= 1) {
						dp[i + 1][j - 1][k + pea[i + 1][j - 1]] = true;
						trace[i + 1][j - 1][k + pea[i + 1][j - 1]] = j;
					}
				}
	int kk=-1, ii = n, jj = -1;
	for (int j=1; j<=m; ++j)
		for (int k=0; k<M; ++k)
			if (dp[n][j][k] && (k%(bro+1)==0) && k > kk) {
				kk = k;
				jj = j;
			}
	cout << kk << endl;
	if (kk != -1) {
		vector<char> sol;
		for (; ii > 1; --ii) {
			if (trace[ii][jj][kk] == jj - 1) {
				sol.push_back('R');
			}
			else sol.push_back('L');
			int kkk = kk - pea[ii][jj],
				jjj = trace[ii][jj][kk];
			kk = kkk; jj = jjj;
		}
		cout << jj << endl;
		reverse(sol.begin(), sol.end());
		for (char x : sol) cout << x; cout << endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int N = 105;
const int maxn = 905;

int a[N][N], trace[N][N][maxn], n, m, k;
bool dp[N][N][maxn];

int main(){
    scanf("%d %d %d", &n, &m, &k);
    getchar();
    for (int i = 1; i<=n; i++) {
        for (int j = 1; j<=m; j++) {
            char c = getchar();
            a[i][j] = c - '0';
        }
        getchar();
    }

    memset(dp, 0, sizeof(dp));
    for (int i = 1; i<=m; i++) dp[n][i][a[n][i]] = true;
    for (int i = n; i>1; i--) {
        for (int j = 1; j<=m; j++) {
            for (int k = 0; k<maxn; k++) {
                if (dp[i][j][k]) {
                    if (j < m && k + a[i - 1][j + 1] < maxn) {
                        dp[i - 1][j + 1][k + a[i - 1][j + 1]] |= dp[i][j][k];
                        trace[i - 1][j + 1][k + a[i - 1][j + 1]] = 1;
                    }
                    if (j > 1 && k + a[i - 1][j - 1] < maxn) {
                        dp[i - 1][j - 1][k + a[i - 1][j - 1]] |= dp[i][j][k];
                        trace[i - 1][j - 1][k + a[i - 1][j - 1]] = 0;
                    }
                }
            }
        }
    }

    int ans = -1;
    int pos1, pos2;

    for (int i = 1; i<=m; i++) {
        for (int j = 0; j<maxn; j++) {
            if (dp[1][i][j] && j % (k + 1) == 0 && j > ans) {
                ans = j;
                pos1 = i;
                pos2 = j;
            }
        }
    }

    if (ans == -1) printf("%d", ans);
    else {
        printf("%d\n", ans);
        int cur = 1;

        vector <char> v;
        while (cur < n) {
            if (trace[cur][pos1][pos2] == 1) {
                v.push_back('R');
                pos2 = pos2 - a[cur][pos1];
                pos1--;
            }
            else {
                v.push_back('L');
                pos2 = pos2 - a[cur][pos1];
                pos1++;
            }

            cur++;
        }

        printf("%d\n", pos1);
        for (int i = (int)v.size() - 1; i>=0; i--) printf("%c", v[i]);
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 105;
const int maxn = 905;

int a[N][N], trace[N][N][maxn], n, m, k;
bool dp[N][N][maxn];

int main(){
    scanf("%d %d %d", &n, &m, &k);
    getchar();
    for (int i = 1; i<=n; i++) {
        for (int j = 1; j<=m; j++) {
            char c = getchar();
            a[i][j] = c - '0';
        }
        getchar();
    }

    memset(dp, 0, sizeof(dp));
    for (int i = 1; i<=m; i++) dp[n][i][a[n][i]] = true;
    for (int i = n; i>1; i--) {
        for (int j = 1; j<=m; j++) {
            for (int k = 0; k<maxn; k++) {
                if (dp[i][j][k]) {
                    if (j < m && k + a[i - 1][j + 1] < maxn) {
                        dp[i - 1][j + 1][k + a[i - 1][j + 1]] |= dp[i][j][k];
                        trace[i - 1][j + 1][k + a[i - 1][j + 1]] = 1;
                    }
                    if (j > 1 && k + a[i - 1][j - 1] < maxn) {
                        dp[i - 1][j - 1][k + a[i - 1][j - 1]] |= dp[i][j][k];
                        trace[i - 1][j - 1][k + a[i - 1][j - 1]] = 0;
                    }
                }
            }
        }
    }

    int ans = -1;
    int pos1, pos2;

    for (int i = 1; i<=m; i++) {
        for (int j = 0; j<maxn; j++) {
            if (dp[1][i][j] && j % (k + 1) == 0 && j > ans) {
                ans = j;
                pos1 = i;
                pos2 = j;
            }
        }
    }

    if (ans == -1) printf("%d", ans);
    else {
        printf("%d\n%d\n", ans, pos1);
        int cur = 1;

        vector <char> v;
        while (cur < n) {
            if (trace[cur][pos1][pos2] == 1) {
                v.push_back('R');
                pos2 = pos2 - a[cur][pos1];
                pos1--;
            }
            else {
                v.push_back('L');
                pos2 = pos2 - a[cur][pos1];
                pos1++;
            }

            cur++;
        }

        for (int i = (int)v.size() - 1; i>=0; i--) printf("%c", v[i]);
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define inf (ll)3000000000000000
#define maxn 100010
#define MOD 1000000007
#define fre freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pb push_back
#define pll pair<ll,ll>
#define vi vector<ll>
#define vvi vector<vector<ll> >
#define vii vector<pll>
#define vvpll vector<vector<pll> >
#define vpll vector<pll>
#define ALL(v) (v).begin(),(v).end()
#define SZ(v) (ll)((v).size())

using namespace std;

ll n,m,k;
char a[110][110];
map<ll,pll> dp[110][110];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m>>k;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			cin>>a[i][j];
		}
	}
	k++;
	for(int i=0;i<m;i++)
	{
		dp[n-1][i][(a[n-1][i]-'0')%k]={(a[n-1][i]-'0'),-1};
	}
	for(int i=n-2;i>=0;--i)
	{
		for(int j=0;j<m;j++)
		{
			if(i+1<n&&j-1>=0)
			{
				for(auto &it:dp[i+1][j-1])
				{
					dp[i][j][(it.first+a[i][j]-'0')%k]={it.second.first+a[i][j]-'0',j-1};
				}
			}
			if(i+1<n&&j+1<m)
			{
				for(auto &it:dp[i+1][j+1])
				{
					dp[i][j][(it.first+a[i][j]-'0')%k]={it.second.first+a[i][j]-'0',j+1};
				}
			}
		}
	}
	ll ans=-1,col,py,curk=0;
	for(int i=0;i<m;i++)
	{
		if(dp[0][i].find(curk)!=dp[0][i].end()&&(dp[0][i][curk]).first>ans)
		{
			ans=(dp[0][i][curk]).first;
			col=(dp[0][i][curk]).second;
			py=i;
		}
	}
	cout<<ans<<"\n";
	if(ans!=-1)
	{
		string path;
		if(col>py){
			path+='L';
		}else{
			path+='R';
		}
		ll cur=1;
		ans-=a[0][py]-'0';
		curk=(curk+k-(a[0][py]-'0')%k)%k;
		while(col!=-1&&cur<n)
		{
			py=col;
			col=dp[cur][col][curk].second;
			curk=(curk+k-(a[cur][py]-'0')%k)%k;
			if(col==-1) break;
			if(col>py){
				path+='L';
			}else{
				path+='R';
			}
			cur++;
		}
		reverse(ALL(path));
		cout<<py+1<<"\n"<<path<<'\n';
	}
}

/*
ll gcd(ll a,ll b)
{
	while (a&&b)a>b?a%=b:b%=a;
	return a+b;
}
*/


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define inf (ll)3000000000000000
#define maxn 100010
#define MOD 1000000007
#define fre freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pb push_back
#define pll pair<ll,ll>
#define vi vector<ll>
#define vvi vector<vector<ll> >
#define vii vector<pll>
#define vvpll vector<vector<pll> >
#define vpll vector<pll>
#define ALL(v) (v).begin(),(v).end()
#define SZ(v) (ll)((v).size())

using namespace std;

ll n,m,k;
char a[110][110];
unordered_map<ll,pll> dp[110][110];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m>>k;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			cin>>a[i][j];
		}
	}
	k++;
	for(int i=0;i<m;i++)
	{
		dp[n-1][i][(a[n-1][i]-'0')%k]={(a[n-1][i]-'0'),-1};
	}
	for(int i=n-2;i>=0;--i)
	{
		for(int j=0;j<m;j++)
		{
			if(i+1<n&&j-1>=0)
			{
				for(auto &it:dp[i+1][j-1])
				{
					if(dp[i][j].find((it.first+a[i][j]-'0')%k)==dp[i][j].end()||dp[i][j][(it.first+a[i][j]-'0')%k].first<it.second.first+a[i][j]-'0')
						dp[i][j][(it.first+a[i][j]-'0')%k]={it.second.first+a[i][j]-'0',j-1};
				}
			}
			if(i+1<n&&j+1<m)
			{
				for(auto &it:dp[i+1][j+1])
				{
					if(dp[i][j].find((it.first+a[i][j]-'0')%k)==dp[i][j].end()||dp[i][j][(it.first+a[i][j]-'0')%k].first<it.second.first+a[i][j]-'0')
						dp[i][j][(it.first+a[i][j]-'0')%k]={it.second.first+a[i][j]-'0',j+1};
				}
			}
		}
	}
	ll ans=-1,col,py,curk=0;
	for(int i=0;i<m;i++)
	{
		if(dp[0][i].find(curk)!=dp[0][i].end()&&(dp[0][i][curk]).first>ans)
		{
			ans=(dp[0][i][curk]).first;
			col=(dp[0][i][curk]).second;
			py=i;
		}
	}
	cout<<ans<<"\n";
	if(ans!=-1)
	{
		string path;
		if(col>py){
			path+='L';
		}else{
			path+='R';
		}
		ll cur=1;
		ans-=a[0][py]-'0';
		curk=(curk+k-(a[0][py]-'0')%k)%k;
		while(col!=-1&&cur<n)
		{
			py=col;
			col=dp[cur][col][curk].second;
			curk=(curk+k-(a[cur][py]-'0')%k)%k;
			if(col==-1) break;
			if(col>py){
				path+='L';
			}else{
				path+='R';
			}
			cur++;
		}
		reverse(ALL(path));
		cout<<py+1<<"\n"<<path<<'\n';
	}
}

/*
ll gcd(ll a,ll b)
{
	while (a&&b)a>b?a%=b:b%=a;
	return a+b;
}
*/


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define inf (ll)3000000000000000
#define maxn 100010
#define MOD 1000000007
#define fre freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pb push_back
#define pll pair<ll,ll>
#define vi vector<ll>
#define vvi vector<vector<ll> >
#define vii vector<pll>
#define vvpll vector<vector<pll> >
#define vpll vector<pll>
#define ALL(v) (v).begin(),(v).end()
#define SZ(v) (ll)((v).size())

using namespace std;

ll n,m,k;
char a[110][110];
set<pll> dp[110][110];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m>>k;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			cin>>a[i][j];
		}
	}
	for(int i=0;i<m;i++)
	{
		dp[n-1][i].insert({a[n-1][i]-'0',-1});
	}
	for(int i=n-2;i>=0;--i)
	{
		for(int j=0;j<m;j++)
		{
			if(i+1<n&&j-1>=0)
			{
				for(auto &it:dp[i+1][j-1])
				{
					dp[i][j].insert({it.first+a[i][j]-'0',j-1});
				}
			}
			if(i+1<n&&j+1<m)
			{
				for(auto &it:dp[i+1][j+1])
				{
					dp[i][j].insert({it.first+a[i][j]-'0',j+1});
				}
			}
		}
	}
	ll ans=-1,col,py;
	for(int i=0;i<m;i++)
	{
		for(auto &it:dp[0][i])
		{
			if((it.first)%(k+1)==0&&ans<it.first)
			{
				py=i;
				col=it.second;
				ans=it.first;
			}
		}
	}
	cout<<ans<<"\n";
	if(ans!=-1)
	{
		string path;
		if(col>py){
			path+='L';
		}else{
			path+='R';
		}
		ll cur=1;
		ans-=a[0][py]-'0';
		while(col!=-1&&cur<n)
		{
			for(auto &it:dp[cur][col])
			{
				if(it.first==ans)
				{
					ans-=a[cur][col]-'0';
					py=col;
					col=it.second;
					break;
				}
			}
			if(col==-1) break;
			if(col>py){
				path+='L';
			}else{
				path+='R';
			}
			cur++;
		}
		reverse(ALL(path));
		cout<<py+1<<"\n"<<path<<'\n';
	}
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int mn = 105;

int main() {
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	int n, m, k;
	cin >> n >> m >> k;
	string s[mn];
	for (int i = 0; i < n; i++)
		cin >> s[i];
	set<int> dp[mn][mn];
	stack<char> ans;
	for (int i = 0; i < m; i++)
		dp[n - 1][i].insert(s[n - 1][i] - '0');
	for (int i = n - 2; i >= 0; i--) {
		for (int j = 0; j < m; j++) {
			if (j > 0) {
				for (auto e : dp[i + 1][j - 1]) {
					dp[i][j].insert(e + s[i][j] - '0');
				}
			}
			if (j < m - 1) {
				for (auto e : dp[i + 1][j + 1]) {
					dp[i][j].insert(e + s[i][j] - '0');
				}
			}
		}
	}
	int res = -1, t;
	for (int i = 0; i < m; i++) {
		for (auto e : dp[0][i])
			if (e % (k + 1) == 0) {
				res = max(res, e);
				t = i;
			}
	}
	cout << res << endl;
	if (res == -1) {
		return 0;
	}
	int i = 0, p;
	while (i != n - 1) {
		res -= s[i][t] - '0';
		if (t > 0) {
			if (dp[i + 1][t - 1].find(res) != dp[i + 1][t - 1].end()) {
				ans.push('R');
				p = t;
				t--;
				i++;
				continue;
			}
		}
		if (t < m - 1) {
			if (dp[i + 1][t + 1].find(res) != dp[i + 1][t + 1].end()) {
				ans.push('L');
				p = t;
				t++;

			}
		}
		i++;
	}
	cout << t + 1 << endl;
	while (!ans.empty()) {
		cout << ans.top();
		ans.pop();
	}
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int mn = 105;

int main() {
	ifstream cin("input.txt");
	//ofstream cout("output.txt");
	int n, m, k;
	cin >> n >> m >> k;
	string s[mn];
	for (int i = 0; i < n; i++)
		cin >> s[i];
	set<int> dp[mn][mn];
	stack<char> ans;
	for (int i = 0; i < m; i++)
		dp[n - 1][i].insert(s[n - 1][i] - '0');
	for (int i = n - 2; i >= 0; i--) {
		for (int j = 0; j < m; j++) {
			if (j > 0) {
				for (auto e : dp[i + 1][j - 1]) {
					dp[i][j].insert(e + s[i][j] - '0');
				}
			}
			if (j < m - 1) {
				for (auto e : dp[i + 1][j + 1]) {
					dp[i][j].insert(e + s[i][j] - '0');
				}
			}
		}
	}
	int res = -1, t;
	for (int i = 0; i < m; i++) {
		for (auto e : dp[0][i])
			if (e % (k + 1) == 0) {
				if (e > res) {
					res = e;
					t = i;
				}
			}
	}
	cout << res << endl;
	if (res == -1) {
		return 0;
	}
	int i = 0, p;
	while (i != n - 1) {
		res -= s[i][t] - '0';
		if (t > 0) {
			if (dp[i + 1][t - 1].find(res) != dp[i + 1][t - 1].end()) {
				ans.push('R');
				p = t;
				t--;
				i++;
				continue;
			}
		}
		if (t < m - 1) {
			if (dp[i + 1][t + 1].find(res) != dp[i + 1][t + 1].end()) {
				ans.push('L');
				p = t;
				t++;

			}
		}
		i++;
	}
	cout << t + 1 << endl;
	while (!ans.empty()) {
		cout << ans.top();
		ans.pop();
	}
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int mn = 105;

int main() {
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	int n, m, k;
	cin >> n >> m >> k;
	string s[mn];
	for (int i = 0; i < n; i++)
		cin >> s[i];
	set<int> dp[mn][mn];
	stack<char> ans;
	for (int i = 0; i < m; i++)
		dp[n - 1][i].insert(s[n - 1][i] - '0');
	for (int i = n - 2; i >= 0; i--) {
		for (int j = 0; j < m; j++) {
			if (j > 0) {
				for (auto e : dp[i + 1][j - 1]) {
					dp[i][j].insert(e + s[i][j] - '0');
				}
			}
			if (j < m - 1) {
				for (auto e : dp[i + 1][j + 1]) {
					dp[i][j].insert(e + s[i][j] - '0');
				}
			}
		}
	}
	int res = -1, t;
	for (int i = 0; i < m; i++) {
		for (auto e : dp[0][i])
			if (e % (k + 1) == 0) {
				if (e > res) {
					res = e;
					t = i;
				}
			}
	}
	cout << res << endl;
	if (res == -1) {
		return 0;
	}
	int i = 0, p;
	while (i != n - 1) {
		res -= s[i][t] - '0';
		if (t > 0) {
			if (dp[i + 1][t - 1].find(res) != dp[i + 1][t - 1].end()) {
				ans.push('R');
				p = t;
				t--;
				i++;
				continue;
			}
		}
		if (t < m - 1) {
			if (dp[i + 1][t + 1].find(res) != dp[i + 1][t + 1].end()) {
				ans.push('L');
				p = t;
				t++;

			}
		}
		i++;
	}
	cout << t + 1 << endl;
	while (!ans.empty()) {
		cout << ans.top();
		ans.pop();
	}
}


#include <bits/stdc++.h>
using namespace std;
char s[105][105];
int a[105][105],n,m;
int dp[105][105][12];
int recur[105][105][12];
int lastremainder[105][105][12];
#define LEFT -1
#define RIGHT 1
//dp[i][j][run]: Maximum number of peas we can get on row i, column j and remainder after diving (k+1) is run
vector<char> path;
int start;
void recursion(int i,int j,int k) {
	//cout<<"i="<<i<<" j="<<j<<" k="<<k<<"\n";
	if (i==0) {
		start=j+1;
		//cout<<"start assigned as "<<start<<"\n";
		return;
	}
	if (recur[i][j][k]==LEFT) {
		recursion(i-1,j-1,lastremainder[i][j][k]);
		path.push_back('R');
	} else {
		recursion(i-1,j+1,lastremainder[i][j][k]);
		path.push_back('L');
	}
}
int main() {
	//freopen("41D.inp","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int k;
	cin>>n>>m>>k;
	for (int i=n-1;i>=0;i--) {
		for (int j=0;j<m;j++) {
			cin>>s[i][j];
			a[i][j]=s[i][j]-'0';
		}
	}
	memset(dp,-1,sizeof(dp));
	//So -1 means uncalculated.
	for (int j=0;j<m;j++) {
		dp[0][j][a[0][j]%(k+1)]=a[0][j];
	}
	for (int i=0;i<n-1;i++) {
		for (int j=0;j<m;j++) {
			//Row n-1 is considered as the highest row.
			for (int run=0;run<=k;run++) {
				if (dp[i][j][run]!=-1) {
					if (j>0) {
						int remain=(run+a[i+1][j-1])%(k+1);
						if (dp[i][j][run]+a[i+1][j-1]>dp[i+1][j-1][remain]) {
							dp[i+1][j-1][remain]=dp[i][j][run]+a[i+1][j-1];
							recur[i+1][j-1][remain]=RIGHT;
							lastremainder[i+1][j-1][remain]=run;
							//We go upleft, so when we go back down we go right.
						}
					}
					if (j<m-1) {
						int remain=(run+a[i+1][j+1])%(k+1);
						if (dp[i][j][run]+a[i+1][j+1]>dp[i+1][j+1][remain]) {
							dp[i+1][j+1][remain]=dp[i][j][run]+a[i+1][j+1];
							recur[i+1][j+1][remain]=LEFT;
							lastremainder[i+1][j+1][remain]=run;
							//We go upright, so when we go back down we go left.
						}
					}
				}
			}
		}
	}
	int ans=-1,endpoint;
	for (int j=0;j<m;j++) {
		if (dp[n-1][j][0]>ans) {
			ans=dp[n-1][j][0];
			endpoint=j;
		}
	}
	if (ans==-1) cout<<"-1";
	else {
		cout<<ans<<"\n";
		recursion(n-1,endpoint,0);
		cout<<start<<"\n";
		for (int i=0;i<path.size();i++) cout<<path[i];
	}
}


#include <bits/stdc++.h>
using namespace std;
string s[101];
int a[101][101],n,m;
int dp[101][101][12];
int recur[101][101][12];
int lastremainder[101][101][12];
#define LEFT -1
#define RIGHT 1
//dp[i][j][run]: Maximum number of peas we can get on row i, column j and remainder after diving (k+1) is run
string path;
int first;
void recursion(int i,int j,int k) {
	if (i==0) {
		first=j;
		return;
	}
	if (recur[i][j][k]==LEFT) {
		recursion(i-1,j-1,lastremainder[i][j][k]);
		path=path+"R";
	} else {
		recursion(i-1,j+1,lastremainder[i][j][k]);
		path=path+"L";
	}
}
int main() {
	//freopen("41D.inp","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int k;
	cin>>n>>m>>k;
	for (int i=n-1;i>=0;i--) {
		for (int j=0;j<m;j++) {
			cin>>s[i][j];
			a[i][j]=s[i][j]-'0';
		}
	}
	memset(dp,0,sizeof(dp));
	for (int j=0;j<m;j++) {
		dp[0][j][a[0][j]%(k+1)]=a[0][j];
	}
	for (int i=0;i<n-1;i++) {
		for (int j=0;j<m;j++) {
			//Row n-1 is considered as the highest row.
			for (int run=0;run<=k;run++) {
				if (dp[i][j][run]) {
					if (j>0) {
						int remain=(run+a[i+1][j-1])%(k+1);
						if (dp[i][j][run]+a[i+1][j-1]>dp[i+1][j-1][remain]) {
							dp[i+1][j-1][remain]=dp[i][j][run]+a[i+1][j-1];
							recur[i+1][j-1][remain]=RIGHT;
							lastremainder[i+1][j-1][remain]=run;
							//We go upleft, so when we go back down we go right.
						}
					}
					if (j<m-1) {
						int remain=(run+a[i+1][j+1])%(k+1);
						if (dp[i][j][run]+a[i+1][j+1]>dp[i+1][j+1][remain]) {
							dp[i+1][j+1][remain]=dp[i][j][run]+a[i+1][j+1];
							recur[i+1][j+1][remain]=LEFT;
							lastremainder[i+1][j+1][remain]=run;
							//We go upright, so when we go back down we go left.
						}
					}
				}
			}
		}
	}
	int ans=0,endpoint;
	for (int j=0;j<m;j++) {
		if (dp[n-1][j][0]>ans) {
			ans=dp[n-1][j][0];
			endpoint=j;
		}
	}
	if (ans==0) cout<<"-1";
	else {
		cout<<ans<<"\n";
		recursion(n-1,endpoint,0);
		cout<<first+1<<"\n"<<path;
	}
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
string s[101];
int a[101][101],n,m;
int dp[101][101][12];
int recur[101][101][12];
int lastremainder[101][101][12];
#define LEFT -1
#define RIGHT 1
//dp[i][j][run]: Maximum number of peas we can get on row i, column j and remainder after diving (k+1) is run
string path;
int first;
void recursion(int i,int j,int k) {
	if (i==0) {
		first=j;
		return;
	}
	if (recur[i][j][k]==LEFT) {
		recursion(i-1,j-1,lastremainder[i][j][k]);
		path=path+"R";
	} else {
		recursion(i-1,j+1,lastremainder[i][j][k]);
		path=path+"L";
	}
}
signed main() {
	//freopen("41D.inp","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int k;
	cin>>n>>m>>k;
	for (int i=n-1;i>=0;i--) {
		for (int j=0;j<m;j++) {
			cin>>s[i][j];
			a[i][j]=s[i][j]-'0';
		}
	}
	memset(dp,0,sizeof(dp));
	for (int j=0;j<m;j++) {
		dp[0][j][a[0][j]%(k+1)]=a[0][j];
	}
	for (int i=0;i<n-1;i++) {
		for (int j=0;j<m;j++) {
			//Row n-1 is considered as the highest row.
			for (int run=0;run<=k;run++) {
				if (dp[i][j][run]) {
					if (j>0) {
						int remain=(run+a[i+1][j-1])%(k+1);
						if (dp[i][j][run]+a[i+1][j-1]>dp[i+1][j-1][remain]) {
							dp[i+1][j-1][remain]=dp[i][j][run]+a[i+1][j-1];
							recur[i+1][j-1][remain]=RIGHT;
							lastremainder[i+1][j-1][remain]=run;
							//We go upleft, so when we go back down we go right.
						}
					}
					if (j<m-1) {
						int remain=(run+a[i+1][j+1])%(k+1);
						if (dp[i][j][run]+a[i+1][j+1]>dp[i+1][j+1][remain]) {
							dp[i+1][j+1][remain]=dp[i][j][run]+a[i+1][j+1];
							recur[i+1][j+1][remain]=LEFT;
							lastremainder[i+1][j+1][remain]=run;
							//We go upright, so when we go back down we go left.
						}
					}
				}
			}
		}
	}
	int ans=0,endpoint;
	for (int j=0;j<m;j++) {
		if (dp[n-1][j][0]>ans) {
			ans=dp[n-1][j][0];
			endpoint=j;
		}
	}
	if (ans==0) cout<<"-1";
	else {
		cout<<ans<<"\n";
		recursion(n-1,endpoint,0);
		cout<<first+1<<"\n"<<path;
	}
}


#include <bits/stdc++.h>
using namespace std;
char s[105][105];
int a[105][105],n,m;
int dp[105][105][12];
int recur[105][105][12];
int lastremainder[105][105][12];
#define LEFT -1
#define RIGHT 1
//dp[i][j][run]: Maximum number of peas we can get on row i, column j and remainder after diving (k+1) is run
vector<char> path;
int start;
void recursion(int i,int j,int k) {
	//cout<<"i="<<i<<" j="<<j<<" k="<<k<<"\n";
	if (i==0) {
		start=j+1;
		//cout<<"start assigned as "<<start<<"\n";
		return;
	}
	if (recur[i][j][k]==LEFT) {
		recursion(i-1,j-1,lastremainder[i][j][k]);
		path.push_back('R');
	} else {
		recursion(i-1,j+1,lastremainder[i][j][k]);
		path.push_back('L');
	}
}
int main() {
	//freopen("41D.inp","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int k;
	cin>>n>>m>>k;
	for (int i=n-1;i>=0;i--) {
		for (int j=0;j<m;j++) {
			cin>>s[i][j];
			a[i][j]=s[i][j]-'0';
		}
	}
	memset(dp,0,sizeof(dp));
	for (int j=0;j<m;j++) {
		dp[0][j][a[0][j]%(k+1)]=a[0][j];
	}
	for (int i=0;i<n-1;i++) {
		for (int j=0;j<m;j++) {
			//Row n-1 is considered as the highest row.
			for (int run=0;run<=k;run++) {
				if (dp[i][j][run]) {
					if (j>0) {
						int remain=(run+a[i+1][j-1])%(k+1);
						if (dp[i][j][run]+a[i+1][j-1]>dp[i+1][j-1][remain]) {
							dp[i+1][j-1][remain]=dp[i][j][run]+a[i+1][j-1];
							recur[i+1][j-1][remain]=RIGHT;
							lastremainder[i+1][j-1][remain]=run;
							//We go upleft, so when we go back down we go right.
						}
					}
					if (j<m-1) {
						int remain=(run+a[i+1][j+1])%(k+1);
						if (dp[i][j][run]+a[i+1][j+1]>dp[i+1][j+1][remain]) {
							dp[i+1][j+1][remain]=dp[i][j][run]+a[i+1][j+1];
							recur[i+1][j+1][remain]=LEFT;
							lastremainder[i+1][j+1][remain]=run;
							//We go upright, so when we go back down we go left.
						}
					}
				}
			}
		}
	}
	int ans=0,endpoint;
	for (int j=0;j<m;j++) {
		if (dp[n-1][j][0]>ans) {
			ans=dp[n-1][j][0];
			endpoint=j;
		}
	}
	if (ans==0) cout<<"-1";
	else {
		cout<<ans<<"\n";
		recursion(n-1,endpoint,0);
		cout<<start<<"\n";
		for (int i=0;i<path.size();i++) cout<<path[i];
	}
}


#include <bits/stdc++.h>
using namespace std;
string s[101];
int a[101][101],n,m;
int dp[101][101][12];
int recur[101][101][12];
int lastremainder[101][101][12];
#define LEFT -1
#define RIGHT 1
//dp[i][j][run]: Maximum number of peas we can get on row i, column j and remainder after diving (k+1) is run
string path;
int first;
void recursion(int i,int j,int k) {
	if (i==0) {
		first=j;
		return;
	}
	if (recur[i][j][k]==LEFT) {
		recursion(i-1,j-1,lastremainder[i][j][k]);
		path=path+"R";
	} else {
		recursion(i-1,j+1,lastremainder[i][j][k]);
		path=path+"L";
	}
}
int main() {
	freopen("41D.inp","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int k;
	cin>>n>>m>>k;
	for (int i=n-1;i>=0;i--) {
		for (int j=0;j<m;j++) {
			cin>>s[i][j];
			a[i][j]=s[i][j]-'0';
		}
	}
	memset(dp,0,sizeof(dp));
	for (int j=0;j<m;j++) {
		dp[0][j][a[0][j]%(k+1)]=a[0][j];
	}
	for (int i=0;i<n-1;i++) {
		for (int j=0;j<m;j++) {
			//Row n-1 is considered as the highest row.
			for (int run=0;run<=k;run++) {
				if (dp[i][j][run]) {
					if (j>0) {
						int remain=(run+a[i+1][j-1])%(k+1);
						if (dp[i][j][run]+a[i+1][j-1]>dp[i+1][j-1][remain]) {
							dp[i+1][j-1][remain]=dp[i][j][run]+a[i+1][j-1];
							recur[i+1][j-1][remain]=RIGHT;
							lastremainder[i+1][j-1][remain]=run;
							//We go upleft, so when we go back down we go right.
						}
					}
					if (j<m-1) {
						int remain=(run+a[i+1][j+1])%(k+1);
						if (dp[i][j][run]+a[i+1][j+1]>dp[i+1][j+1][remain]) {
							dp[i+1][j+1][remain]=dp[i][j][run]+a[i+1][j+1];
							recur[i+1][j+1][remain]=LEFT;
							lastremainder[i+1][j+1][remain]=run;
							//We go upright, so when we go back down we go left.
						}
					}
				}
			}
		}
	}
	int ans=0,endpoint;
	for (int j=0;j<m;j++) {
		if (dp[n-1][j][0]>ans) {
			ans=dp[n-1][j][0];
			endpoint=j;
		}
	}
	if (ans==0) cout<<"-1";
	else {
		cout<<ans<<"\n";
		recursion(n-1,endpoint,0);
		cout<<first+1<<"\n"<<path;
	}
}


#include <bits/stdc++.h>
using namespace std;
string s[101];
int a[101][101],n,m;
int dp[101][101][12];
int recur[101][101][12];
int lastremainder[101][101][12];
#define LEFT -1
#define RIGHT 1
//dp[i][j][run]: Maximum number of peas we can get on row i, column j and remainder after diving (k+1) is run
string path;
int first;
void recursion(int i,int j,int k) {
	if (i==0) {
		first=j;
		return;
	}
	if (recur[i][j][k]==LEFT) {
		recursion(i-1,j-1,lastremainder[i][j][k]);
		path=path+"R";
	} else {
		recursion(i-1,j+1,lastremainder[i][j][k]);
		path=path+"L";
	}
}
int main() {
	//freopen("41D.inp","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int k;
	cin>>n>>m>>k;
	for (int i=n-1;i>=0;i--) {
		for (int j=0;j<m;j++) {
			cin>>s[i][j];
			a[i][j]=s[i][j]-'0';
		}
	}
	memset(dp,0,sizeof(dp));
	for (int j=0;j<m;j++) {
		dp[0][j][a[0][j]%(k+1)]=a[0][j];
	}
	for (int i=0;i<n-1;i++) {
		for (int j=0;j<m;j++) {
			//Row n-1 is considered as the highest row.
			for (int run=0;run<=k;run++) {
				if (dp[i][j][run]) {
					//cout<<"i="<<i<<" j="<<j<<" k="<<k<<"\n";
					if (j>0) {
						int remain=(run+a[i+1][j-1])%(k+1);
						if (dp[i][j][run]+a[i+1][j-1]>dp[i+1][j-1][remain]) {
							dp[i+1][j-1][remain]=dp[i][j][run]+a[i+1][j-1];
							recur[i+1][j-1][remain]=RIGHT;
							lastremainder[i+1][j-1][remain]=run;
							//We go upleft, so when we go back down we go right.
						}
					}
					if (j<m-1) {
						int remain=(run+a[i+1][j+1])%(k+1);
						if (dp[i][j][run]+a[i+1][j+1]>dp[i+1][j+1][remain]) {
							dp[i+1][j+1][remain]=dp[i][j][run]+a[i+1][j+1];
							recur[i+1][j+1][remain]=LEFT;
							lastremainder[i+1][j+1][remain]=run;
							//We go upright, so when we go back down we go left.
						}
					}
				}
			}
		}
	}
	int ans=0,endpoint;
	for (int j=0;j<m;j++) {
		if (dp[n-1][j][0]>ans) {
			ans=dp[n-1][j][0];
			endpoint=j;
		}
	}
	if (ans==0) cout<<"-1";
	else {
		cout<<ans<<"\n";
		recursion(n-1,endpoint,0);
		cout<<first+1<<"\n"<<path;
	}
}


#include <bits/stdc++.h>
using namespace std;
char s[105][105];
int a[105][105],n,m;
int dp[105][105][12];
int recur[105][105][12];
int lastremainder[105][105][12];
#define LEFT -1
#define RIGHT 1
//dp[i][j][run]: Maximum number of peas we can get on row i, column j and remainder after diving (k+1) is run
vector<char> path;
int start;
void recursion(int i,int j,int k) {
	//cout<<"i="<<i<<" j="<<j<<" k="<<k<<"\n";
	if (i==0) {
		start=j+1;
		//cout<<"start assigned as "<<start<<"\n";
		return;
	}
	if (recur[i][j][k]==LEFT) {
		recursion(i-1,j-1,lastremainder[i][j][k]);
		path.push_back('R');
	} else {
		recursion(i-1,j+1,lastremainder[i][j][k]);
		path.push_back('L');
	}
}
int main() {
	//freopen("41D.inp","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int k;
	cin>>n>>m>>k;
	for (int i=n-1;i>=0;i--) {
		for (int j=0;j<m;j++) {
			cin>>s[i][j];
			a[i][j]=s[i][j]-'0';
		}
	}
	memset(dp,0,sizeof(dp));
	for (int j=0;j<m;j++) {
		dp[0][j][a[0][j]%(k+1)]=a[0][j];
	}
	for (int i=0;i<n-1;i++) {
		for (int j=0;j<m;j++) {
			//Row n-1 is considered as the highest row.
			for (int run=0;run<=k;run++) {
				if (dp[i][j][run]) {
					if (j>0) {
						int remain=(run+a[i+1][j-1])%(k+1);
						if (dp[i][j][run]+a[i+1][j-1]>dp[i+1][j-1][remain]) {
							dp[i+1][j-1][remain]=dp[i][j][run]+a[i+1][j-1];
							recur[i+1][j-1][remain]=RIGHT;
							lastremainder[i+1][j-1][remain]=run;
							//We go upleft, so when we go back down we go right.
						}
					}
					if (j<m-1) {
						int remain=(run+a[i+1][j+1])%(k+1);
						if (dp[i][j][run]+a[i+1][j+1]>dp[i+1][j+1][remain]) {
							dp[i+1][j+1][remain]=dp[i][j][run]+a[i+1][j+1];
							recur[i+1][j+1][remain]=LEFT;
							lastremainder[i+1][j+1][remain]=run;
							//We go upright, so when we go back down we go left.
						}
					}
				}
			}
		}
	}
	int ans=-1,endpoint;
	for (int j=0;j<m;j++) {
		if (dp[n-1][j][0]>ans) {
			ans=dp[n-1][j][0];
			endpoint=j;
		}
	}
	if (ans==-1) cout<<"-1";
	else {
		cout<<ans<<"\n";
		recursion(n-1,endpoint,0);
		cout<<start<<"\n";
		for (int i=0;i<path.size();i++) cout<<path[i];
	}
}


#include <bits/stdc++.h>
using namespace std;
string s[101];
int a[101][101],n,m;
int dp[101][101][12];
int recur[101][101][12];
int lastremainder[101][101][12];
#define LEFT -1
#define RIGHT 1
//dp[i][j][run]: Maximum number of peas we can get on row i, column j and remainder after diving (k+1) is run
string path;
int first;
void recursion(int i,int j,int k) {
	if (i==0) {
		first=j;
		return;
	}
	if (recur[i][j][k]==LEFT) {
		recursion(i-1,j-1,lastremainder[i][j][k]);
		path=path+"R";
	} else {
		recursion(i-1,j+1,lastremainder[i][j][k]);
		path=path+"L";
	}
}
int main() {
	//freopen("41D.inp","r",stdin);
	//ios_base::sync_with_stdio(false);
	//cin.tie(0); cout.tie(0);
	int k;
	cin>>n>>m>>k;
	for (int i=n-1;i>=0;i--) {
		for (int j=0;j<m;j++) {
			cin>>s[i][j];
			a[i][j]=s[i][j]-'0';
		}
	}
	memset(dp,0,sizeof(dp));
	for (int j=0;j<m;j++) {
		dp[0][j][a[0][j]%(k+1)]=a[0][j];
	}
	for (int i=0;i<n-1;i++) {
		for (int j=0;j<m;j++) {
			//Row n-1 is considered as the highest row.
			for (int run=0;run<=k;run++) {
				if (dp[i][j][run]) {
					//cout<<"i="<<i<<" j="<<j<<" k="<<k<<"\n";
					if (j>0) {
						int remain=(run+a[i+1][j-1])%(k+1);
						if (dp[i][j][run]+a[i+1][j-1]>dp[i+1][j-1][remain]) {
							dp[i+1][j-1][remain]=dp[i][j][run]+a[i+1][j-1];
							recur[i+1][j-1][remain]=RIGHT;
							lastremainder[i+1][j-1][remain]=run;
							//We go upleft, so when we go back down we go right.
						}
					}
					if (j<m-1) {
						int remain=(run+a[i+1][j+1])%(k+1);
						if (dp[i][j][run]+a[i+1][j+1]>dp[i+1][j+1][remain]) {
							dp[i+1][j+1][remain]=dp[i][j][run]+a[i+1][j+1];
							recur[i+1][j+1][remain]=LEFT;
							lastremainder[i+1][j+1][remain]=run;
							//We go upright, so when we go back down we go left.
						}
					}
				}
			}
		}
	}
	int ans=0,endpoint;
	for (int j=0;j<m;j++) {
		if (dp[n-1][j][0]>ans) {
			ans=dp[n-1][j][0];
			endpoint=j;
		}
	}
	if (ans==0) cout<<"-1";
	else {
		cout<<ans<<"\n";
		recursion(n-1,endpoint,0);
		cout<<first+1<<"\n"<<path;
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007  //998244353
#include<string.h>
#define inf 1000000000000000000
#define maxn 200006
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
#define endl '\n'
#define mapint_iterator map<int,int> :: iterator
#define mapll_iterator map<ll,ll> :: iterator
#define setint_iterator set<int> :: iterator
#define setll_iterator set<ll> :: iterator
#define setpint_iterator set<pint> :: iterator
#define setpll_iterator set<pll> :: iterator
#define trace(x) cout<<#x<<": "<<x<<" "<<endl
#define trace2(x,y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x,y,z) cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a,b,c,d) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<endl
#define cout2(a,b) cout<<a<<' '<<b<<endl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<endl
typedef priority_queue<ll,vector<ll>,greater<ll> > pqset;
typedef priority_queue<pint,vector<pint>,greater<pint> > pqset_ll;
#define pb push_back
#define fi first
#define se second
#include<ext/pb_ds/assoc_container.hpp>
ll dxk[]={0,0,1,-1,1,1,-1,-1};
ll dyk[]={1,-1,0,0,1,-1,1,-1};
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> os_pair;
#define acc (ios::sync_with_stdio(false),cin.tie(0))
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define repeat(i,start,n) for(ll i=start;i<n;i++)
#define print(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" ";}
ll ll_max(ll a,ll b,ll c){return max(a,max(b,c));}
int int_max(int a,int b,int c){return max(a,max(b,c));}
ll ll_min(ll a,ll b,ll c){return min(a,min(b,c));}
int int_min(int a,int b,int c){return min(a,min(b,c));}
ll max(int a,ll b){ return max((ll)a,b);}
ll min(int a,ll b){ return min((ll)a,b);}
ll min(ll a,int b){ return min(a,(ll)b);}
ll max(ll a,int b){ return max(a,(ll)b);}
ll dx[]={0,0,1,-1};
ll dy[]={1,-1,0,0};
//ifstream cin("b_read_on.txt"); ofstream cout("output3.txt");
//Chronology: Binary Search,Greedy,dp,dfs and similar
//Use (<<) for multiplication
//Use (>>) for division
// In dp, first try top-down,then bottom-up
//ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed;cerr.tie(NULL);cout.precision(10);
// find_by_order -> value at index
// order_of_key -> index of value
void solve(int countu){
	int n,m,k;
	cin>>n>>m>>k;
	vector<string> s(n);
	rep(i,n)
		cin>>s[i];
	reverse(s.begin(),s.end());
	int par[n][m][k+1];
	int dp[n][m][k+1];
	rep(i,n)
		rep(j,m)
			rep(l,k+1)
				dp[i][j][l]=-1e9;
	memset(par,-1,sizeof(par));
	rep(i,m)
		dp[0][i][((s[0][i]-'0')%(k+1))]=s[0][i]-'0';
	repeat(i,1,n){
		rep(j,m){
			rep(l,k+1){
				int c=(l-s[i][j]+'0')%(k+1);
				if(c<0)
					c+=(k+1);
				if(j!=m-1&&dp[i][j][l]<dp[i-1][j+1][c]+s[i][j]-'0'){
					dp[i][j][l]=dp[i-1][j+1][c]+s[i][j]-'0';
					par[i][j][l]=j+1;
				}
				if(j!=0&&dp[i][j][l]<dp[i-1][j-1][c]+s[i][j]-'0'){
					dp[i][j][l]=dp[i-1][j-1][c]+s[i][j]-'0';
					par[i][j][l]=j-1;
				}
			}
		}
	}
	int x=-1;
	int x1=-1;
	rep(i,m){
		if(dp[n-1][i][0]>x){
			x=dp[n-1][i][0];
			x1=i;
		}
	}
	if(x==-1){
		cout<<-1<<endl;
		return;
	}
	cout1(x);
	string s1;
	int j=n-1;
	int k1=0;
	int count=s[n-1][x1]-'0';
	while(s1.size()<n-1){
		if(par[j][x1][k1]>x1)
			s1+='L';
		else if(par[j][x1][k1]<x1)
			s1+='R';
		int l=k1;
		k1=(k1-s[j][x1]+'0')%(k+1);
		if(k1<0)
			k1+=(k+1);
		j--;
		x1=par[j+1][x1][l];
	}
	cout1(x1+1);
	reverse(s1.begin(),s1.end());
	cout1(s1);
}
int main(){
    int t=1;
	//cin>>t;
	int countu=1;
    while(t--){
    	solve(countu);
    	countu++;
    }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007  //998244353
#include<string.h>
#define inf 1000000000000000000
#define maxn 200006
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
#define endl '\n'
#define mapint_iterator map<int,int> :: iterator
#define mapll_iterator map<ll,ll> :: iterator
#define setint_iterator set<int> :: iterator
#define setll_iterator set<ll> :: iterator
#define setpint_iterator set<pint> :: iterator
#define setpll_iterator set<pll> :: iterator
#define trace(x) cout<<#x<<": "<<x<<" "<<endl
#define trace2(x,y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x,y,z) cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a,b,c,d) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<endl
#define cout2(a,b) cout<<a<<' '<<b<<endl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<endl
typedef priority_queue<ll,vector<ll>,greater<ll> > pqset;
typedef priority_queue<pint,vector<pint>,greater<pint> > pqset_ll;
#define pb push_back
#define fi first
#define se second
#include<ext/pb_ds/assoc_container.hpp>
ll dxk[]={0,0,1,-1,1,1,-1,-1};
ll dyk[]={1,-1,0,0,1,-1,1,-1};
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> os_pair;
#define acc (ios::sync_with_stdio(false),cin.tie(0))
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define repeat(i,start,n) for(ll i=start;i<n;i++)
#define print(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" ";}
ll ll_max(ll a,ll b,ll c){return max(a,max(b,c));}
int int_max(int a,int b,int c){return max(a,max(b,c));}
ll ll_min(ll a,ll b,ll c){return min(a,min(b,c));}
int int_min(int a,int b,int c){return min(a,min(b,c));}
ll max(int a,ll b){ return max((ll)a,b);}
ll min(int a,ll b){ return min((ll)a,b);}
ll min(ll a,int b){ return min(a,(ll)b);}
ll max(ll a,int b){ return max(a,(ll)b);}
ll dx[]={0,0,1,-1};
ll dy[]={1,-1,0,0};
//ifstream cin("b_read_on.txt"); ofstream cout("output3.txt");
//Chronology: Binary Search,Greedy,dp,dfs and similar
//Use (<<) for multiplication
//Use (>>) for division
// In dp, first try top-down,then bottom-up
//ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed;cerr.tie(NULL);cout.precision(10);
// find_by_order -> value at index
// order_of_key -> index of value
void solve(int countu){
	int n,m,k;
	cin>>n>>m>>k;
	vector<string> s(n);
	rep(i,n)
		cin>>s[i];
	reverse(s.begin(),s.end());
	int par[n][m][k+1];
	int dp[n][m][k+1];
	rep(i,n)
		rep(j,m)
			rep(l,k+1)
				dp[i][j][l]=-1e9;
	memset(par,-1,sizeof(par));
	rep(i,m)
		dp[0][i][((s[0][i]-'0')%(k+1))]=s[0][i]-'0';
	repeat(i,1,n){
		rep(j,m){
			rep(l,k+1){
				rep(m1,k+1){
					int c=(m1+s[i][j]-'0')%(k+1);
					if(j!=m-1&&dp[i][j][l]<dp[i-1][j+1][m1]+s[i][j]-'0'&&c==l){
						dp[i][j][l]=dp[i-1][j+1][m1]+s[i][j]-'0';
						par[i][j][l]=j+1;
					}
					if(j!=0&&dp[i][j][l]<dp[i-1][j-1][m1]+s[i][j]-'0'&&c==l){
						dp[i][j][l]=dp[i-1][j-1][m1]+s[i][j]-'0';
						par[i][j][l]=j-1;
					}
				}
			}
		}
	}
	int x=-1;
	int x1=-1;
	rep(i,m){
		if(dp[n-1][i][0]>x){
			x=dp[n-1][i][0];
			x1=i;
		}
	}
	if(x==-1){
		cout<<-1<<endl;
		return;
	}
	cout1(x);
	string s1;
	int f=x1;
	int j=n-1;
	int k1=0;
	int count=s[n-1][x1]-'0';
	while(s1.size()<n-1){
		if(par[j][x1][k1]>x1)
			s1+='L';
		else
			s1+='R';
		int l=k1;
		k1=(k1-s[j][x1]+'0'+k+1)%(k+1);
		j--;
		x1=par[j+1][x1][l];
	}
	cout1(x1+1);
	reverse(s1.begin(),s1.end());
	cout1(s1);
}
int main(){
    int t=1;
	//cin>>t;
	int countu=1;
    while(t--){
    	solve(countu);
    	countu++;
    }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007  //998244353
#include<string.h>
#define inf 1000000000000000000
#define maxn 200006
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
#define endl '\n'
#define mapint_iterator map<int,int> :: iterator
#define mapll_iterator map<ll,ll> :: iterator
#define setint_iterator set<int> :: iterator
#define setll_iterator set<ll> :: iterator
#define setpint_iterator set<pint> :: iterator
#define setpll_iterator set<pll> :: iterator
#define trace(x) cout<<#x<<": "<<x<<" "<<endl
#define trace2(x,y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x,y,z) cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a,b,c,d) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<endl
#define cout2(a,b) cout<<a<<' '<<b<<endl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<endl
typedef priority_queue<ll,vector<ll>,greater<ll> > pqset;
typedef priority_queue<pint,vector<pint>,greater<pint> > pqset_ll;
#define pb push_back
#define fi first
#define se second
#include<ext/pb_ds/assoc_container.hpp>
ll dxk[]={0,0,1,-1,1,1,-1,-1};
ll dyk[]={1,-1,0,0,1,-1,1,-1};
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> os_pair;
#define acc (ios::sync_with_stdio(false),cin.tie(0))
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define repeat(i,start,n) for(ll i=start;i<n;i++)
#define print(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" ";}
ll ll_max(ll a,ll b,ll c){return max(a,max(b,c));}
int int_max(int a,int b,int c){return max(a,max(b,c));}
ll ll_min(ll a,ll b,ll c){return min(a,min(b,c));}
int int_min(int a,int b,int c){return min(a,min(b,c));}
ll max(int a,ll b){ return max((ll)a,b);}
ll min(int a,ll b){ return min((ll)a,b);}
ll min(ll a,int b){ return min(a,(ll)b);}
ll max(ll a,int b){ return max(a,(ll)b);}
ll dx[]={0,0,1,-1};
ll dy[]={1,-1,0,0};
//ifstream cin("b_read_on.txt"); ofstream cout("output3.txt");
//Chronology: Binary Search,Greedy,dp,dfs and similar
//Use (<<) for multiplication
//Use (>>) for division
// In dp, first try top-down,then bottom-up
//ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed;cerr.tie(NULL);cout.precision(10);
// find_by_order -> value at index
// order_of_key -> index of value
void solve(int countu){
	int n,m,k;
	cin>>n>>m>>k;
	vector<string> s(n);
	rep(i,n)
		cin>>s[i];
	reverse(s.begin(),s.end());
	int par[n][m][k+1];
	int dp[n][m][k+1];
	rep(i,n)
		rep(j,m)
			rep(l,k+1)
				dp[i][j][l]=-1e9;
	memset(par,-1,sizeof(par));
	rep(i,m)
		dp[0][i][((s[0][i]-'0')%(k+1))]=s[0][i]-'0';
	repeat(i,1,n){
		rep(j,m){
			rep(l,k+1){
				rep(m1,k+1){
					int c=(m1+s[i][j]-'0')%(k+1);
					if(j!=m-1&&dp[i][j][l]<dp[i-1][j+1][m1]+s[i][j]-'0'&&c==l){
						dp[i][j][l]=dp[i-1][j+1][m1]+s[i][j]-'0';
						par[i][j][l]=j+1;
					}
					if(j!=0&&dp[i][j][l]<dp[i-1][j-1][m1]+s[i][j]-'0'&&c==l){
						dp[i][j][l]=dp[i-1][j-1][m1]+s[i][j]-'0';
						par[i][j][l]=j-1;
					}
				}
			}
		}
	}
	int x=-1;
	int x1=-1;
	rep(i,m){
		if(dp[n-1][i][0]>x){
			x=dp[n-1][i][0];
			x1=i;
		}
	}
	if(x==-1){
		cout<<-1<<endl;
		return;
	}
	cout1(x);
	string s1;
	int j=n-1;
	int k1=0;
	int count=s[n-1][x1]-'0';
	while(s1.size()<n-1){
		if(par[j][x1][k1]>x1)
			s1+='L';
		else if(par[j][x1][k1]<x1)
			s1+='R';
		int l=k1;
		k1=(k1-s[j][x1]+'0')%(k+1);
		if(k1<0)
			k1+=(k+1);
		j--;
		x1=par[j+1][x1][l];
	}
	cout1(x1+1);
	reverse(s1.begin(),s1.end());
	cout1(s1);
}
int main(){
    int t=1;
	//cin>>t;
	int countu=1;
    while(t--){
    	solve(countu);
    	countu++;
    }

}


#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]);
            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()-2;i>=0;i--)
            cout<<e.at(i);
    }
}