On some square in the lowest row of a chessboard a stands a pawn. It has only two variants of moving: upwards and leftwards or upwards and rightwards. The pawn can choose from which square of the lowest row it can start its journey. On each square lay from 0 to 9 peas. The pawn wants to reach the uppermost row having collected as many peas as possible. As there it will have to divide the peas between itself and its *k* brothers, the number of peas must be divisible by *k* + 1. Find the maximal number of peas it will be able to collect and which moves it should make to do it.

The pawn cannot throw peas away or leave the board. When a pawn appears in some square of the board (including the first and last square of the way), it necessarily takes all the peas.
The first line contains three integers *n*, *m*, *k* (2 ≤ *n*, *m* ≤ 100, 0 ≤ *k* ≤ 10) — the number of rows and columns on the chessboard, the number of the pawn's brothers. Then follow *n* lines containing each *m* numbers from 0 to 9 without spaces — the chessboard's description. Each square is described by one number — the number of peas in it. The first line corresponds to the uppermost row and the last line — to the lowest row.
import sys
import math
import numpy as np


def ii(): return int(input())  # input int


def ils(s=' '): return input().split(s)  # input list split


# input list of char: ['a', 'b', 'c', ...]
def ilc(): return list(input())


# input list of d: [1, 0, 9, ...]
def ild(): return list(map(lambda x: int(x), input()))


# input list of int: [1, 2, 3, ...]
def ili(): return list(map(lambda x: int(x), input().split(' ')))


# input list of int splited: (a, b, c, ...)
def ilis(): return tuple(map(lambda x: int(x), input().split(' ')))


def ip(): return input()


def op(l):
    print(l)
    sys.stdout.flush()


def gcd(a, b): return a if b == 0 else gcd(b, a % b)


def extgcd(a, b, x=0, y=0):
    if b == 0:
        return (a, 1, 0)
    d, m, n = extgcd(b, a % b, x, y)
    return (d, n, m-(a//b)*n)


class Union_set:
    def __init__(self, n):
        self.data = [i for i in range(n)]  # 记录每个节点的祖先节点
        self.size = [1] * n               # 记录每个节点的子树的节点数
        self.cnt = n                      # 记录当前的集合数量

    def find(self, m):
        if self.data[m] == m:
            return m
        ancestor = self.find(self.data[m])  # 找到祖先节点（根节点）
        self.data[m] = ancestor
        return ancestor

    def union(self, a, b):
        ancestor_a = self.find(a)
        ancestor_b = self.find(b)
        if ancestor_a == ancestor_b:
            return
        if self.size[ancestor_a] > self.size[ancestor_b]:
            self.data[ancestor_b] = ancestor_a
            self.size[ancestor_a] += ancestor_b
        else:
            self.data[ancestor_a] = ancestor_b
            self.size[ancestor_b] += ancestor_a
        self.cnt -= 1

    def query(self, a, b):
        return self.find(a) == self.find(b)


class ZKW:
    def __init__(self, l, n):
        self.n = n
        self.m = 1
        while self.m <= self.n:
            self.m <<= 1
        self.add = [0 for _ in range(self.m << 1)]
        self.sum = [0 for _ in range(self.m << 1)]
        self.mx = [0 for _ in range(self.m << 1)]
        self.mn = [1 << 30 for _ in range(self.m << 1)]
        for i in range(self.m + 1, self.m + self.n + 1):
            self.sum[i] = self.mx[i] = self.mn[i] = l[i-self.m-1]
        for i in range(self.m - 1, 0, -1):
            self.sum[i] = self.sum[i << 1] + self.sum[i << 1 | 1]

            self.mn[i] = min(self.mn[i << 1], self.mn[i << 1 | 1])
            self.mn[i << 1] -= self.mn[i]
            self.mn[i << 1 | 1] -= self.mn[i]

            self.mx[i] = max(self.mx[i << 1], self.mx[i << 1 | 1])
            self.mx[i << 1] -= self.mx[i]
            self.mx[i << 1 | 1] -= self.mx[i]

    def update_node(self, x, v):
        x += self.m + 1
        self.mx[x] += v
        self.mn[x] += v
        while x > 1:
            self.sum[x] += v

            a = min(self.mn[x], self.mn[x ^ 1])
            self.mn[x >> 1] += a
            self.mn[x] -= a
            self.mn[x ^ 1] -= a

            a = max(self.mx[x], self.mx[x ^ 1])
            self.mx[x >> 1] += a
            self.mx[x] -= a
            self.mx[x ^ 1] -= a
            x >>= 1

    def update_iter(self, s, t, v):
        l = 1
        lc = 0
        rc = 0
        s += self.m
        t += self.m + 2
        while s ^ t ^ 1:
            if s & 1 ^ 1:
                self.add[s ^ 1] += v
                lc += l
                self.mn[s ^ 1] += v
                self.mx[s ^ 1] += v
            if t & 1:
                self.add[t ^ 1] += v
                rc += l
                self.mn[t ^ 1] += v
                self.mx[t ^ 1] += v

            self.sum[s >> 1] += v * lc
            self.sum[t >> 1] += v * rc

            a = min(self.mn[s], self.mn[s ^ 1])
            self.mn[s >> 1] += a
            self.mn[s] -= a
            self.mn[s ^ 1] -= a

            a = min(self.mn[t], self.mn[t ^ 1])
            self.mn[t >> 1] += a
            self.mn[t] -= a
            self.mn[t ^ 1] -= a

            a = max(self.mx[s], self.mx[s ^ 1])
            self.mx[s >> 1] += a
            self.mx[s] -= a
            self.mx[s ^ 1] -= a

            a = max(self.mx[t], self.mx[t ^ 1])
            self.mx[t >> 1] += a
            self.mx[t] -= a
            self.mx[t ^ 1] -= a
            s >>= 1
            t >>= 1
            l <<= 1
        lc += rc
        while s > 1:
            self.sum[s >> 1] += v * lc

            a = min(self.mn[s], self.mn[s ^ 1])
            self.mn[s >> 1] += a
            self.mn[s] -= a
            self.mn[s ^ 1] -= a

            a = max(self.mx[s], self.mx[s ^ 1])
            self.mx[s >> 1] += a
            self.mx[s] -= a
            self.mx[s ^ 1] -= a
            s >>= 1

    def query_node(self, x):
        x += self.m + 1
        ans = 0
        while x:
            ans += self.mx[x]
            x >>= 1
        return ans

    def query_sum(self, s, t):
        lc = 0
        rc = 0
        l = 1
        ans = 0
        s += self.m
        t += self.m+2
        while s ^ t ^ 1:
            if s & 1 ^ 1:
                ans += self.sum[s ^ 1] + l * self.add[s ^ 1]
                lc += l
            if t & 1:
                ans += self.sum[t ^ 1] + l * self.add[t ^ 1]
                rc += l
            if self.add[s >> 1]:
                ans += self.add[s >> 1] * lc
            if self.add[t >> 1]:
                ans += self.add[t >> 1] * rc
            s >>= 1
            t >>= 1
            l <<= 1
        lc += rc
        s >>= 1
        while s:
            if self.add[s]:
                ans += self.add[s] * lc
            s >>= 1
        return ans

    def query_min(self, s, t):
        if s == t:
            return self.query_node(s)
        l = 0
        r = 0
        s += self.m + 1
        t += self.m + 1
        while s ^ t ^ 1:
            l += self.mn[s]
            r += self.mn[t]
            if s & 1 ^ 1:
                l = min(l, self.mn[s ^ 1])
            if t & 1:
                r = min(r, self.mn[t ^ 1])
            s >>= 1
            t >>= 1
        l += self.mn[s]
        r += self.mn[t]
        ans = min(l, r)
        s >>= 1
        while s:
            ans += self.mn[s]
            s >>= 1
        return ans

    def query_max(self, s, t):
        if s == t:
            return self.query_node(s)
        l = 0
        r = 0
        s += self.m + 1
        t += self.m + 1
        while s ^ t ^ 1:
            l += self.mx[s]
            r += self.mx[t]
            if s & 1 ^ 1:
                l = max(l, self.mx[s ^ 1])
            if t & 1:
                r = max(r, self.mx[t ^ 1])
            s >>= 1
            t >>= 1
        l += self.mx[s]
        r += self.mx[t]
        ans = max(l, r)
        s >>= 1
        while s:
            ans += self.mx[s]
            s >>= 1
        return ans


def main():
    n, m, k = ilis()
    mat = []
    for _ in range(n):
        mat.append(ild())
    # init dp
    ret = [[0 for _ in range(m)] for _ in range(n)]
    for i in range(m):
        t = mat[n-1][i]
        ret[n - 1][i] = t if t % (k + 1) == 0 else (-1)
    # update dp
    for i in range(n - 2, -1, -1):
        for j in range(m):
            if mat[i][j] % (k+1) != 0:
                ret[i][j] = -1
                continue
            a = ret[i + 1][j - 1] if (j > 0) else (-1)
            b = ret[i + 1][j + 1] if (j < m - 1) else (-1)
            if a == -1 and b == -1:
                ret[i][j] = -1
                continue
            ret[i][j] = max(a, b) + mat[i][j]
    # op
    maxi = -1
    ind = 0
    for i in range(m):
        if ret[0][i] > maxi:
            maxi = ret[0][i]
            ind = i
    op(maxi)
    if (maxi > -1):
        path = ''
        for i in range(n - 1):
            a = ret[i + 1][ind - 1] if (ind > 0) else (-1)
            b = ret[i + 1][ind + 1] if (ind < m - 1) else (-1)
            path += 'L' if a < b else 'R'
            ind += 1 if a < b else - 1
        op(ind+1)
        op(''.join(reversed(path)))


if __name__ == "__main__":
    main()
