def sqr_5_converter(n):
	if n != 0:
		b = (n%2 == 0) or (n%5 == 0); num_2s = 0; num_5s = 0
		while b:
			if n%2 == 0: num_2s += 1; n = n//2;
			if n%5 == 0: num_5s += 1; n = n//5;
			b = (n%2 == 0) or (n%5 == 0)
		return (num_2s, num_5s, False, False)
	else:
		return (1, 1, True, True)

#needs to choose the one with less 0's.
def grim_reaper(r, d, add):
	if r[0] < d[0]:
		if r[1] < d[1]: return (r[0] + add[0], r[1] + add[1], r[2] and add[2], r[3] and add[3])
		else: return (r[0] + add[0], d[1] + add[1], r[2] and add[2], d[3] and add[3])
	else:
		if r[1] < d[1]: return (d[0] + add[0], r[1] + add[1], d[2] and add[2], r[3] and add[3])
		else: return (d[0] + add[0], d[1] + add[1], d[2] and add[2], d[3] and add[3])

def backtracker(mode, path, m, n):
	if m == 0 or n == 0:
		if m == 0 and n == 0: print(path); return;
		elif m == 0: print('R'*n + path); return;
		else:	print('D'*m + path); return;
	else: # 0 for 2 and 1 for 5
		if arr[m-1][n][mode] < arr[m][n-1][mode]: backtracker(mode, 'D' + path, m-1,n);
		elif arr[m-1][n][mode] == arr[m][n-1][mode]:
			if arr[m-1][n][(mode + 1)%2] <= arr[m][n-1][(mode + 1)%2]: backtracker(mode, 'D' + path, m-1,n)
			else: backtracker(mode, 'R' + path, m,n-1);
		else: backtracker(mode, 'R' + path, m,n-1);

#first route is for the 2s and second is for the 5s
n = int(input())
arr = [[1]]*n
for i in range(n):
	a = list(map(sqr_5_converter, (map(int, input().split()))))
	arr[i] = a
for j in range(n):
	for k in range(n):
		if j == 0 or k == 0:
			if j == 0 and k == 0: continue
			elif j == 0: arr[j][k] = (arr[j][k-1][0] + arr[j][k][0], arr[j][k-1][1] + arr[j][k][1], arr[j][k-1][2] and arr[j][k][2], arr[j][k-1][3] and arr[j][k][3])
			else: arr[j][k] = (arr[j-1][k][0] + arr[j][k][0], arr[j-1][k][1] + arr[j][k][1], arr[j-1][k][2] and arr[j][k][2], arr[j-1][k][3] and arr[j][k][3])
		else:
			arr[j][k] = grim_reaper(arr[j][k-1], arr[j-1][k], arr[j][k])
val = min(arr[n-1][n-1][0], arr[n-1][n-1][1])
zero = arr[n-1][n-1][2] or arr[n-1][n-1][3]
if zero and val > 1:
	print(1)
	if arr[n-1][n-1][2] == 0: backtracker(0,'',n-1,n-1)
	else: backtracker(1,'',n-1,n-1)
else:
	print(val)
	if arr[n-1][n-1][0] < arr[n-1][n-1][1]: backtracker(0,'',n-1,n-1)
	else: backtracker(1,'',n-1,n-1)


def sqr_5_converter(n):
	if n != 0:
		b = (n%2 == 0) or (n%5 == 0)
		ori_n = n
		num_2s = 0; num_5s = 0
		while b:
			if n%2 == 0: n = n//2; num_2s += 1;
			if n%5 == 0: n = n//5; num_5s += 1;
			b = (n%2 == 0) or (n%5 == 0)
		return (num_2s, num_5s, ori_n)
	else:
		return (1, 1, n)

def compare_val(tup1, tup2, zero_mode):
	if zero_mode:
		num1_pairs = min(tup1[0], tup1[1])
		num2_pairs = min(tup2[0], tup2[1])
		if num1_pairs == num2_pairs:
			num1_unpairs = max(tup1[0], tup1[1])
			num2_unpairs = max(tup2[0], tup2[1])
			if num1_unpairs == num2_unpairs: return tup1
			elif num1_unpairs > num2_unpairs: return tup2
			else: return tup1
		elif num1_pairs > num2_pairs:	return tup2
		else:	return tup1
	else:
		val1 = tup1[3]
		val2 = tup2[3]
		if val1 * val2 != 0: return compare_val(tup1, tup2, True)
		else:
			if val1 == 0 and val2 == 0: return tup1
			elif val1 == 0: return tup2
			else: return tup1

n = int(input())
arr = [list(map(sqr_5_converter, (map(int, input().split())))) for _ in range(n)]
arr_nozero = arr
for j in range(n):
	for k in range(n):
		if j == 0 or k == 0: #first row and column
			if j == 0 and k == 0: value = (arr[j][k][0], arr[j][k][1], '', arr[j][k][2]); arr[j][k] = value; arr_nozero[j][k] = value
			elif j == 0: value = (arr[j][k][0] + arr[j][k-1][0], arr[j][k][1] + arr[j][k-1][1], arr[j][k-1][2] + 'R', arr[j][k][2]*arr[j][k-1][3]); arr[j][k] = value; arr_nozero[j][k] = value
			else: value = (arr[j][k][0] + arr[j-1][k][0], arr[j][k][1] + arr[j-1][k][1], arr[j-1][k][2] + 'D', arr[j-1][k][2]*arr[j][k][2]); arr[j][k] = value; arr_nozero[j][k] = value
		else:
			ztup1 = (arr[j-1][k][0] + arr[j][k][0], arr[j-1][k][1] + arr[j][k][1], arr[j-1][k][2] + 'D', arr[j-1][k][3]*arr[j][k][2])
			ztup2 = (arr[j][k-1][0] + arr[j][k][0], arr[j][k-1][1] + arr[j][k][1], arr[j][k-1][2] + 'R', arr[j][k-1][3]*arr[j][k][2])
			nztup1 = (arr_nozero[j-1][k][0] + arr_nozero[j][k][0], arr_nozero[j-1][k][1] + arr_nozero[j][k][1], arr_nozero[j-1][k][2] + 'D', arr_nozero[j-1][k][3]*arr_nozero[j][k][2])
			nztup2 = (arr_nozero[j][k-1][0] + arr_nozero[j][k][0], arr_nozero[j][k-1][1] + arr_nozero[j][k][1], arr_nozero[j][k-1][2] + 'R', arr_nozero[j][k-1][3]*arr_nozero[j][k][2])
			arr[j][k] = compare_val(ztup1,ztup2,True)
			arr_nozero[j][k] = compare_val(nztup1,nztup2,False)
val_zero = min(arr[n-1][n-1][0], arr[n-1][n-1][1])
val = min(arr_nozero[n-1][n-1][0], arr_nozero[n-1][n-1][1])
if val_zero > val:
	print(val)
	print(arr_nozero[n-1][n-1][2])
else:
	print(val_zero)
	print(arr[n-1][n-1][2])


def sqr_5_converter(n):
	if n != 0:
		b = (n%2 == 0) or (n%5 == 0); fac_tup = (0, 0, n); ori_n = n
		while b:
			if n%2 == 0: fac_tup = (fac_tup[0] + 1, fac_tup[1], ori_n); n = n//2;
			if n%5 == 0: fac_tup = (fac_tup[0], fac_tup[1] + 1, ori_n); n = n//5;
			b = (n%2 == 0) or (n%5 == 0)
		return fac_tup
	else:
		return (1, 1, n)

n = int(input())
arr = [[1]]*n
for i in range(n):
	a = list(map(sqr_5_converter, (map(int, input().split()))))
	arr[i] = a
for j in range(n):
	for k in range(n):
		if j == 0 or k == 0:
			if j == 0 and k == 0: arr[j][k] = (arr[0][0][0], arr[0][0][1], '', arr[0][0][2])
			elif j == 0: arr[j][k] = (arr[j][k-1][0] + arr[j][k][0], arr[j][k-1][1] + arr[j][k][1], arr[j][k-1][2] + 'R', arr[j][k-1][3] * arr[j][k][2])
			else: arr[j][k] = (arr[j-1][k][0] + arr[j][k][0], arr[j-1][k][1] + arr[j][k][1], arr[j-1][k][2] + 'D', arr[j-1][k][3] * arr[j][k][2])
		else:
			can_a = (arr[j-1][k][0] + arr[j][k][0], arr[j-1][k][1] + arr[j][k][1], arr[j-1][k][2] + 'D', arr[j-1][k][3] * arr[j][k][2]); can_b = (arr[j][k-1][0] + arr[j][k][0], arr[j][k-1][1] + arr[j][k][1], arr[j][k-1][2] + 'R', arr[j][k-1][3] * arr[j][k][2])
			num_pair_a = min(can_a[0], can_a[1]); num_pair_b = min(can_b[0], can_b[1])
			if can_a[3] == 0 or can_b[3] == 0:
				if can_a[3] == 0:
					if can_b[3] == 0: arr[j][k] = can_a
					else:	# where one a is 0 but the other b isn't
						if num_pair_b >= 1: arr[j][k] = can_a
						else: arr[j][k] = can_b
				else:
					if num_pair_a >= 1: arr[j][k] = can_b
					else: arr[j][k] = can_a
			elif num_pair_a == num_pair_b:
				num_unpair_a = max(can_a[0], can_a[1]); num_unpair_b = max(can_b[0], can_b[1])
				if num_unpair_a >= num_unpair_b: arr[j][k] = can_b
				else: arr[j][k] = can_a
			else:
				if num_pair_a > num_pair_b: arr[j][k] = can_b
				else: arr[j][k] = can_a
val = min(arr[n-1][n-1][0], arr[n-1][n-1][1])
if val != 0 and arr[n-1][n-1][3] == 0: print(1)
else:	print(val)
print(arr[n-1][n-1][2])


def sqr_5_converter(n):
	if n != 0:
		b = (n%2 == 0) or (n%5 == 0); ori_n = n; num_2s = 0; num_5s = 0
		while b:
			if n%2 == 0: num_2s += 1; n = n//2;
			if n%5 == 0: num_5s += 1; n = n//5;
			b = (n%2 == 0) or (n%5 == 0)
		return (num_2s, num_5s, ori_n, ori_n)
	else:
		return (1, 1, n, n)

def grim_reaper(r, d, add):
	res0 = res1 = res2 = res3= 0;
	if r[0] < d[0]:
		res0 = r[0] + add[0]
		res2 = r[2] * add[2]
	elif r[0] == d[0]:
		if r[2] <= d[2]:
			res0 = r[0] + add[0]
			res2 = r[2] * add[2]
		else:
			res0 = d[0] + add[0]
			res2 = d[2] * add[2]
	else:
		res0 = d[0] + add[0]
		res2 = d[2] * add[3]
	if r[1] < d[1]:
		res1 = r[1] + add[1]
		res3 = r[3] * add[3]
	elif r[1] == d[1]:
		if r[2] <= d[2]:
			res1 = r[1] + add[1]
			res3 = r[3] * add[3]
		else:
			res1 = d[1] + add[1]
			res3 = d[3] * add[3]
	else:
		res1 = d[1] + add[1]
		res3 = d[3] * add[3]
	return (res0, res1, res2,res3)

def backtracker(mode, path, m, n):
	if m == 0 or n == 0:
		if m == 0 and n == 0: print(path); return;
		elif m == 0: print('R'*n + path); return;
		else:	print('D'*m + path); return;
	else: # 0 for 2 and 1 for 5
		if arr[m-1][n][mode] <= arr[m][n-1][mode]: backtracker(mode, 'D' + path, m-1,n);
		else: backtracker(mode, 'R' + path, m-1,n);

#first route is for the 2s and second is for the 5s
n = int(input())
arr = [[1]]*n
zero_ex = False
for i in range(n):
	a = list(map(sqr_5_converter, (map(int, input().split()))))
	arr[i] = a
for j in range(n):
	for k in range(n):
		if j == 0 or k == 0:
			if j == 0 and k == 0: continue
			elif j == 0: arr[j][k] = (arr[j][k-1][0] + arr[j][k][0], arr[j][k-1][1] + arr[j][k][1], arr[j][k-1][2]*arr[j][k][2], arr[j][k-1][3]*arr[j][k][3])
			else: arr[j][k] = (arr[j-1][k][0] + arr[j][k][0], arr[j-1][k][1] + arr[j][k][1], arr[j-1][k][2]*arr[j][k][2], arr[j][k-1][3]*arr[j][k][3])
		else:
			arr[j][k] = grim_reaper(arr[j][k-1], arr[j-1][k], arr[j][k])
val = min(arr[n-1][n-1][0], arr[n-1][n-1][1])
zero = arr[n-1][n-1][2] * arr[n-1][n-1][3] == 0
if zero:
	print(1)
	if arr[n-1][n-1][2] == 0: backtracker(0,'',n-1,n-1)
	else: backtracker(1,'',n-1,n-1)
else:
	print(val)
	if arr[n-1][n-1][0] == val: backtracker(0,'',n-1,n-1)
	else: backtracker(1,'',n-1,n-1)


def sqr_5_converter(n):
	if n != 0:
		b = (n%2 == 0) or (n%5 == 0)
		ori_n = n
		num_2s = 0; num_5s = 0
		while b:
			if n%2 == 0: n = n//2; num_2s += 1;
			if n%5 == 0: n = n//5; num_5s += 1;
			b = (n%2 == 0) or (n%5 == 0)
		return (num_2s, num_5s, ori_n)
	else:
		return (1, 1, n)

def compare_val(tup1, tup2, zero_mode):
	if zero_mode:
		num1_pairs = min(tup1[0], tup1[1])
		num2_pairs = min(tup2[0], tup2[1])
		if num1_pairs == num2_pairs:
			num1_unpairs = max(tup1[0], tup1[1])
			num2_unpairs = max(tup2[0], tup2[1])
			if num1_unpairs == num2_unpairs: return tup1
			elif num1_unpairs > num2_unpairs: return tup2
			else: return tup1
		elif num1_pairs > num2_pairs:	return tup2
		else:	return tup1
	else:
		val1 = tup1[3]
		val2 = tup2[3]
		if val1 == 0 or val2 == 0:
			if val1 == 0 and val2 == 0: return tup1
			elif val1 == 0: return tup2
			else: return tup1
		else: return compare_val(tup1, tup2, True)

n = int(input())
arr = [list(map(sqr_5_converter, (map(int, input().split())))) for _ in range(n)]
arr_nozero = arr
for j in range(n):
	for k in range(n):
		if j == 0 or k == 0: #first row and column
			if j == 0 and k == 0: value = (arr[j][k][0], arr[j][k][1], '', arr[j][k][2]); arr[j][k] = value; arr_nozero[j][k] = value
			elif j == 0: value = (arr[j][k][0] + arr[j][k-1][0], arr[j][k][1] + arr[j][k-1][1], arr[j][k-1][2] + 'R', arr[j][k][2]*arr[j][k-1][3]); arr[j][k] = value; arr_nozero[j][k] = value
			else: arr[j][k] = arr[0][0]; value = (arr[j][k][0] + arr[j-1][k][0], arr[j][k][1] + arr[j-1][k][1], arr[j-1][k][2] + 'D', arr[j-1][k][2]*arr[j][k][3]); arr[j][k] = value; arr_nozero[j][k] = value
		else:
			ztup1 = (arr[j-1][k][0] + arr[j][k][0], arr[j-1][k][1] + arr[j][k][1], arr[j-1][k][2] + 'D', arr[j-1][k][3]*arr[j][k][2])
			ztup2 = (arr[j][k-1][0] + arr[j][k][0], arr[j][k-1][1] + arr[j][k][1], arr[j][k-1][2] + 'R', arr[j][k-1][3]*arr[j][k][2])
			nztup1 = (arr_nozero[j-1][k][0] + arr_nozero[j][k][0], arr_nozero[j-1][k][1] + arr_nozero[j][k][1], arr_nozero[j-1][k][2] + 'D', arr_nozero[j-1][k][3]*arr_nozero[j][k][2])
			nztup2 = (arr_nozero[j][k-1][0] + arr_nozero[j][k][0], arr_nozero[j][k-1][1] + arr_nozero[j][k][1], arr_nozero[j][k-1][2] + 'R', arr_nozero[j][k-1][3]*arr_nozero[j][k][2])
			arr[j][k] = compare_val(ztup1,ztup2,True)
			arr_nozero[j][k] = compare_val(nztup1,nztup2,False)
val_zero = min(arr[n-1][n-1][0], arr[n-1][n-1][1])
val = min(arr_nozero[n-1][n-1][0], arr_nozero[n-1][n-1][1])
if val_zero >= val:
	print(val)
	print(arr_nozero[n-1][n-1][2])
else:
	print(val_zero)
	print(arr[n-1][n-1][2])


def sqr_5_converter(i):
	global num_called
	num_called += 1
	if i != 0:
		b = (i%2 == 0) or (i%5 == 0); num_2s = 0; num_5s = 0
		while b:
			if i%2 == 0: num_2s += 1; i = i//2;
			if i%5 == 0: num_5s += 1; i = i//5;
			b = (i%2 == 0) or (i%5 == 0)
		return (num_2s, num_5s)
	else:
		global zero
		if not zero:
			zero = True
			global zero_spot
			rem = num_called%n
			quot = num_called//n
			if num_called%n == 0:
				zero_spot = (quot - 1, n - 1)
			else:
				zero_spot = (quot, rem - 1)
		return (1, 1)

#needs to choose the one with less 0's.
def grim_reaper(r, d, add):
	if r[0] < d[0]:
		if r[1] < d[1]: return (r[0] + add[0], r[1] + add[1])
		else: return (r[0] + add[0], d[1] + add[1])
	else:
		if r[1] < d[1]: return (d[0] + add[0], r[1] + add[1])
		else: return (d[0] + add[0], d[1] + add[1])

def backtracker(mode, path, m, n): # backtracker now needs to follow the zero in case of zero
	if mode == 2:
		global zero_spot
		print(zero_spot)
		x = zero_spot[1], y = zero_spot[0]
		print(x); print(y)
		path += 'R'*x + 'D'*y + 'R'*(n-x) + 'D'*(m-y)
		print(path); return;
	else:
		if m == 0 or n == 0:
			if m == 0 and n == 0: print(path); return;
			elif m == 0: print('R'*n + path); return;
			else:	print('D'*m + path); return;
		else: # 0 for 2 and 1 for 5
			if arr[m-1][n][mode] < arr[m][n-1][mode]: backtracker(mode, 'D' + path, m-1,n);
			elif arr[m-1][n][mode] == arr[m][n-1][mode]:
				if arr[m-1][n][(mode + 1)%2] <= arr[m][n-1][(mode + 1)%2]: backtracker(mode, 'D' + path, m-1,n)
				else: backtracker(mode, 'R' + path, m,n-1);
			else: backtracker(mode, 'R' + path, m,n-1);

#first route is for the 2s and second is for the 5s
n = int(input())
arr = [[1]]*n
zero = False
zero_spot = (0, 0)
num_called = 0
for i in range(n):
	a = list(map(sqr_5_converter, (map(int, input().split()))))
	arr[i] = a
for j in range(n):
	for k in range(n):
		if j == 0 or k == 0:
			if j == 0 and k == 0: continue
			elif j == 0: arr[j][k] = (arr[j][k-1][0] + arr[j][k][0], arr[j][k-1][1] + arr[j][k][1])
			else: arr[j][k] = (arr[j-1][k][0] + arr[j][k][0], arr[j-1][k][1] + arr[j][k][1])
		else:
			arr[j][k] = grim_reaper(arr[j][k-1], arr[j-1][k], arr[j][k])
val = min(arr[n-1][n-1][0], arr[n-1][n-1][1])
if zero and val >= 1:
	print(1)
	backtracker(2,'',n-1,n-1)
else:
	print(val)
	if arr[n-1][n-1][0] < arr[n-1][n-1][1]: backtracker(0,'',n-1,n-1)
	else: backtracker(1,'',n-1,n-1)


def sqr_5_converter(n):
	if n != 0:
		b = (n%2 == 0) or (n%5 == 0)
		ori_n = n
		num_2s = 0; num_5s = 0
		while b:
			if n%2 == 0: n = n//2; num_2s += 1;
			if n%5 == 0: n = n//5; num_5s += 1;
			b = (n%2 == 0) or (n%5 == 0)
		return (num_2s, num_5s, ori_n)
	else:
		return (1, 1, n)

def compare_val(tup1, tup2, zero_mode):
	if zero_mode:
		num1_pairs = min(tup1[0], tup1[1])
		num2_pairs = min(tup2[0], tup2[1])
		if num1_pairs == num2_pairs:
			num1_unpairs = max(tup1[0], tup1[1])
			num2_unpairs = max(tup2[0], tup2[1])
			if num1_unpairs == num2_unpairs: return tup1
			elif num1_unpairs > num2_unpairs: return tup2
			else: return tup1
		elif num1_pairs > num2_pairs:	return tup2
		else:	return tup1
	else:
		val1 = tup1[3]
		val2 = tup2[3]
		if val1 == 0 or val2 == 0:
			if val1 == 0 and val2 == 0: return tup1
			elif val1 == 0: return tup2
			else: return tup1
		else: return compare_val(tup1, tup2, True)

n = int(input())
arr = [list(map(sqr_5_converter, (map(int, input().split())))) for _ in range(n)]
arr_nozero = arr
for j in range(n):
	for k in range(n):
		if j == 0 or k == 0: #first row and column
			if j == 0 and k == 0: value = (arr[j][k][0], arr[j][k][1], '', arr[j][k][2]); arr[j][k] = value; arr_nozero[j][k] = value
			elif j == 0: value = (arr[j][k][0] + arr[j][k-1][0], arr[j][k][1] + arr[j][k-1][1], arr[j][k-1][2] + 'R', arr[j][k][2]*arr[j][k-1][3]); arr[j][k] = value; arr_nozero[j][k] = value
			else: value = (arr[j][k][0] + arr[j-1][k][0], arr[j][k][1] + arr[j-1][k][1], arr[j-1][k][2] + 'D', arr[j-1][k][2]*arr[j][k][2]); arr[j][k] = value; arr_nozero[j][k] = value
		else:
			ztup1 = (arr[j-1][k][0] + arr[j][k][0], arr[j-1][k][1] + arr[j][k][1], arr[j-1][k][2] + 'D', arr[j-1][k][3]*arr[j][k][2])
			ztup2 = (arr[j][k-1][0] + arr[j][k][0], arr[j][k-1][1] + arr[j][k][1], arr[j][k-1][2] + 'R', arr[j][k-1][3]*arr[j][k][2])
			nztup1 = (arr_nozero[j-1][k][0] + arr_nozero[j][k][0], arr_nozero[j-1][k][1] + arr_nozero[j][k][1], arr_nozero[j-1][k][2] + 'D', arr_nozero[j-1][k][3]*arr_nozero[j][k][2])
			nztup2 = (arr_nozero[j][k-1][0] + arr_nozero[j][k][0], arr_nozero[j][k-1][1] + arr_nozero[j][k][1], arr_nozero[j][k-1][2] + 'R', arr_nozero[j][k-1][3]*arr_nozero[j][k][2])
			arr[j][k] = compare_val(ztup1,ztup2,True)
			arr_nozero[j][k] = compare_val(nztup1,nztup2,False)
val_zero = min(arr[n-1][n-1][0], arr[n-1][n-1][1])
val = min(arr_nozero[n-1][n-1][0], arr_nozero[n-1][n-1][1])
if val_zero > val:
	print(val)
	print(arr_nozero[n-1][n-1][2])
else:
	print(val_zero)
	print(arr[n-1][n-1][2])


def sqr_5_converter(i):
	global num_called
	num_called += 1
	if i != 0:
		b = (i%2 == 0) or (i%5 == 0); num_2s = 0; num_5s = 0
		while b:
			if i%2 == 0: num_2s += 1; i = i//2;
			if i%5 == 0: num_5s += 1; i = i//5;
			b = (i%2 == 0) or (i%5 == 0)
		return (num_2s, num_5s)
	else:
		global zero
		if not zero:
			zero = True
			global zero_spot
			rem = num_called%n
			quot = num_called//n
			if num_called%n == 0:
				zero_spot = (quot - 1, n - 1)
			else:
				zero_spot = (quot, rem - 1)
		return (1, 1)

#needs to choose the one with less 0's.
def grim_reaper(r, d, add):
	if r[0] < d[0]:
		if r[1] < d[1]: return (r[0] + add[0], r[1] + add[1])
		else: return (r[0] + add[0], d[1] + add[1])
	else:
		if r[1] < d[1]: return (d[0] + add[0], r[1] + add[1])
		else: return (d[0] + add[0], d[1] + add[1])

def backtracker(mode, path, m, n): # backtracker now needs to follow the zero in case of zero
	if mode == 2:
		global zero_spot
		x = zero_spot[1], y = zero_spot[0]
		print('R'*(x - 1) + 'D' * (y - 1) + 'R'* (n - x) + 'D'* (n - y)); return;
	else:
		if m == 0 or n == 0:
			if m == 0 and n == 0: print(path); return;
			elif m == 0: print('R'*n + path); return;
			else:	print('D'*m + path); return;
		else: # 0 for 2 and 1 for 5
			if arr[m-1][n][mode] < arr[m][n-1][mode]: backtracker(mode, 'D' + path, m-1,n);
			elif arr[m-1][n][mode] == arr[m][n-1][mode]:
				if arr[m-1][n][(mode + 1)%2] <= arr[m][n-1][(mode + 1)%2]: backtracker(mode, 'D' + path, m-1,n)
				else: backtracker(mode, 'R' + path, m,n-1);
			else: backtracker(mode, 'R' + path, m,n-1);

#first route is for the 2s and second is for the 5s
n = int(input())
arr = [[1]]*n
zero = False
zero_spot = (0, 0)
num_called = 0
for i in range(n):
	a = list(map(sqr_5_converter, (map(int, input().split()))))
	arr[i] = a
for j in range(n):
	for k in range(n):
		if j == 0 or k == 0:
			if j == 0 and k == 0: continue
			elif j == 0: arr[j][k] = (arr[j][k-1][0] + arr[j][k][0], arr[j][k-1][1] + arr[j][k][1])
			else: arr[j][k] = (arr[j-1][k][0] + arr[j][k][0], arr[j-1][k][1] + arr[j][k][1])
		else:
			arr[j][k] = grim_reaper(arr[j][k-1], arr[j-1][k], arr[j][k])
val = min(arr[n-1][n-1][0], arr[n-1][n-1][1])
if zero and val >= 1:
	print(1)
	backtracker(2,'',n-1,n-1)
else:
	print(val)
	if arr[n-1][n-1][0] < arr[n-1][n-1][1]: backtracker(0,'',n-1,n-1)
	else: backtracker(1,'',n-1,n-1)


def sqr_5_converter(n):
	b = (n%2 == 0) or (n%5 == 0); fac_tup = (0, 0)
	while b:
		if n%2 == 0: fac_tup = (fac_tup[0] + 1, fac_tup[1]); n = n//2;
		if n%5 == 0: fac_tup = (fac_tup[0], fac_tup[1] + 1); n = n//5;
		b = (n%2 == 0) or (n%5 == 0)
	return fac_tup

n = int(input())
arr = [[1]]*n
for i in range(n):
	a = list(map(sqr_5_converter, (map(int, input().split()))))
	arr[i] = a
for j in range(n):
	for k in range(n):
		if j == 0 and k == 0: arr[j][k] = (arr[0][0][0], arr[0][0][1], '')
		elif j == 0: arr[j][k] = (arr[j][k-1][0] + arr[j][k][0], arr[j][k-1][1] + arr[j][k][1], arr[j][k-1][2] + 'R')
		elif k == 0: arr[j][k] = (arr[j-1][k][0] + arr[j][k][0], arr[j-1][k][1] + arr[j][k][1], arr[j-1][k][2] + 'D')
		else:
			can_a = (arr[j-1][k][0] + arr[j][k][0], arr[j-1][k][1] + arr[j][k][1], arr[j-1][k][2] + 'D'); can_b = (arr[j][k-1][0] + arr[j][k][0], arr[j][k-1][1] + arr[j][k][1], arr[j][k-1][2] + 'R')
			num_pair_a = min(can_a[0], can_a[1]); num_pair_b = min(can_b[0], can_b[1])
			if (num_pair_a == 0 and num_pair_b == 0) or (num_pair_a == num_pair_b):
				num_unpair_a = max(can_a[0], can_a[1]); num_unpair_b = max(can_b[0], can_b[1])
				if num_unpair_a >= num_unpair_b: arr[j][k] = can_b
				else: arr[j][k] = can_a
			else:
				if num_pair_a > num_pair_b: arr[j][k] = can_b
				else: arr[j][k] = can_a
print(min(arr[n-1][n-1][0], arr[n-1][n-1][1]))
print(arr[n-1][n-1][2])


def sqr_5_converter(n):
	if n != 0:
		b = (n%2 == 0) or (n%5 == 0); ori_n = n; num_2s = 0; num_5s = 0
		while b:
			if n%2 == 0: num_2s += 1; n = n//2;
			if n%5 == 0: num_5s += 1; n = n//5;
			b = (n%2 == 0) or (n%5 == 0)
		return (num_2s, num_5s, ori_n, ori_n)
	else:
		return (1, 1, n, n)

def grim_reaper(r, d, add):
	res0 = res1 = res2 = res3= 0;
	if r[0] < d[0]:
		res0 = r[0] + add[0]
		res2 = r[2] * add[2]
	elif r[0] == d[0]:
		if r[2] <= d[2]:
			res0 = r[0] + add[0]
			res2 = r[2] * add[2]
		else:
			res0 = d[0] + add[0]
			res2 = d[2] * add[2]
	else:
		res0 = d[0] + add[0]
		res2 = d[2] * add[3]
	if r[1] < d[1]:
		res1 = r[1] + add[1]
		res3 = r[3] * add[3]
	elif r[1] == d[1]:
		if r[2] <= d[2]:
			res1 = r[1] + add[1]
			res3 = r[3] * add[3]
		else:
			res1 = d[1] + add[1]
			res3 = d[3] * add[3]
	else:
		res1 = d[1] + add[1]
		res3 = d[3] * add[3]
	return (res0, res1, res2,res3)

def backtracker(mode, path, m, n):
	if m == 0 or n == 0:
		if m == 0 and n == 0: print(path); return;
		elif m == 0: print('R'*n + path); return;
		else:	print('D'*m + path); return;
	else: # 0 for 2 and 1 for 5
		if arr[m-1][n][mode] < arr[m][n-1][mode]: backtracker(mode, 'D' + path, m-1,n);
		elif arr[m-1][n][mode] == arr[m][n-1][mode]:
			if arr[m-1][n][(mode + 1)%2] <= arr[m][n-1][(mode + 1)%2]: backtracker(mode, 'D' + path, m-1,n)
			else: backtracker(mode, 'R' + path, m,n-1);
		else: backtracker(mode, 'R' + path, m,n-1);

#first route is for the 2s and second is for the 5s
n = int(input())
arr = [[1]]*n
zero_ex = False
for i in range(n):
	a = list(map(sqr_5_converter, (map(int, input().split()))))
	arr[i] = a
for j in range(n):
	for k in range(n):
		if j == 0 or k == 0:
			if j == 0 and k == 0: continue
			elif j == 0: arr[j][k] = (arr[j][k-1][0] + arr[j][k][0], arr[j][k-1][1] + arr[j][k][1], arr[j][k-1][2]*arr[j][k][2], arr[j][k-1][3]*arr[j][k][3])
			else: arr[j][k] = (arr[j-1][k][0] + arr[j][k][0], arr[j-1][k][1] + arr[j][k][1], arr[j-1][k][2]*arr[j][k][2], arr[j-1][k-1][3]*arr[j][k][3])
		else:
			arr[j][k] = grim_reaper(arr[j][k-1], arr[j-1][k], arr[j][k])
val = min(arr[n-1][n-1][0], arr[n-1][n-1][1])
zero = arr[n-1][n-1][2] * arr[n-1][n-1][3] == 0
if zero:
	print(1)
	if arr[n-1][n-1][2] == 0: backtracker(0,'',n-1,n-1)
	else: backtracker(1,'',n-1,n-1)
else:
	print(val)
	if arr[n-1][n-1][0] < arr[n-1][n-1][1]: backtracker(0,'',n-1,n-1)
	else: backtracker(1,'',n-1,n-1)


def sqr_5_converter(i):
	global num_called
	num_called += 1
	if i != 0:
		b = (i%2 == 0) or (i%5 == 0); num_2s = 0; num_5s = 0
		while b:
			if i%2 == 0: num_2s += 1; i = i//2;
			if i%5 == 0: num_5s += 1; i = i//5;
			b = (i%2 == 0) or (i%5 == 0)
		return (num_2s, num_5s)
	else:
		global zero
		if not zero:
			zero = True
			global zero_spot
			rem = num_called%n
			quot = num_called//n
			if num_called%n == 0:
				zero_spot = (quot - 1, n - 1)
			else:
				zero_spot = (quot, rem - 1)
		return (1, 1)

#needs to choose the one with less 0's.
def grim_reaper(r, d, add):
	if r[0] < d[0]:
		if r[1] < d[1]: return (r[0] + add[0], r[1] + add[1])
		else: return (r[0] + add[0], d[1] + add[1])
	else:
		if r[1] < d[1]: return (d[0] + add[0], r[1] + add[1])
		else: return (d[0] + add[0], d[1] + add[1])

def backtracker(mode, path, m, n): # backtracker now needs to follow the zero in case of zero
	if mode == 2:
		global zero_spot
		x = zero_spot[1], y = zero_spot[0]
		print(('R'*x) + ('D' *y) + ('R'* (n - x)) + ('D'* (m - y)) + path); return;
	else:
		if m == 0 or n == 0:
			if m == 0 and n == 0: print(path); return;
			elif m == 0: print('R'*n + path); return;
			else:	print('D'*m + path); return;
		else: # 0 for 2 and 1 for 5
			if arr[m-1][n][mode] < arr[m][n-1][mode]: backtracker(mode, 'D' + path, m-1,n);
			elif arr[m-1][n][mode] == arr[m][n-1][mode]:
				if arr[m-1][n][(mode + 1)%2] <= arr[m][n-1][(mode + 1)%2]: backtracker(mode, 'D' + path, m-1,n)
				else: backtracker(mode, 'R' + path, m,n-1);
			else: backtracker(mode, 'R' + path, m,n-1);

#first route is for the 2s and second is for the 5s
n = int(input())
arr = [[1]]*n
zero = False
zero_spot = (0, 0)
num_called = 0
for i in range(n):
	a = list(map(sqr_5_converter, (map(int, input().split()))))
	arr[i] = a
for j in range(n):
	for k in range(n):
		if j == 0 or k == 0:
			if j == 0 and k == 0: continue
			elif j == 0: arr[j][k] = (arr[j][k-1][0] + arr[j][k][0], arr[j][k-1][1] + arr[j][k][1])
			else: arr[j][k] = (arr[j-1][k][0] + arr[j][k][0], arr[j-1][k][1] + arr[j][k][1])
		else:
			arr[j][k] = grim_reaper(arr[j][k-1], arr[j-1][k], arr[j][k])
val = min(arr[n-1][n-1][0], arr[n-1][n-1][1])
if zero and val >= 1:
	print(1)
	backtracker(2,'',n-1,n-1)
else:
	print(val)
	if arr[n-1][n-1][0] < arr[n-1][n-1][1]: backtracker(0,'',n-1,n-1)
	else: backtracker(1,'',n-1,n-1)


def sqr_5_converter(n):
	if n != 0:
		b = (n%2 == 0) or (n%5 == 0)
		ori_n = n
		num_2s = 0; num_5s = 0
		while b:
			if n%2 == 0: n = n//2; num_2s += 1;
			if n%5 == 0: n = n//5; num_5s += 1;
			b = (n%2 == 0) or (n%5 == 0)
		return (num_2s, num_5s, ori_n)
	else:
		return (1, 1, n)

def compare_val(tup1, tup2, zero_mode):
	if zero_mode:
		num1_pairs = min(tup1[0], tup1[1])
		num2_pairs = min(tup2[0], tup2[1])
		if num1_pairs == num2_pairs:
			num1_unpairs = max(tup1[0], tup1[1])
			num2_unpairs = max(tup2[0], tup2[1])
			if num1_unpairs == num2_unpairs: return tup1
			elif num1_unpairs > num2_unpairs: return tup2
			else: return tup1
		elif num1_pairs > num2_pairs:	return tup2
		else:	return tup1
	else:
		val1 = tup1[3]
		val2 = tup2[3]
		if val1 == 0 or val2 == 0:
			if val1 == 0 and val2 == 0: return tup1
			elif val1 == 0: return tup2
			else: return tup1
		else: return compare_val(tup1, tup2, True)

n = int(input())
arr = [list(map(sqr_5_converter, (map(int, input().split())))) for _ in range(n)]
arr_nozero = arr
for j in range(n):
	for k in range(n):
		if j == 0 or k == 0: #first row and column
			if j == 0 and k == 0: value = (arr[j][k][0], arr[j][k][1], '', arr[j][k][2]); arr[j][k] = value; arr_nozero[j][k] = value
			elif j == 0: value = (arr[j][k][0] + arr[j][k-1][0], arr[j][k][1] + arr[j][k-1][1], arr[j][k-1][2] + 'R', arr[j][k][2]*arr[j][k-1][3]); arr[j][k] = value; arr_nozero[j][k] = value
			else: arr[j][k] = arr[0][0]; value = (arr[j][k][0] + arr[j-1][k][0], arr[j][k][1] + arr[j-1][k][1], arr[j-1][k][2] + 'D', arr[j-1][k][2]*arr[j][k][3]); arr[j][k] = value; arr_nozero[j][k] = value
		else:
			ztup1 = (arr[j-1][k][0] + arr[j][k][0], arr[j-1][k][1] + arr[j][k][1], arr[j-1][k][2] + 'D', arr[j-1][k][3]*arr[j][k])
			ztup2 = (arr[j][k-1][0] + arr[j][k][0], arr[j][k-1][1] + arr[j][k][1], arr[j][k-1][2] + 'R', arr[j][k-1][3]*arr[j][k])
			nztup1 = (arr_nozero[j-1][k][0] + arr_nozero[j][k][0], arr[j-1][k][1] + arr[j][k][1], arr[j-1][k][2] + 'D', arr[j-1][k][3]*arr[j][k])
			nztup2 = (arr_nozero[j][k-1][0] + arr_nozero[j][k][0], arr_nozero[j][k-1][1] + arr_nozero[j][k][1], arr_nozero[j][k-1][2] + 'R', arr_nozero[j][k-1][3]*arr_nozero[j][k])
			arr[j][k] = compare_val(ztup1,ztup2,True)
			arr_nozero[j][k] = compare_val(nztup1,nztup2,False)
val_zero = min(arr[n-1][n-1][0], arr[n-1][n-1][1])
val = min(arr_nozero[n-1][n-1], arr_nozero[n-1][n-1])
if val_zero >= val:
	print(val)
	print(arr_nozero[n-1][n-1][2])
else:
	print(val_zero)
	print(arr[n-1][n-1][2])


def sqr_5_converter(n):
	if n != 0:
		b = (n%2 == 0) or (n%5 == 0); num_2s = 0; num_5s = 0
		while b:
			if n%2 == 0: num_2s += 1; n = n//2;
			if n%5 == 0: num_5s += 1; n = n//5;
			b = (n%2 == 0) or (n%5 == 0)
		return (num_2s, num_5s)
	else:
		global zero
		zero = True
		return (1, 1)

#needs to choose the one with less 0's.
def grim_reaper(r, d, add):
	if r[0] < d[0]:
		if r[1] < d[1]: return (r[0] + add[0], r[1] + add[1])
		else: return (r[0] + add[0], d[1] + add[1])
	else:
		if r[1] < d[1]: return (d[0] + add[0], r[1] + add[1])
		else: return (d[0] + add[0], d[1] + add[1])

def backtracker(mode, path, m, n):
	if m == 0 or n == 0:
		if m == 0 and n == 0: print(path); return;
		elif m == 0: print('R'*n + path); return;
		else:	print('D'*m + path); return;
	else: # 0 for 2 and 1 for 5
		if arr[m-1][n][mode] < arr[m][n-1][mode]: backtracker(mode, 'D' + path, m-1,n);
		elif arr[m-1][n][mode] == arr[m][n-1][mode]:
			if arr[m-1][n][(mode + 1)%2] <= arr[m][n-1][(mode + 1)%2]: backtracker(mode, 'D' + path, m-1,n)
			else: backtracker(mode, 'R' + path, m,n-1);
		else: backtracker(mode, 'R' + path, m,n-1);

#first route is for the 2s and second is for the 5s
n = int(input())
arr = [[1]]*n
zero = False
for i in range(n):
	a = list(map(sqr_5_converter, (map(int, input().split()))))
	arr[i] = a
for j in range(n):
	for k in range(n):
		if j == 0 or k == 0:
			if j == 0 and k == 0: continue
			elif j == 0: arr[j][k] = (arr[j][k-1][0] + arr[j][k][0], arr[j][k-1][1] + arr[j][k][1])
			else: arr[j][k] = (arr[j-1][k][0] + arr[j][k][0], arr[j-1][k][1] + arr[j][k][1])
		else:
			arr[j][k] = grim_reaper(arr[j][k-1], arr[j-1][k], arr[j][k])
val = min(arr[n-1][n-1][0], arr[n-1][n-1][1])
if zero and val >= 1:
	print(1)
	backtracker(1,'',n-1,n-1)
else:
	print(val)
	if arr[n-1][n-1][0] < arr[n-1][n-1][1]: backtracker(0,'',n-1,n-1)
	else: backtracker(1,'',n-1,n-1)


def sqr_5_converter(i):
	global num_called
	num_called += 1
	if i != 0:
		b = (i%2 == 0) or (i%5 == 0); num_2s = 0; num_5s = 0
		while b:
			if i%2 == 0: num_2s += 1; i = i//2;
			if i%5 == 0: num_5s += 1; i = i//5;
			b = (i%2 == 0) or (i%5 == 0)
		return (num_2s, num_5s)
	else:
		global zero
		if not zero:
			zero = True
			global zero_spot
			rem = num_called%n
			quot = num_called//n
			if num_called%n == 0:
				zero_spot = (quot - 1, n - 1)
			else:
				zero_spot = (quot, rem - 1)
		return (1, 1)

#needs to choose the one with less 0's.
def grim_reaper(r, d, add):
	if r[0] < d[0]:
		if r[1] < d[1]: return (r[0] + add[0], r[1] + add[1])
		else: return (r[0] + add[0], d[1] + add[1])
	else:
		if r[1] < d[1]: return (d[0] + add[0], r[1] + add[1])
		else: return (d[0] + add[0], d[1] + add[1])

def backtracker(mode, path, m, n): # backtracker now needs to follow the zero in case of zero
	if mode == 2:
		global zero_spot
		global n
		x = zero_spot[0], y = zero_spot[1]
		path_from_0 = 'R'* (n - 1 - x) + 'D'* (n - 1 - y)
		path_to_0 = 'R'*(x - 1) + 'D' * (y - 1)
		print(path_to_0 + path_from_0)
	else:
		if m == 0 or n == 0:
			if m == 0 and n == 0: print(path); return;
			elif m == 0: print('R'*n + path); return;
			else:	print('D'*m + path); return;
		else: # 0 for 2 and 1 for 5
			if arr[m-1][n][mode] < arr[m][n-1][mode]: backtracker(mode, 'D' + path, m-1,n);
			elif arr[m-1][n][mode] == arr[m][n-1][mode]:
				if arr[m-1][n][(mode + 1)%2] <= arr[m][n-1][(mode + 1)%2]: backtracker(mode, 'D' + path, m-1,n)
				else: backtracker(mode, 'R' + path, m,n-1);
			else: backtracker(mode, 'R' + path, m,n-1);

#first route is for the 2s and second is for the 5s
n = int(input())
arr = [[1]]*n
zero = False
zero_spot = (0, 0)
num_called = 0
for i in range(n):
	a = list(map(sqr_5_converter, (map(int, input().split()))))
	arr[i] = a
for j in range(n):
	for k in range(n):
		if j == 0 or k == 0:
			if j == 0 and k == 0: continue
			elif j == 0: arr[j][k] = (arr[j][k-1][0] + arr[j][k][0], arr[j][k-1][1] + arr[j][k][1])
			else: arr[j][k] = (arr[j-1][k][0] + arr[j][k][0], arr[j-1][k][1] + arr[j][k][1])
		else:
			arr[j][k] = grim_reaper(arr[j][k-1], arr[j-1][k], arr[j][k])
val = min(arr[n-1][n-1][0], arr[n-1][n-1][1])
if zero and val >= 1:
	print(1)
	backtracker(2,'',n-1,n-1)
else:
	print(val)
	if arr[n-1][n-1][0] < arr[n-1][n-1][1]: backtracker(0,'',n-1,n-1)
	else: backtracker(1,'',n-1,n-1)


def sqr_5_converter(n):
	if n != 0:
		b = (n%2 == 0) or (n%5 == 0); num_2s = 0; num_5s = 0
		while b:
			if n%2 == 0: num_2s += 1; n = n//2;
			if n%5 == 0: num_5s += 1; n = n//5;
			b = (n%2 == 0) or (n%5 == 0)
		return (num_2s, num_5s, False, False)
	else:
		return (1, 1, True, True)

#needs to choose the one with less 0's.
def grim_reaper(r, d, add):
	res0 = res1 = 0;
	if r[0] < d[0]:
		res0 = r[0] + add[0]
		res2 = r[2] and add[2]
	else:
		res0 = d[0] + add[0]
		res2 = d[2] and add[2]
	if r[1] < d[1]:
		res1 = r[1] + add[1]
		res3 = r[3] and add[3]
	else:
		res1 = d[1] + add[1]
		res3 = d[3] and add[3]
	return (res0, res1, res2,res3)

def backtracker(mode, path, m, n):
	if m == 0 or n == 0:
		if m == 0 and n == 0: print(path); return;
		elif m == 0: print('R'*n + path); return;
		else:	print('D'*m + path); return;
	else: # 0 for 2 and 1 for 5
		if arr[m-1][n][mode] < arr[m][n-1][mode]: backtracker(mode, 'D' + path, m-1,n);
		elif arr[m-1][n][mode] == arr[m][n-1][mode]:
			if arr[m-1][n][(mode + 1)%2] <= arr[m][n-1][(mode + 1)%2]: backtracker(mode, 'D' + path, m-1,n)
			else: backtracker(mode, 'R' + path, m,n-1);
		else: backtracker(mode, 'R' + path, m,n-1);

#first route is for the 2s and second is for the 5s
n = int(input())
arr = [[1]]*n
for i in range(n):
	a = list(map(sqr_5_converter, (map(int, input().split()))))
	arr[i] = a
for j in range(n):
	for k in range(n):
		if j == 0 or k == 0:
			if j == 0 and k == 0: continue
			elif j == 0: arr[j][k] = (arr[j][k-1][0] + arr[j][k][0], arr[j][k-1][1] + arr[j][k][1], arr[j][k-1][2] and arr[j][k][2], arr[j][k-1][3] and arr[j][k][3])
			else: arr[j][k] = (arr[j-1][k][0] + arr[j][k][0], arr[j-1][k][1] + arr[j][k][1], arr[j-1][k][2] and arr[j][k][2], arr[j-1][k][3] and arr[j][k][3])
		else:
			arr[j][k] = grim_reaper(arr[j][k-1], arr[j-1][k], arr[j][k])
val = min(arr[n-1][n-1][0], arr[n-1][n-1][1])
zero = arr[n-1][n-1][2] or arr[n-1][n-1][3]
if zero and val > 1:
	print(1)
	if arr[n-1][n-1][2] == 0: backtracker(0,'',n-1,n-1)
	else: backtracker(1,'',n-1,n-1)
else:
	print(val)
	if arr[n-1][n-1][0] < arr[n-1][n-1][1]: backtracker(0,'',n-1,n-1)
	else: backtracker(1,'',n-1,n-1)


import sys
input=sys.stdin.readline
n=int(input())

tl=[[0]*(n+1)]
fl=[[0]*(n+1)]
for i in range(n):
    x=[0]
    y=[0]
    w=list(map(int,input().split()))
    for j in range(n):
        d=[0,0]
        a=w[j]
        while(a%2==0):
            d[0]+=1
            a//=2
        while(a%5==0):
            d[1]+=1
            a//=5
        x.append(d[0])
        y.append(d[1])

    tl.append(x)
    fl.append(y)

dp=[]

for i in range(n+1):
    x=[0]*(n+1)
    dp.append(x)
for i in range(1,n+1):
    for j in range(1,n+1):
        a=10**9
        b=10**9
        if(j==1 and i==1):
            dp[i][j]=tl[i][j]
        else:
            if(i-1):
                a=dp[i-1][j]+tl[i][j]
            if(j-1):
                b=dp[i][j-1]+tl[i][j]
            dp[i][j]=min(a,b)

i=n
j=n
s=""
while(i>1 and j>1):
    if(dp[i-1][j]>dp[i][j-1]):
        s="R"+s
        j-=1
    else:
        s="D"+s
        i-=1
if(i+j!=2):
    if(i!=1):
        while(i!=1):
            s="D"+s
            i-=1
    else:
        while(j!=1):
            s="R"+s
            j-=1

fp=[]

for i in range(n+1):
    x=[0]*(n+1)
    fp.append(x)

for i in range(1,n+1):
    for j in range(1,n+1):
        a=10**9
        b=10**9
        if(i==1 and j==1):
            fp[i][j]=fl[i][j]
        else:
            if(i-1):
                a=fp[i-1][j]+fl[i][j]
            if(j-1):
                b=fp[i][j-1]+fl[i][j]
            fp[i][j]=min(a,b)

i=n
j=n
w=""
while(i>1 and j>1):
    if(fp[i-1][j]>fp[i][j-1]):
        w="R"+w
        j-=1
    else:
        w="D"+w
        i-=1
if(i+j!=2):
    if(i!=1):
        while(i!=1):
            w="D"+w
            i-=1
    else:
        while(j!=1):
            w="R"+w
            j-=1
if(dp[n][n]>=fp[n][n]):
    print(fp[n][n])
    print(w)
else:
    print(dp[n][n])
    print(s)


import sys
input=sys.stdin.readline
print=sys.stdout.write
n=int(input())
shake=0
tl=[[0]*(n+1)]
fl=[[0]*(n+1)]
for i in range(n):
    x=[0]
    y=[0]
    w=list(map(int,input().split()))
    for j in range(n):
        d=[0,0]
        a=w[j]
        if(a==0):
            shake=1
            index=(i,j)
        while(a%2==0 and a!=0):
            d[0]+=1
            a//=2
        while(a%5==0 and a!=0):
            d[1]+=1
            a//=5
        x.append(d[0])
        y.append(d[1])

    tl.append(x)
    fl.append(y)
if(shake):
    i,j=index[0],index[1]
    s="R"*(j-1)
    s+="D"*(i-1)
    s+="R"*(n-j)
    s+="D"*(n-i)
    print(str(1))
    print("\n")
    print(s)

else:
    dp=[]
    for i in range(n+1):
        x=[0]*(n+1)
        dp.append(x)
    for i in range(1,n+1):
        for j in range(1,n+1):
            a=10**9
            b=10**9
            if(j==1 and i==1):
                dp[i][j]=tl[i][j]
            else:
                if(i-1):
                    a=dp[i-1][j]+tl[i][j]
                if(j-1):
                    b=dp[i][j-1]+tl[i][j]
                dp[i][j]=min(a,b)

    fp=[]

    for i in range(n+1):
        x=[0]*(n+1)
        fp.append(x)

    for i in range(1,n+1):
        for j in range(1,n+1):
            a=10**9
            b=10**9
            if(i==1 and j==1):
                fp[i][j]=fl[i][j]
            else:
                if(i-1):
                    a=fp[i-1][j]+fl[i][j]
                if(j-1):
                    b=fp[i][j-1]+fl[i][j]
                fp[i][j]=min(a,b)

    if(dp[n][n]>=fp[n][n]):
        print(str(fp[n][n]))
        print("\n")
        i=n
        j=n
        w=""
        while(i>1 and j>1):
            if(fp[i-1][j]>fp[i][j-1]):
                w="R"+w
                j-=1
            else:
                w="D"+w
                i-=1
        if(i+j!=2):
            if(i!=1):
                while(i!=1):
                    w="D"+w
                    i-=1
            else:
                while(j!=1):
                    w="R"+w
                    j-=1
        print(w)
    else:
        print(str(dp[n][n]))
        print("\n")
        i=n
        j=n
        s=""
        while(i>1 and j>1):
            if(dp[i-1][j]>dp[i][j-1]):
                s="R"+s
                j-=1
            else:
                s="D"+s
                i-=1
        if(i+j!=2):
            if(i!=1):
                while(i!=1):
                    s="D"+s
                    i-=1
            else:
                while(j!=1):
                    s="R"+s
                    j-=1
        print(s)


import sys
input=sys.stdin.readline
print=sys.stdout.write
n=int(input())

tl=[[0]*(n+1)]
fl=[[0]*(n+1)]
for i in range(n):
    x=[0]
    y=[0]
    w=list(map(int,input().split()))
    for j in range(n):
        d=[0,0]
        a=w[j]
        while(a%2==0 and a!=0):
            d[0]+=1
            a//=2
        while(a%5==0 and a!=0):
            d[1]+=1
            a//=5
        x.append(d[0])
        y.append(d[1])

    tl.append(x)
    fl.append(y)

dp=[]

for i in range(n+1):
    x=[0]*(n+1)
    dp.append(x)
for i in range(1,n+1):
    for j in range(1,n+1):
        a=10**9
        b=10**9
        if(j==1 and i==1):
            dp[i][j]=tl[i][j]
        else:
            if(i-1):
                a=dp[i-1][j]+tl[i][j]
            if(j-1):
                b=dp[i][j-1]+tl[i][j]
            dp[i][j]=min(a,b)

fp=[]

for i in range(n+1):
    x=[0]*(n+1)
    fp.append(x)

for i in range(1,n+1):
    for j in range(1,n+1):
        a=10**9
        b=10**9
        if(i==1 and j==1):
            fp[i][j]=fl[i][j]
        else:
            if(i-1):
                a=fp[i-1][j]+fl[i][j]
            if(j-1):
                b=fp[i][j-1]+fl[i][j]
            fp[i][j]=min(a,b)

if(dp[n][n]>=fp[n][n]):
    print(str(fp[n][n]))
    print("\n")
    i=n
    j=n
    w=""
    while(i>1 and j>1):
        if(fp[i-1][j]>fp[i][j-1]):
            w="R"+w
            j-=1
        else:
            w="D"+w
            i-=1
    if(i+j!=2):
        if(i!=1):
            while(i!=1):
                w="D"+w
                i-=1
        else:
            while(j!=1):
                w="R"+w
                j-=1
    print(w)
else:
    print(str(dp[n][n]))
    print("\n")
    i=n
    j=n
    s=""
    while(i>1 and j>1):
        if(dp[i-1][j]>dp[i][j-1]):
            s="R"+s
            j-=1
        else:
            s="D"+s
            i-=1
    if(i+j!=2):
        if(i!=1):
            while(i!=1):
                s="D"+s
                i-=1
        else:
            while(j!=1):
                s="R"+s
                j-=1
    print(s)


import sys
input=sys.stdin.readline
print=sys.stdout.write
n=int(input())

tl=[[0]*(n+1)]
fl=[[0]*(n+1)]
for i in range(n):
    x=[0]
    y=[0]
    w=list(map(int,input().split()))
    for j in range(n):
        d=[0,0]
        a=w[j]
        while(a%2==0):
            d[0]+=1
            a//=2
        while(a%5==0):
            d[1]+=1
            a//=5
        x.append(d[0])
        y.append(d[1])

    tl.append(x)
    fl.append(y)

dp=[]

for i in range(n+1):
    x=[0]*(n+1)
    dp.append(x)
for i in range(1,n+1):
    for j in range(1,n+1):
        a=10**9
        b=10**9
        if(j==1 and i==1):
            dp[i][j]=tl[i][j]
        else:
            if(i-1):
                a=dp[i-1][j]+tl[i][j]
            if(j-1):
                b=dp[i][j-1]+tl[i][j]
            dp[i][j]=min(a,b)

fp=[]

for i in range(n+1):
    x=[0]*(n+1)
    fp.append(x)

for i in range(1,n+1):
    for j in range(1,n+1):
        a=10**9
        b=10**9
        if(i==1 and j==1):
            fp[i][j]=fl[i][j]
        else:
            if(i-1):
                a=fp[i-1][j]+fl[i][j]
            if(j-1):
                b=fp[i][j-1]+fl[i][j]
            fp[i][j]=min(a,b)

if(dp[n][n]>=fp[n][n]):
    print(str(fp[n][n]))
    print("\n")
    i=n
    j=n
    w=""
    while(i>1 and j>1):
        if(fp[i-1][j]>fp[i][j-1]):
            w="R"+w
            j-=1
        else:
            w="D"+w
            i-=1
    if(i+j!=2):
        if(i!=1):
            while(i!=1):
                w="D"+w
                i-=1
        else:
            while(j!=1):
                w="R"+w
                j-=1
    print(w)
else:
    print(str(dp[n][n]))
    print("\n")
    i=n
    j=n
    s=""
    while(i>1 and j>1):
        if(dp[i-1][j]>dp[i][j-1]):
            s="R"+s
            j-=1
        else:
            s="D"+s
            i-=1
    if(i+j!=2):
        if(i!=1):
            while(i!=1):
                s="D"+s
                i-=1
        else:
            while(j!=1):
                s="R"+s
                j-=1
    print(s)


import sys,math
input=sys.stdin.readline
print=sys.stdout.write
n=int(input())
def primefact(n,b):
    lo=0
    hi=int(math.log(n,b))
    if(hi==0):
        return 0
    while(lo<hi):
        mid=(lo+hi)//2
        if(n%pow(b,mid)==0):
           lo=mid+1
        else:
           hi=mid-1
    if(n%pow(b,lo)==0):
        return lo
    else:
        #print("s")
        return lo-1

#print(str(primefact(3072,2)))
#print(str(primefact(250,5)))
tl=[[0]*(n+1)]
fl=[[0]*(n+1)]
for i in range(n):
    x=[0]
    y=[0]
    w=list(map(int,input().split()))
    for j in range(n):
        a=w[j]
        if(a==0):
            x.append(0)
            y.append(0)
        else:
            x.append(primefact(a,2))
            y.append(primefact(a,5))

    tl.append(x)
    fl.append(y)

dp=[]

for i in range(n+1):
    x=[0]*(n+1)
    dp.append(x)
for i in range(1,n+1):
    for j in range(1,n+1):
        a=10**9
        b=10**9
        if(j==1 and i==1):
            dp[i][j]=tl[i][j]
        else:
            if(i-1):
                a=dp[i-1][j]+tl[i][j]
            if(j-1):
                b=dp[i][j-1]+tl[i][j]
            dp[i][j]=min(a,b)

fp=[]

for i in range(n+1):
    x=[0]*(n+1)
    fp.append(x)

for i in range(1,n+1):
    for j in range(1,n+1):
        a=10**9
        b=10**9
        if(i==1 and j==1):
            fp[i][j]=fl[i][j]
        else:
            if(i-1):
                a=fp[i-1][j]+fl[i][j]
            if(j-1):
                b=fp[i][j-1]+fl[i][j]
            fp[i][j]=min(a,b)

if(dp[n][n]>=fp[n][n]):
    print(str(fp[n][n]))
    print("\n")
    i=n
    j=n
    w=""
    while(i>1 and j>1):
        if(fp[i-1][j]>fp[i][j-1]):
            w="R"+w
            j-=1
        else:
            w="D"+w
            i-=1
    if(i+j!=2):
        if(i!=1):
            while(i!=1):
                w="D"+w
                i-=1
        else:
            while(j!=1):
                w="R"+w
                j-=1
    print(w)
else:
    print(str(dp[n][n]))
    print("\n")
    i=n
    j=n
    s=""
    while(i>1 and j>1):
        if(dp[i-1][j]>dp[i][j-1]):
            s="R"+s
            j-=1
        else:
            s="D"+s
            i-=1
    if(i+j!=2):
        if(i!=1):
            while(i!=1):
                s="D"+s
                i-=1
        else:
            while(j!=1):
                s="R"+s
                j-=1
    print(s)


import sys
input=sys.stdin.readline
print=sys.stdout.write
n=int(input())

tl=[[0]*(n+1)]
fl=[[0]*(n+1)]
for i in range(n):
    x=[0]
    y=[0]
    w=list(map(int,input().split()))
    for j in range(n):
        d=[0,0]
        a=w[j]
        while(a%2==0):
            d[0]+=1
            a//=2
        while(a%5==0):
            d[1]+=1
            a//=5
        x.append(d[0])
        y.append(d[1])

    tl.append(x)
    fl.append(y)

dp=[]

for i in range(n+1):
    x=[0]*(n+1)
    dp.append(x)
for i in range(1,n+1):
    for j in range(1,n+1):
        a=10**9
        b=10**9
        if(j==1 and i==1):
            dp[i][j]=tl[i][j]
        else:
            if(i-1):
                a=dp[i-1][j]+tl[i][j]
            if(j-1):
                b=dp[i][j-1]+tl[i][j]
            dp[i][j]=min(a,b)

i=n
j=n
s=""
while(i>1 and j>1):
    if(dp[i-1][j]>dp[i][j-1]):
        s="R"+s
        j-=1
    else:
        s="D"+s
        i-=1
if(i+j!=2):
    if(i!=1):
        while(i!=1):
            s="D"+s
            i-=1
    else:
        while(j!=1):
            s="R"+s
            j-=1

fp=[]

for i in range(n+1):
    x=[0]*(n+1)
    fp.append(x)

for i in range(1,n+1):
    for j in range(1,n+1):
        a=10**9
        b=10**9
        if(i==1 and j==1):
            fp[i][j]=fl[i][j]
        else:
            if(i-1):
                a=fp[i-1][j]+fl[i][j]
            if(j-1):
                b=fp[i][j-1]+fl[i][j]
            fp[i][j]=min(a,b)

i=n
j=n
w=""
while(i>1 and j>1):
    if(fp[i-1][j]>fp[i][j-1]):
        w="R"+w
        j-=1
    else:
        w="D"+w
        i-=1
if(i+j!=2):
    if(i!=1):
        while(i!=1):
            w="D"+w
            i-=1
    else:
        while(j!=1):
            w="R"+w
            j-=1
if(dp[n][n]>=fp[n][n]):
    print(str(fp[n][n]))
    print("\n")
    print(w)
else:
    print(str(dp[n][n]))
    print("\n")
    print(s)


import sys
input=sys.stdin.readline
print=sys.stdout.write
n=int(input())
shake=0
tl=[[0]*(n+1)]
fl=[[0]*(n+1)]
for i in range(n):
    x=[0]
    y=[0]
    w=list(map(int,input().split()))
    for j in range(n):
        d=[0,0]
        a=w[j]
        if(a==0):
            shake=1
            index=(i,j)
        while(a%2==0 and a!=0):
            d[0]+=1
            a//=2
        while(a%5==0 and a!=0):
            d[1]+=1
            a//=5
        x.append(d[0])
        y.append(d[1])

    tl.append(x)
    fl.append(y)
if(shake):
    i,j=index[0],index[1]
    s="R"*(j)
    s+="D"*(i)
    s+="R"*(n-j-1)
    s+="D"*(n-i-1)
    print(str(1))
    print("\n")
    print(s)

else:
    dp=[]
    for i in range(n+1):
        x=[0]*(n+1)
        dp.append(x)
    for i in range(1,n+1):
        for j in range(1,n+1):
            a=10**9
            b=10**9
            if(j==1 and i==1):
                dp[i][j]=tl[i][j]
            else:
                if(i-1):
                    a=dp[i-1][j]+tl[i][j]
                if(j-1):
                    b=dp[i][j-1]+tl[i][j]
                dp[i][j]=min(a,b)

    fp=[]

    for i in range(n+1):
        x=[0]*(n+1)
        fp.append(x)

    for i in range(1,n+1):
        for j in range(1,n+1):
            a=10**9
            b=10**9
            if(i==1 and j==1):
                fp[i][j]=fl[i][j]
            else:
                if(i-1):
                    a=fp[i-1][j]+fl[i][j]
                if(j-1):
                    b=fp[i][j-1]+fl[i][j]
                fp[i][j]=min(a,b)

    if(dp[n][n]>=fp[n][n]):
        print(str(fp[n][n]))
        print("\n")
        i=n
        j=n
        w=""
        while(i>1 and j>1):
            if(fp[i-1][j]>fp[i][j-1]):
                w="R"+w
                j-=1
            else:
                w="D"+w
                i-=1
        if(i+j!=2):
            if(i!=1):
                while(i!=1):
                    w="D"+w
                    i-=1
            else:
                while(j!=1):
                    w="R"+w
                    j-=1
        print(w)
    else:
        print(str(dp[n][n]))
        print("\n")
        i=n
        j=n
        s=""
        while(i>1 and j>1):
            if(dp[i-1][j]>dp[i][j-1]):
                s="R"+s
                j-=1
            else:
                s="D"+s
                i-=1
        if(i+j!=2):
            if(i!=1):
                while(i!=1):
                    s="D"+s
                    i-=1
            else:
                while(j!=1):
                    s="R"+s
                    j-=1
        print(s)


import sys
input=sys.stdin.readline
print=sys.stdout.write
n=int(input())
shake=0
tl=[[0]*(n+1)]
fl=[[0]*(n+1)]
for i in range(n):
    x=[0]
    y=[0]
    w=list(map(int,input().split()))
    for j in range(n):
        d=[0,0]
        a=w[j]
        if(a==0):
            shake=1
            index=(i,j)
        while(a%2==0 and a!=0):
            d[0]+=1
            a//=2
        while(a%5==0 and a!=0):
            d[1]+=1
            a//=5
        x.append(d[0])
        y.append(d[1])

    tl.append(x)
    fl.append(y)
if(shake):
    i,j=index[0],index[1]
    ss="R"*(j)
    ss+="D"*(i)
    ss+="R"*(n-j-1)
    ss+="D"*(n-i-1)

dp=[]
for i in range(n+1):
    x=[0]*(n+1)
    dp.append(x)
for i in range(1,n+1):
    for j in range(1,n+1):
        a=10**9
        b=10**9
        if(j==1 and i==1):
            dp[i][j]=tl[i][j]
        else:
            if(i-1):
                a=dp[i-1][j]+tl[i][j]
            if(j-1):
                b=dp[i][j-1]+tl[i][j]
            dp[i][j]=min(a,b)

fp=[]

for i in range(n+1):
    x=[0]*(n+1)
    fp.append(x)

for i in range(1,n+1):
    for j in range(1,n+1):
        a=10**9
        b=10**9
        if(i==1 and j==1):
            fp[i][j]=fl[i][j]
        else:
            if(i-1):
                a=fp[i-1][j]+fl[i][j]
            if(j-1):
                b=fp[i][j-1]+fl[i][j]
            fp[i][j]=min(a,b)

if(dp[n][n]>=fp[n][n]):
    if(shake and fp[n][n]>1):
        print(str(1))
        print("\n")
        print(ss)
    else:
        print(str(fp[n][n]))
        print("\n")
        i=n
        j=n
        w=""
        while(i>1 and j>1):
            if(fp[i-1][j]>fp[i][j-1]):
                w="R"+w
                j-=1
            else:
                w="D"+w
                i-=1
        if(i+j!=2):
            if(i!=1):
                while(i!=1):
                    w="D"+w
                    i-=1
            else:
                while(j!=1):
                    w="R"+w
                    j-=1
        print(w)
else:
    if(shake and dp[n][n]>1):
        print(str(1))
        print("\n")
        print(ss)
    else:
        print(str(dp[n][n]))
        print("\n")
        i=n
        j=n
        s=""
        while(i>1 and j>1):
            if(dp[i-1][j]>dp[i][j-1]):
                s="R"+s
                j-=1
            else:
                s="D"+s
                i-=1
        if(i+j!=2):
            if(i!=1):
                while(i!=1):
                    s="D"+s
                    i-=1
            else:
                while(j!=1):
                    s="R"+s
                    j-=1
        print(s)


import sys
input=sys.stdin.readline
print=sys.stdout.write
n=int(input())

tl=[[0]*(n+1)]
fl=[[0]*(n+1)]
for i in range(n):
    x=[0]
    y=[0]
    w=list(map(int,input().split()))
    for j in range(n):
        two=0
        five=0
        a=w[j]
        if(a!=0):

            while(a%10==0):
                two+=1
                five+=1
                a//=10
            while(a%5==0):
                five+=1
                a//=5
            while(a%2==0):
                two+=1
                a//=2

        x.append(two)
        y.append(five)

    tl.append(x)
    fl.append(y)

dp=[]

for i in range(n+1):
    x=[0]*(n+1)
    dp.append(x)
for i in range(1,n+1):
    for j in range(1,n+1):
        a=10**9
        b=10**9
        if(j==1 and i==1):
            dp[i][j]=tl[i][j]
        else:
            if(i-1):
                a=dp[i-1][j]+tl[i][j]
            if(j-1):
                b=dp[i][j-1]+tl[i][j]
            dp[i][j]=min(a,b)

fp=[]

for i in range(n+1):
    x=[0]*(n+1)
    fp.append(x)

for i in range(1,n+1):
    for j in range(1,n+1):
        a=10**9
        b=10**9
        if(i==1 and j==1):
            fp[i][j]=fl[i][j]
        else:
            if(i-1):
                a=fp[i-1][j]+fl[i][j]
            if(j-1):
                b=fp[i][j-1]+fl[i][j]
            fp[i][j]=min(a,b)

if(dp[n][n]>=fp[n][n]):
    print(str(fp[n][n]))
    print("\n")
    i=n
    j=n
    w=""
    while(i>1 and j>1):
        if(fp[i-1][j]>fp[i][j-1]):
            w="R"+w
            j-=1
        else:
            w="D"+w
            i-=1
    if(i+j!=2):
        if(i!=1):
            while(i!=1):
                w="D"+w
                i-=1
        else:
            while(j!=1):
                w="R"+w
                j-=1
    print(w)
else:
    print(str(dp[n][n]))
    print("\n")
    i=n
    j=n
    s=""
    while(i>1 and j>1):
        if(dp[i-1][j]>dp[i][j-1]):
            s="R"+s
            j-=1
        else:
            s="D"+s
            i-=1
    if(i+j!=2):
        if(i!=1):
            while(i!=1):
                s="D"+s
                i-=1
        else:
            while(j!=1):
                s="R"+s
                j-=1
    print(s)


def dcount(x, d):
    if not x:
        return 1
    ans = 0
    while x > 0:
        if x % d != 0:
            break
        x //= d
        ans += 1
    return ans

def get(a, n, d):
    t = [None] * n
    p = [None] * n
    for i in range(n):
        t[i] = [None] * n
        p[i] = [None] * n

    t[0][0] = dcount(a[0][0], d)
    p[0][0] = ''

    for i in range(n):
        i1 = i - 1
        for j in range(n):
            j1 = j - 1

            c = ''
            prev = None

            if i1 >= 0:
                c = 'D'
                prev = t[i1][j]

            if j1 >= 0:
                if prev is None or t[i][j1] < prev:
                    c = 'R'
                    prev = t[i][j1]

            if prev is not None:
                t[i][j] = prev + dcount(a[i][j], d)
                p[i][j] = c

    i = n - 1
    j = n - 1

    s = ''
    while True:
        c = p[i][j]
        if c == 'D':
            i -= 1
            s = c + s
        elif c == 'R':
            j -= 1
            s = c + s
        else:
            break

    return [t[n - 1][n - 1], s]

n = int(input())

a = [None] * n

for i in range(n):
    a[i] = list(map(int, input().split()))

ans2 = get(a, n, 2)
ans5 = get(a, n, 5)

ans = ans2 if ans2[0] < ans5[0] else ans5

i0 = -1
j0 = -1

for i in range(n):
    for j in range(n):
        if not a[i][j]:
            i0 = i
            j0 = j
            break
        if i0 >= 0:
            break

if ans[0] > 0 and i0 >= 0:
    ans[1] = ''
    ans[0] = 1

    for j in range(0, j0):
        ans[1] += 'R'

    for i in range(1, n):
        ans[1] += 'D'

    for j in range(j0 + 1, n):
        ans[1] += 'R'

print(ans[0])
print(ans[1])


n = int(input())
lis2 = []
lis5 = []
liss = [lis2,lis5]
zero_i = None
def flis(i,val,m):
	global zero_i
	if val == 0:
		zero_i = i
		return 20000
	r = 0
	while val % m == 0:
		r += 1
		val //= m
	return r

def get_path():
	for i in range(1,n):
		lis2[i][0] += lis2[i-1][0]
		lis5[i][0] += lis5[i-1][0]
	for j in range(1,n):
		lis2[0][j] += lis2[0][j-1]
		lis5[0][j] += lis5[0][j-1]

	for i in range(1,n):
		for j in range(1,n):
			lis2[i][j] += min(lis2[i-1][j],lis2[i][j-1])
			lis5[i][j] += min(lis5[i-1][j],lis5[i][j-1])
	if lis2[-1][-1] < lis5[-1][-1]:
		return lis2[-1][-1], build_path(lis2)
	else:
		return lis5[-1][-1], build_path(lis5)
def build_path(lis):
	path = []
	i = j = n - 1
	while i + j:
		if i == 0 or not j == 0 and lis[i][j-1] < lis[i-1][j]:
			path.append('R')
			j -= 1
		else:
			path.append('D')
			i -= 1
	path.reverse()
	return ''.join(path)

def solve():
	zero, path = get_path()
	if zero < 2:
		return zero, path
	if zero_i is None:
		return zero, path
	else:
		return 1, 'D' * zero_i + 'R' * (n - 1) + 'D' * (n - 1 -zero_i)

def ans():
	for i in range(n):
		l = [int(x) for x in input().split()]
		lis2.append([flis(i, e, 2) for e in l])
		lis5.append([flis(i, e, 5) for e in l])

	zero,path = solve()
	print(zero)
	print(path)

ans()


def solve():
	n = int(input())
	A = []
	for _ in range(n):
		A.append([int(x) for x in input().split()])

	A2 = [[0 for _ in range(n)] for __ in range(n)]
	A5 = [[0 for _ in range(n)] for __ in range(n)]
	ans = 0; act_path = ""
	for i in range(n):
		for j in range(n):
			if(A[i][j]==0):
				ans = 1
				act_path = "R"*j+"D"*i+"R"*(n-1-j)+"D"*(n-1-i)
				A[i][j]=10

	for i in range(n):
		for j in range(n):
			x = A[i][j]
			while(x%2==0 and x>0):
				A2[i][j]+=1
				x//=2
			while(x%5==0 and x>0):
				A5[i][j]+=1
				x//=5

	dp2 = A2
	dp5 = A5
	for i in range(1,n):
		dp2[i][0]+=dp2[i-1][0]
		dp2[0][i]+=dp2[0][i-1]
	for i in range(1,n):
		dp5[i][0]+=dp5[i-1][0]
		dp5[0][i]+=dp5[0][i-1]
	for i in range(1,n):
		for j in range(1,n):
			dp2[i][j]+= min(dp2[i-1][j],dp2[i][j-1])
			dp5[i][j]+= min(dp5[i-1][j],dp5[i][j-1])
	dp = dp2 if dp2[-1][-1]<dp5[-1][-1] else dp5

	if ans==1 and dp[-1][-1]:
		print(ans)
		print(act_path)
		return
	ans = dp[-1][-1]
	pi,pj = n-1,n-1
	act_path = ""
	while(pi and pj):
		up = dp[pi-1][pj]<dp[pi][pj-1]
		act_path+= "D" if up else "R"
		pi-= int(up)
		pj-= int(not up)
	if(not pi):
		act_path+= "R"*pj
	else:
		act_path+= "D"*pi
	print(ans)
	print(act_path[::-1])

solve()


import functools

N = n = int(input())
lines = []
while(n):
    line = [int(i) for i in input().split()]
    lines.append(line)
    n -= 1

def count_2(x):
    num_2 = 0
    while(x >= 2 and x % 2 == 0):
        num_2 += 1
        x //= 2
    return num_2

def count_5(x):
    num_5 = 0
    while(x >= 5 and x % 5 == 0):
        num_5 += 1
        x //= 5
    return num_5

matrix_base_2 = [list(map(count_2, line)) for line in lines]
matrix_base_5 = [list(map(count_5, line)) for line in lines]

def memorize(f):
    f.cache = {}

    def newf(*args, **kw):
        if kw:
            key = args, frozenset(kw.items())
        else:
            key = args
        cache = f.cache
        if key in cache:
            return cache[key]
        else:
            cache[key] = result = f(*args, **kw)
            return result
    return functools.update_wrapper(newf, f)

@memorize
def D_2(r, c):
    if r < 0 or c < 0:
        return [float('inf'), '']
    if r == 0 and c == 0:
        return [matrix_base_2[0][0], '']
    else:
        Rnum, Rway = D_2(r, c - 1)
        Dnum, Dway = D_2(r - 1, c)
        if Dnum < Rnum:
            return Dnum + matrix_base_2[r][c], Dway + 'D'
        else:
            return Rnum + matrix_base_2[r][c], Rway + 'R'

@memorize
def D_5(r, c):
    if r < 0 or c < 0:
        return [float('inf'), '']
    if r == 0 and c == 0:
        return [matrix_base_5[0][0], '']
    else:
        Rnum, Rway = D_5(r, c - 1)
        Dnum, Dway = D_5(r - 1, c)
        if Dnum < Rnum:
            return Dnum + matrix_base_5[r][c], Dway + 'D'
        else:
            return Rnum + matrix_base_5[r][c], Rway + 'R'

result = min(D_2(N - 1, N - 1), D_5(N - 1, N - 1), key=lambda x: x[0])
print(result[0])
print(result[1])


N = n = int(input())
lines = []
while(n):
    line = [int(i) for i in input().split()]
    lines.append(line)
    n -= 1

def Fpow(factor):
    def count_fpow(x):
        num = 0
        if x < 1:
            return 0.1
        while(x >= factor and x % factor == 0):
            num += 1
            x //= factor
        return num
    return count_fpow

matrix_base_2 = [list(map(Fpow(factor=2), line)) for line in lines]
matrix_base_5 = [list(map(Fpow(factor=5), line)) for line in lines]

dp_2 = [[0] * N for _ in range(N)]
dp_5 = [[0] * N for _ in range(N)]

# dp init
'''
if matrix_base_2[0][0] == 0 or matrix_base_5[0][0] == 0:
    print(1)
    path = ''
    for _ in range(N):
        path += 'D'
        path += 'R'
    print(path)
    exit(0)
'''
dp_2[0][0] = matrix_base_2[0][0]
dp_5[0][0] = matrix_base_5[0][0]
for i in range(1, N):
    dp_2[i][0] = dp_2[i - 1][0] + matrix_base_2[i][0]
    if dp_2[i][0] // 1 != dp_2[i][0]:
        dp_2[i][0] = 0.1
    dp_2[0][i] = dp_2[0][i - 1] + matrix_base_2[0][i]
    if dp_2[0][i] // 1 != dp_2[0][i]:
        dp_2[0][i] = 0.1
    dp_5[i][0] = dp_5[i - 1][0] + matrix_base_5[i][0]
    if dp_5[i][0] // 1 != dp_5[i][0]:
        dp_5[i][0] = 0.1
    dp_5[0][i] = dp_5[0][i - 1] + matrix_base_5[0][i]
    if dp_5[0][i] // 1 != dp_5[0][i]:
        dp_5[0][i] = 0.1

# dp
for colum in range(1, N):
    for row in range(1, N):
        dp_2[row][colum] = min(
            dp_2[row - 1][colum], dp_2[row][colum - 1]) \
            + matrix_base_2[row][colum]
        if dp_2[row][colum] // 1 != dp_2[row][colum]:
            dp_2[row][colum] = 0.1
        dp_5[row][colum] = min(dp_5[row - 1][colum], dp_5[row][colum - 1]) \
            + matrix_base_5[row][colum]
        if dp_5[row][colum] // 1 != dp_5[row][colum]:
            dp_5[row][colum] = 0.1

def findpath(dp_x, N):
    path = ''
    row, colum = N - 1, N - 1
    while(row != 0 and colum != 0):
        if dp_x[row - 1][colum] < dp_x[row][colum - 1]:
            path += 'D'
            row -= 1
        else:
            path += 'R'
            colum -= 1
    if row == 0:
        while(colum != 0):
            path += 'R'
            colum -= 1
    if colum == 0:
        while(row != 0):
            path += 'D'
            row -= 1
    return path[::-1]

if dp_2[N - 1][N - 1] <= dp_5[N - 1][N - 1]:
    least_round = dp_2[N - 1][N - 1]
    path = findpath(dp_2, N)
else:
    least_round = dp_5[N - 1][N - 1]
    path = findpath(dp_5, N)

if least_round == 0.1:
    least_round = 1
print(least_round)
print(path)

'''
def memorize(f):
    f.cache = {}

    def newf(*args, **kw):
        if kw:
            key = args, frozenset(kw.items())
        else:
            key = args
        cache = f.cache
        if key in cache:
            return cache[key]
        else:
            cache[key] = result = f(*args, **kw)
            return result
    return functools.update_wrapper(newf, f)

@memorize
def D_2(r, c):
    if r < 0 or c < 0:
        return [float('inf'), '']
    if r == 0 and c == 0:
        return [matrix_base_2[0][0], '']
    else:
        Rnum, Rway = D_2(r, c - 1)
        Dnum, Dway = D_2(r - 1, c)
        if Dnum < Rnum:
            return Dnum + matrix_base_2[r][c], Dway + 'D'
        else:
            return Rnum + matrix_base_2[r][c], Rway + 'R'

@memorize
def D_5(r, c):
    if r < 0 or c < 0:
        return [float('inf'), '']
    if r == 0 and c == 0:
        return [matrix_base_5[0][0], '']
    else:
        Rnum, Rway = D_5(r, c - 1)
        Dnum, Dway = D_5(r - 1, c)
        if Dnum < Rnum:
            return Dnum + matrix_base_5[r][c], Dway + 'D'
        else:
            return Rnum + matrix_base_5[r][c], Rway + 'R'

result = min(D_2(N - 1, N - 1), D_5(N - 1, N - 1), key=lambda x: x[0])
print(result[0])
print(result[1])

'''


N = n = int(input())
lines = []
while(n):
    line = [int(i) for i in input().split()]
    lines.append(line)
    n -= 1

def Fpow(factor):
    def count_fpow(x):
        num = 0
        while(x >= factor and x % factor == 0):
            num += 1
            x //= factor
        return num
    return count_fpow

matrix_base_2 = [list(map(Fpow(factor=2), line)) for line in lines]
matrix_base_5 = [list(map(Fpow(factor=5), line)) for line in lines]

dp_2 = [[0] * N for _ in range(N)]
dp_5 = [[0] * N for _ in range(N)]

# dp init
dp_2[0][0] = matrix_base_2[0][0]
dp_5[0][0] = matrix_base_5[0][0]
for i in range(1, N):
    dp_2[i][0] = dp_2[i - 1][0] + matrix_base_2[i][0]
    dp_2[0][i] = dp_2[0][i - 1] + matrix_base_2[0][i]
    dp_5[i][0] = dp_5[i - 1][0] + matrix_base_5[i][0]
    dp_5[0][i] = dp_5[0][i - 1] + matrix_base_5[0][i]

# dp
for colum in range(1, N):
    for row in range(1, N):
        dp_2[row][colum] = min(
            dp_2[row - 1][colum], dp_2[row][colum - 1]) \
            + matrix_base_2[row][colum]
        dp_5[row][colum] = min(dp_5[row - 1][colum], dp_5[row][colum - 1]) \
            + matrix_base_5[row][colum]

def findpath(dp_x, N):
    path = ''
    row, colum = N - 1, N - 1
    while(row != 0 and colum != 0):
        if dp_x[row - 1][colum] < dp_x[row][colum - 1]:
            path += 'D'
            row -= 1
        else:
            path += 'R'
            colum -= 1
    if row == 0:
        while(colum != 0):
            path += 'R'
            colum -= 1
    if colum == 0:
        while(row != 0):
            path += 'D'
            row -= 1
    return path[::-1]

if dp_2[N - 1][N - 1] <= dp_5[N - 1][N - 1]:
    least_round = dp_2[N - 1][N - 1]
    path = findpath(dp_2, N)
else:
    least_round = dp_5[N - 1][N - 1]
    path = findpath(dp_5, N)

print(least_round)
print(path)

'''
def memorize(f):
    f.cache = {}

    def newf(*args, **kw):
        if kw:
            key = args, frozenset(kw.items())
        else:
            key = args
        cache = f.cache
        if key in cache:
            return cache[key]
        else:
            cache[key] = result = f(*args, **kw)
            return result
    return functools.update_wrapper(newf, f)

@memorize
def D_2(r, c):
    if r < 0 or c < 0:
        return [float('inf'), '']
    if r == 0 and c == 0:
        return [matrix_base_2[0][0], '']
    else:
        Rnum, Rway = D_2(r, c - 1)
        Dnum, Dway = D_2(r - 1, c)
        if Dnum < Rnum:
            return Dnum + matrix_base_2[r][c], Dway + 'D'
        else:
            return Rnum + matrix_base_2[r][c], Rway + 'R'

@memorize
def D_5(r, c):
    if r < 0 or c < 0:
        return [float('inf'), '']
    if r == 0 and c == 0:
        return [matrix_base_5[0][0], '']
    else:
        Rnum, Rway = D_5(r, c - 1)
        Dnum, Dway = D_5(r - 1, c)
        if Dnum < Rnum:
            return Dnum + matrix_base_5[r][c], Dway + 'D'
        else:
            return Rnum + matrix_base_5[r][c], Rway + 'R'

result = min(D_2(N - 1, N - 1), D_5(N - 1, N - 1), key=lambda x: x[0])
print(result[0])
print(result[1])

'''


t = int(input())
def get_cnt(num, mod):
    cnt = 0
    while num > 0 and num % mod == 0:
        cnt += 1
        num //= mod
    return cnt
r = range(t)
def solve(m, num):
    path = ''
    n = [[0 for i in r] for i in r]
    for i in r:
        for j in r:
            n[i][j] = get_cnt(m[i][j], num)
    for i in range(1, t):
        n[0][i] += n[0][i - 1]
        n[i][0] += n[i - 1][0]
    for i in range(1, t):
        for j in range(1, t):
            if n[i - 1][j] < n[i][j - 1]:
                n[i][j] += n[i - 1][j]
            else:
                n[i][j] += n[i][j - 1]
    x, y = t - 1, t - 1
    while x or y:
        if x == 0 or n[x - 1][y] > n[x][y - 1]:
            y -= 1
            path += 'D'
        else:
            x -= 1
            path += 'R'
    return [n[t - 1][t - 1], path[::-1]]

matrix = [[]] * t
zero_point = [0, 0, 0]
for i in r:
    matrix[i] = list(map(int, input().split()))
    for j in r:
        if matrix[i][j] == 0:
            zero_point = [1, i, j]
ans2 = solve(matrix, 2)
ans5 = solve(matrix, 5)
if ans2 < ans5:
    ans = ans2
else:
    ans = ans5
if zero_point[0] == 0 or ans[0] <= 1:
    print(ans[0])
    print(ans[1])
else:
    print(1)
    print('R' * zero_point[1] + 'D' * zero_point[2] + 'R' * (t - zero_point[1] - 1) + 'D' * (t - zero_point[2] - 1))


t = int(input())
def get_cnt(num, mod):
    cnt = 0
    while num > 0 and num % mod == 0:
        cnt += 1
        num //= mod
    return cnt
r = range(t)
def solve(m, num):
    path = ''
    n = [[0 for i in r] for i in r]
    for i in r:
        for j in r:
            n[i][j] = get_cnt(m[i][j], num)
    for i in range(1, t):
        n[0][i] += n[0][i - 1]
        n[i][0] += n[i - 1][0]
    for i in range(1, t):
        for j in range(1, t):
            if n[i - 1][j] < n[i][j - 1]:
                n[i][j] += n[i - 1][j]
            else:
                n[i][j] += n[i][j - 1]
    x, y = t - 1, t - 1
    while x or y:
        if x == 0 or n[x - 1][y] > n[x][y - 1]:
            y -= 1
            path += 'R'
        else:
            x -= 1
            path += 'D'
    return [n[t - 1][t - 1], path[::-1]]

matrix = [[]] * t
zero_point = [0, 0, 0]
for i in r:
    matrix[i] = list(map(int, input().split()))
    for j in r:
        if matrix[i][j] == 0:
            zero_point = [1, i, j]
ans2 = solve(matrix, 2)
ans5 = solve(matrix, 5)
if ans2 < ans5:
    ans = ans2
else:
    ans = ans5
if zero_point[0] == 0 or ans[0] <= 1:
    print(ans[0])
    print(ans[1])
else:
    print(1)
    print('R' * zero_point[1] + 'D' * zero_point[2] + 'R' * (t - zero_point[1] - 1) + 'D' * (t - zero_point[2] - 1))


t = int(input())
def get_cnt(num, mod):
    cnt = 0
    while num > 0 and num % mod == 0:
        cnt += 1
        num //= mod
    return cnt
r = range(t)
def solve(m, num):
    path = [['' for i in r] for i in r]
    n = [[0 for i in r] for i in r]
    for i in r:
        for j in r:
            n[i][j] = get_cnt(m[i][j], num)
    for i in range(1, t):
        n[0][i] += n[0][i - 1]
        n[i][0] += n[i - 1][0]
        path[i][0] = path[i - 1][0] + 'D'
        path[0][i] = path[0][i - 1] + 'R'
    for i in range(1, t):
        for j in range(1, t):
            if n[i - 1][j] < n[i][j - 1]:
                n[i][j] += n[i - 1][j]
                path[i][j] = path[i - 1][j] + 'D'
            else:
                n[i][j] += n[i][j - 1]
                path[i][j] = path[i][j - 1] + 'R'
    return [n[t - 1][t - 1], path[t - 1][t - 1]]

matrix = [[]] * t
zero_point = [0, 0, 0]
for i in r:
    matrix[i] = list(map(int, input().split()))
    for j in r:
        if matrix[i][j] == 0:
            zero_point = [1, i, j]
ans2 = solve(matrix, 2)
ans5 = solve(matrix, 5)
if ans2 < ans5:
    ans = ans2
else:
    ans = ans5
if zero_point[0] == 0 or ans[0] <= 1:
    print(ans[0])
    print(ans[1])
else:
    print(1)
    print('R' * zero_point[1] + 'D' * zero_point[2] + 'R' * (t - zero_point[1] - 1) + 'D' * (t - zero_point[2] - 1))


t = int(input())
def get_cnt(num, mod):
    cnt = 0
    while num > 0 and num % mod == 0:
        cnt += 1
        num //= mod
    return cnt
r = range(t)
def solve(m, num):
    path = ''
    n = [[0 for i in r] for i in r]
    for i in r:
        for j in r:
            n[i][j] = get_cnt(m[i][j], num)
    for i in range(1, t):
        n[0][i] += n[0][i - 1]
        n[i][0] += n[i - 1][0]
    for i in range(1, t):
        for j in range(1, t):
            if n[i - 1][j] < n[i][j - 1]:
                n[i][j] += n[i - 1][j]
            else:
                n[i][j] += n[i][j - 1]
    x, y = t - 1, t - 1
    while x or y:
        if x == 0 or (y > 0 and n[x - 1][y] > n[x][y - 1]):
            y -= 1
            path += 'R'
        else:
            x -= 1
            path += 'D'
    return [n[t - 1][t - 1], path[::-1]]

matrix = [[]] * t
zero_point = [0, 0, 0]
for i in r:
    matrix[i] = list(map(int, input().split()))
    for j in r:
        if matrix[i][j] == 0:
            zero_point = [1, i, j]
ans2 = solve(matrix, 2)
ans5 = solve(matrix, 5)
if ans2 < ans5:
    ans = ans2
else:
    ans = ans5
if zero_point[0] == 0 or ans[0] <= 1:
    print(ans[0])
    print(ans[1])
else:
    print(1)
    print('R' * zero_point[1] + 'D' * (t - 1) + 'R' * (t - zero_point[1] - 1))


t = int(input())
def get_cnt(num, mod):
    cnt = 0
    while num > 0 and num % mod == 0:
        cnt += 1
        num //= mod
    return cnt
r = range(t)
def solve(m, num):
    path = ''
    n = [[0 for i in r] for i in r]
    for i in r:
        for j in r:
            n[i][j] = get_cnt(m[i][j], num)
    for i in range(1, t):
        n[0][i] += n[0][i - 1]
        n[i][0] += n[i - 1][0]
    for i in range(1, t):
        for j in range(1, t):
            if n[i - 1][j] < n[i][j - 1]:
                n[i][j] += n[i - 1][j]
            else:
                n[i][j] += n[i][j - 1]
    x, y = t - 1, t - 1
    while x or y:
        if x == 0 or (y > 0 and n[x - 1][y] > n[x][y - 1]):
            y -= 1
            path += 'R'
        else:
            x -= 1
            path += 'D'
    return [n[t - 1][t - 1], path[::-1]]

matrix = [[]] * t
zero_point = [0, 0, 0]
for i in r:
    matrix[i] = list(map(int, input().split()))
    for j in r:
        if matrix[i][j] == 0:
            zero_point = [1, i, j]
ans2 = solve(matrix, 2)
ans5 = solve(matrix, 5)
if ans2 < ans5:
    ans = ans2
else:
    ans = ans5
if zero_point[0] == 0 or ans[0] <= 1:
    print(ans[0])
    print(ans[1])
else:
    print(1)
    print('R' * zero_point[1] + 'D' * zero_point[2] + 'R' * (t - zero_point[1] - 1) + 'D' * (t - zero_point[2] - 1))


t = int(input())
def get_cnt(num, mod):
    cnt = 0
    while num > 0 and num % mod == 0:
        cnt += 1
        num //= mod
    return cnt
r = range(t)
def solve(m, num):
    path = ''
    n = [[0 for i in r] for i in r]
    for i in r:
        for j in r:
            n[i][j] = get_cnt(m[i][j], num)
    for i in range(1, t):
        n[0][i] += n[0][i - 1]
        n[i][0] += n[i - 1][0]
    for i in range(1, t):
        for j in range(1, t):
            if n[i - 1][j] < n[i][j - 1]:
                n[i][j] += n[i - 1][j]
            else:
                n[i][j] += n[i][j - 1]
    x, y = t - 1, t - 1
    while x or y:
        if x == 0 or (y > 0 and n[x - 1][y] > n[x][y - 1]):
            y -= 1
            path += 'R'
        else:
            x -= 1
            path += 'D'
    return [n[t - 1][t - 1], path[::-1]]

matrix = [[]] * t
zero_point = [0, 0, 0]
for i in r:
    matrix[i] = list(map(int, input().split()))
    for j in r:
        if matrix[i][j] == 0:
            zero_point = [1, i, j]
ans2 = solve(matrix, 2)
ans5 = solve(matrix, 5)
if ans2 < ans5:
    ans = ans2
else:
    ans = ans5
if zero_point[0] == 0 or ans[0] <= 1:
    print(ans[0])
    print(ans[1])
else:
    print(1)
    print('R' * zero_point[2] + 'D' * (t - 1) + 'R' * (t - zero_point[2] - 1))


t = int(input())
def get_cnt(num, mod):
    cnt = 0
    while num > 0 and num % mod == 0:
        cnt += 1
        num //= mod
    return cnt
r = range(t)
def solve(m, num):
    path = [[''] * t] * t
    n = [[0 for i in r] for i in r]
    for i in r:
        for j in r:
            n[i][j] = get_cnt(m[i][j], num)
    for i in r:
        for j in r:
            if i == 0 and j == 0:
                continue
            elif j == 0 or (i > 0 and n[i - 1][j] < n[i][j - 1]):
                n[i][j] += n[i - 1][j]
                path[i][j] = path[i - 1][j] + 'D'
            else:
                n[i][j] += n[i][j - 1]
                path[i][j] = path[i][j - 1] + 'R'
    return [n[t - 1][t - 1], path[t - 1][t - 1]]

matrix = [[]] * t
zero_point = [0, 0, 0]
for i in r:
    matrix[i] = list(map(int, input().split()))
    for j in r:
        if matrix[i][j] == 0:
            zero_point = [1, i, j]
ans2 = solve(matrix, 2)
ans5 = solve(matrix, 5)
if ans2 < ans5:
    ans = ans2
else:
    ans = ans5
if zero_point[0] == 0 or ans[0] <= 1:
    print(ans[0])
    print(ans[1])
else:
    print(1)
    print('R' * zero_point[1] + 'D' * zero_point[2] + 'R' * (t - zero_point[1] - 1) + 'D' * (t - zero_point[2] - 1))


t = int(input())
def get_cnt(num, mod):
    cnt = 0
    while num > 0 and num % mod == 0:
        cnt += 1
        num //= mod
    return cnt
r = range(t)
def solve(m, num):
    path = [[''] * t] * t
    n = [[0] * t] * t
    for i in r:
        for j in r:
            n[i][j] = get_cnt(m[i][j], num)
    for i in r:
        for j in r:
            if i == 0 and j == 0:
                continue
            elif j == 0 or (i > 0 and n[i - 1][j] < n[i][j - 1]):
                n[i][j] += n[i - 1][j]
                path[i][j] = path[i - 1][j] + 'D'
            else:
                n[i][j] += n[i][j - 1]
                path[i][j] = path[i][j - 1] + 'R'
    return [n[t - 1][t - 1], path[t - 1][t - 1]]

matrix = [[]] * t
zero_point = [0, 0, 0]
for i in r:
    matrix[i] = list(map(int, input().split()))
    for j in r:
        if matrix[i][j] == 0:
            zero_point = [1, i, j]
ans2 = solve(matrix, 2)
ans5 = solve(matrix, 5)
if ans2 < ans5:
    ans = ans2
else:
    ans = ans5
if zero_point[0] == 0 or ans[0] <= 1:
    print(ans[0])
    print(ans[1])
else:
    print(1)
    print('R' * zero_point[1] + 'D' * zero_point[2] + 'R' * (t - zero_point[1] - 1) + 'D' * (t - zero_point[2] - 1))


t = int(input())
def get_cnt(num, mod):
    cnt = 0
    while num > 0 and num % mod == 0:
        cnt += 1
        num //= mod
    return cnt
def solve(m, num):
    path = [[''] * t] * t
    n = [[0] * t] * t
    for i in range(0, t):
        for j in range(0, t):
            if i == 0 and j == 0:
                n[i][j] = get_cnt(m[i][j], num)
                continue
            elif j == 0 or (i > 0 and n[i - 1][j] < n[i][j - 1]):
                n[i][j] = n[i - 1][j] + get_cnt(m[i][j], num)
                path[i][j] = path[i - 1][j] + 'D'
            else:
                n[i][j] = n[i][j - 1] + get_cnt(m[i][j], num)
                path[i][j] = path[i][j - 1] + 'R'
    return [n[t - 1][t - 1], path[t - 1][t - 1]]

matrix = [[]] * t
zero_point = [0, 0, 0]
for i in range(t):
    matrix[i] = list(map(int, input().split()))
    for j in range(t):
        if matrix[i][j] == 0:
            zero_point = [1, i, j]
ans2 = solve(matrix, 2)
ans5 = solve(matrix, 5)
if ans2 < ans5:
    ans = ans2
else:
    ans = ans5
if zero_point[0] == 0 or ans[0] <= 1:
    print(ans[0])
    print(ans[1])
else:
    print(1)
    print('R' * zero_point[1] + 'D' * zero_point[2] + 'R' * (t - zero_point[1] - 1) + 'D' * (t - zero_point[2] - 1))


t = int(input())
def get_cnt(num, mod):
    cnt = 0
    while num > 0 and num % mod == 0:
        cnt += 1
        num //= mod
    return cnt
r = range(t)
def solve(m, num):
    path = [[''] * t] * t
    n = [[0] * t] * t
    for i in r:
        for j in r:
            if i == 0 and j == 0:
                n[i][j] = get_cnt(m[i][j], num)
                continue
            elif j == 0 or (i > 0 and n[i - 1][j] < n[i][j - 1]):
                n[i][j] = n[i - 1][j] + get_cnt(m[i][j], num)
                path[i][j] = path[i - 1][j] + 'D'
            else:
                n[i][j] = n[i][j - 1] + get_cnt(m[i][j], num)
                path[i][j] = path[i][j - 1] + 'R'
    return [n[t - 1][t - 1], path[t - 1][t - 1]]

matrix = [[]] * t
zero_point = [0, 0, 0]
for i in r:
    matrix[i] = list(map(int, input().split()))
    for j in r:
        if matrix[i][j] == 0:
            zero_point = [1, i, j]
ans2 = solve(matrix, 2)
ans5 = solve(matrix, 5)
if ans2 < ans5:
    ans = ans2
else:
    ans = ans5
if zero_point[0] == 0 or ans[0] <= 1:
    print(ans[0])
    print(ans[1])
else:
    print(1)
    print('R' * zero_point[1] + 'D' * zero_point[2] + 'R' * (t - zero_point[1] - 1) + 'D' * (t - zero_point[2] - 1))


import sys
input = sys.stdin.readline
from math import *
from bisect import *
from itertools import *
from functools import reduce, lru_cache
from collections import Counter, defaultdict

def main():
    n = int(input())
    B = [list(map(int, input().split())) for _ in range(n)]
    def F(x, p):
        r = 0
        while not x % p:
            r += 1
            x //= p
        return r
    for x in range(n):
        if not all(B[x]):
            print(0)
            print("D" * x + "R" * (n - 1) + "D" * (n - 1 - x))
            return
    B = ([[F(i, 2) for i in l] for l in B], [[F(i, 5) for i in l] for l in B])
    def P(p):
        T = B[p]
        for i in range(1, n):
            T[0][i] += T[0][i - 1]
            T[i][0] += T[i - 1][0]
        for x in range(1, n):
            for y in range(1, n):
                T[x][y] += min(T[x - 1][y], T[x][y - 1])
        x, y, P = n - 1, n - 1, []
        while x and y:
            if T[x - 1][y] < T[x][y - 1]:
                x -= 1
                P.append("D")
            else:
                y -= 1
                P.append("R")
        P.extend(["D"] * x + ["R"] * y)
        return T[-1][-1], "".join(P[::-1])
    R = min(P(0), P(1))
    print(R[0])
    print(R[1])

if __name__ == "__main__":
    main()


import sys
input = sys.stdin.readline
from math import *
from bisect import *
from functools import reduce, lru_cache
from collections import Counter, defaultdict

def main():
    n = int(input())
    B = [list(map(int, input().split())) for _ in range(n)]
    for x in range(n):
        if not all(B[x]):
            print(0)
            print("D" * x + "R" * (n - 1) + "D" * (n - 1 - x))
            return
    def F(x, p):
        r = 0
        while not x % p:
            r += 1
            x //= p
        return r
    def P(p):
        L = [(inf, "")] * (n + 1)
        L[1] = (0, "")
        for x in range(n):
            for y in range(n):
                if L[y] < L[y + 1]:
                    L[y + 1] = (L[y][0] + F(B[x][y], p), L[y][1] + "R")
                else:
                    L[y + 1] = (L[y + 1][0] + F(B[x][y], p), L[y + 1][1] + "D")
        return L[n]
    R = min(P(2), P(5))
    print(R[0])
    print(R[1][1:])

if __name__ == "__main__":
    main()


import sys
input = sys.stdin.readline
from math import *
from bisect import *
from functools import reduce, lru_cache
from collections import Counter, defaultdict

n = int(input())
D = [list(map(int, input().split())) for _ in range(n)]
F = lambda x, p: 0 if x % p else 1 + F(x // p, p)
L = [((inf, ""), (inf, ""))] * (n + 1)
for x in range(n):
    for y in range(n):
        l2 = min(y, y + 1, key = lambda i: L[i][0][0])
        l5 = min(y, y + 1, key = lambda i: L[i][1][0])
        c2 = L[y][0][1] + "R" if l2 == y else L[y + 1][0][1] + "D"
        c5 = L[y][1][1] + "R" if l5 == y else L[y + 1][1][1] + "D"
        L[y + 1] = ((F(D[x][y], 2) +l2, c2), (F(D[x][y], 5) + l5, c5))
R = min(L[n])
print(R[0])
print(R[1][1:])


import sys
input = sys.stdin.readline
from math import *
from bisect import *
from itertools import *
from functools import reduce, lru_cache
from collections import Counter, defaultdict

def main():
    n = int(input())
    B = [list(map(int, input().split())) for _ in range(n)]
    def F(x, p):
        r = 0
        while not x % p:
            r += 1
            x //= p
        return r
    for x in range(n):
        for y in range(n):
            if B[x][y] == 0:
                B[x][y] = 10
    B = ([[F(i, 2) for i in l] for l in B], [[F(i, 5) for i in l] for l in B])
    def P(p):
        T = B[p]
        for i in range(1, n):
            T[0][i] += T[0][i - 1]
            T[i][0] += T[i - 1][0]
        for x in range(1, n):
            for y in range(1, n):
                T[x][y] += min(T[x - 1][y], T[x][y - 1])
        x, y, P = n - 1, n - 1, []
        while x and y:
            if T[x - 1][y] <= T[x][y - 1]:
                x -= 1
                P.append("D")
            else:
                y -= 1
                P.append("R")
        P.extend(["D"] * x + ["R"] * y)
        return T[-1][-1], "".join(P[::-1])
    R = min(P(0), P(1))
    print(R[0])
    print(R[1])

if __name__ == "__main__":
    main()


import sys
input = sys.stdin.readline
from math import *
from bisect import *
from itertools import *
from functools import reduce, lru_cache
from collections import Counter, defaultdict

def main():
    n = int(input())
    B = [list(map(int, input().split())) for _ in range(n)]
    def F(x, p):
        r = 0
        while not x % p:
            r += 1
            x //= p
        return r
    for x in range(n):
        if not all(B[x]):
            print(0)
            print("D" * x + "R" * (n - 1) + "D" * (n - 1 - x))
            return
    B = ([[F(i, 2) for i in l] for l in B], [[F(i, 5) for i in l] for l in B])
    def P(p):
        T = B[p]
        for i in range(1, n):
            T[0][i] += T[0][i - 1]
            T[i][0] += T[i - 1][0]
        for x in range(1, n):
            for y in range(1, n):
                T[x][y] += min(T[x - 1][y], T[x][y - 1])
        x, y, P = n - 1, n - 1, []
        while x and y:
            if T[x - 1][y] < T[x][y - 1]:
                x -= 1
                P.append("R")
            else:
                y -= 1
                P.append("D")
        P.extend(["R"] * x + ["D"] * y)
        return T[-1][-1], "".join(P[::-1])
    R = min(P(0), P(1))
    print(R[0])
    print(R[1])

if __name__ == "__main__":
    main()


import sys
input = sys.stdin.readline
from math import *
from bisect import *
from functools import reduce, lru_cache
from collections import Counter, defaultdict

n = int(input())
D = [list(map(int, input().split())) for _ in range(n)]
F = lambda x, p: 0 if x % p or x == 0 else 1 + F(x // p, p)
L = [((inf, ""), (inf, ""))] * (n + 1)
L[1] = ((0, ""), (0, ""))
for x in range(n):
    for y in range(n):
        if D[x][y] == 0:
            print(0)
            print("D" * x + "R" * (n - 1) + "D" * (n - 1 - x))
            exit()
        l2 = min(y, y + 1, key = lambda i: L[i][0][0])
        l5 = min(y, y + 1, key = lambda i: L[i][1][0])
        c2 = L[y][0][1] + "R" if l2 == y else L[y + 1][0][1] + "D"
        c5 = L[y][1][1] + "R" if l5 == y else L[y + 1][1][1] + "D"
        L[y + 1] = ((F(D[x][y], 2) + L[l2][0][0], c2), (F(D[x][y], 5) + L[l5][1][0], c5))
R = min(L[n])
print(R[0])
print(R[1][1:])


import sys
input = sys.stdin.readline
from math import *
from bisect import *
from itertools import *
from functools import reduce, lru_cache
from collections import Counter, defaultdict

def main():
    n = int(input())
    B = [list(map(int, input().split())) for _ in range(n)]
    def F(x, p):
        if x == 0: return 1
        r = 0
        while not x % p:
            r += 1
            x //= p
        return r
    R = (inf, "")
    for x in range(n):
        if not all(B[x]):
            R = (1, "D" * x + "R" * (n - 1) + "D" * (n - x - 1))
            break
    B = ([[F(i, 2) for i in l] for l in B], [[F(i, 5) for i in l] for l in B])
    def P(p):
        T = B[p]
        for i in range(1, n):
            T[0][i] += T[0][i - 1]
            T[i][0] += T[i - 1][0]
        for x in range(1, n):
            for y in range(1, n):
                T[x][y] += min(T[x - 1][y], T[x][y - 1])
        x, y, P = n - 1, n - 1, []
        while x and y:
            if T[x - 1][y] <= T[x][y - 1]:
                x -= 1
                P.append("D")
            else:
                y -= 1
                P.append("R")
        P.extend(["D"] * x + ["R"] * y)
        return T[-1][-1], "".join(P[::-1])
    R = min(P(0), P(1), R)
    print(R[0])
    print(R[1])

if __name__ == "__main__":
    main()


import sys
input = sys.stdin.readline
from math import *
from bisect import *
from functools import reduce, lru_cache
from collections import Counter, defaultdict

n = int(input())
D = [list(map(int, input().split())) for _ in range(n)]
F = lambda x, p: 0 if x % p or x == 0 else 1 + F(x // p, p)
L = [((inf, ""), (inf, ""))] * (n + 1)
L[1] = ((0, ""), (0, ""))
for x in range(n):
    for y in range(n):
        l2 = min(y, y + 1, key = lambda i: L[i][0][0])
        l5 = min(y, y + 1, key = lambda i: L[i][1][0])
        c2 = L[y][0][1] + "R" if l2 == y else L[y + 1][0][1] + "D"
        c5 = L[y][1][1] + "R" if l5 == y else L[y + 1][1][1] + "D"
        L[y + 1] = ((F(D[x][y], 2) + L[l2][0][0], c2), (F(D[x][y], 5) + L[l5][1][0], c5))
R = min(L[n])
print(R[0])
print(R[1][1:])


import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)
from math import *
from bisect import *
from functools import reduce, lru_cache
from collections import Counter, defaultdict

def main():
    n = int(input())
    B = [list(map(int, input().split())) for _ in range(n)]
    for x in range(n):
        if not all(B[x]):
            print(0)
            print("D" * x + "R" * (n - 1) + "D" * (n - 1 - x))
            return
    def F(x, p):
        r = 0
        while not x % p:
            r += 1
            x //= p
        return r
    def P(p):
        L = [(inf, "")] * (n + 1)
        L[1] = (0, "")
        for x in range(n):
            for y in range(n):
                if L[y] < L[y + 1]:
                    L[y + 1] = (L[y][0] + F(B[x][y], p), L[y][1] + "R")
                else:
                    L[y + 1] = (L[y + 1][0] + F(B[x][y], p), L[y + 1][1] + "D")
        return L[n]
    R = min(P(2), P(5))
    print(R[0])
    print(R[1][1:])

if __name__ == "__main__":
    main()


import sys
input = sys.stdin.readline
from math import *
from bisect import *
from itertools import *
from functools import reduce, lru_cache
from collections import Counter, defaultdict

def main():
    n = int(input())
    B = [list(map(int, input().split())) for _ in range(n)]
    def F(x, p):
        r = 0
        while not x % p:
            r += 1
            x //= p
        return r
    for x in range(n):
        if not all(B[x]):
            print(1)
            print("D" * x + "R" * (n - 1) + "D" * (n - 1 - x))
            return
    B = ([[F(i, 2) for i in l] for l in B], [[F(i, 5) for i in l] for l in B])
    def P(p):
        T = B[p]
        for i in range(1, n):
            T[0][i] += T[0][i - 1]
            T[i][0] += T[i - 1][0]
        for x in range(1, n):
            for y in range(1, n):
                T[x][y] += min(T[x - 1][y], T[x][y - 1])
        x, y, P = n - 1, n - 1, []
        while x and y:
            if T[x - 1][y] <= T[x][y - 1]:
                x -= 1
                P.append("D")
            else:
                y -= 1
                P.append("R")
        P.extend(["D"] * x + ["R"] * y)
        return T[-1][-1], "".join(P[::-1])
    R = min(P(0), P(1))
    print(R[0])
    print(R[1])

if __name__ == "__main__":
    main()


import sys
input = sys.stdin.readline
from math import *
from bisect import *
from itertools import *
from functools import reduce, lru_cache
from collections import Counter, defaultdict

def main():
    n = int(input())
    B = [list(map(int, input().split())) for _ in range(n)]
    def F(x, p):
        r = 0
        while not x % p:
            r += 1
            x //= p
        return r
    for x in range(n):
        if not all(B[x]):
            print(0)
            print("D" * x + "R" * (n - 1) + "D" * (n - 1 - x))
            return
    B = ([[F(i, 2) for i in l] for l in B], [[F(i, 5) for i in l] for l in B])
    def P(p):
        T = B[p]
        for i in range(1, n):
            T[0][i] += T[0][i - 1]
            T[i][0] += T[i - 1][0]
        for x in range(1, n):
            for y in range(1, n):
                T[x][y] += min(T[x - 1][y], T[x][y - 1])
        x, y, P = n - 1, n - 1, []
        while x and y:
            if T[x - 1][y] < T[x][y - 1]:
                x -= 1
                P.append("D")
            else:
                y -= 1
                P.append("R")
        P.extend(["R"] * x + ["D"] * y)
        return T[-1][-1], "".join(P[::-1])
    R = min(P(0), P(1))
    print(R[0])
    print(R[1])

if __name__ == "__main__":
    main()


n = int(input())
m = []
for i in range(n):
    m.append(list(map(int, input().split())))

dp2 = [[0 for _ in range(n)] for __ in range(n)]
dp5 = [[0 for _ in range(n)] for __ in range(n)]
ans = 0
for i in range(n):
    for j in range(n):
        if (m[i][j] == 0):
            ans = 1
            path = 'R' * j + 'D' * i + 'R' * (n - 1 - j) + 'D' * (n - 1 - i)
            m[i][j] = 10
for i in range(n):
    for j in range(n):
        x = m[i][j]
        while x % 2 == 0 and x > 0:
            dp2[i][j] += 1
            x //= 2
        while x % 5 == 0 and x > 0:
            dp5[i][j] += 1
            x //= 5

for i in range(1, n):
    dp2[i][0] += dp2[i - 1][0]
    dp2[0][i] += dp2[0][i - 1]
    dp5[i][0] += dp5[i - 1][0]
    dp5[0][i] += dp5[0][i - 1]
for i in range(1, n):
    for j in range(1, n):
        dp2[i][j] += min(dp2[i - 1][j], dp2[i][j - 1])
        dp5[i][j] += min(dp5[i - 1][j], dp5[i][j - 1])
if dp2[-1][-1] < dp5[-1][-1]:
    dp = dp2
else:
    dp = dp5
if ans == 1 and dp[-1][-1]:
    print(ans)
    print(path)
else:
    i, j = n - 1, n - 1
    path = ''
    while i or j:
        if not i:
            path += 'R'
            j -= 1
        elif not j:
            path += 'D'
            i -= 1
        else:
            if dp[i - 1][j] < dp[i][j - 1]:
                path += 'D'
                i -= 1
            else:
                path += 'R'
                j -= 1
    path = path[::-1]
    print(dp[-1][-1])
    print(path)


n = int(input())
m = []
for i in range(n):
    m.append(list(map(int, input().split())))
a2 = [[0 for i in range(n)] for j in range(n)]
a5 = [[0 for i in range(n)] for j in range(n)]
ans = 0

for i in range(n):
    for j in range(n):
        if m[i][j] == 0:
            ans = 1
            path = 'R' * j + 'D' * i + 'R' * (n - 1 - j) + 'D' * (n - 1 - i)
            m[i][j] = 10

for i in range(n):
    for j in range(n):
        x = m[i][j]
        while x % 2 == 0 and x > 0:
            a2[i][j] += 1
            x //= 2
        while x % 5 == 0 and x > 0:
            a5[i][j] += 1
            x //= 5

for i in range(1, n):
    a2[i][0] += a2[i - 1][0]
    a2[0][i] += a2[0][i - 1]
    a5[i][0] += a5[i - 1][0]
    a5[0][i] += a5[0][i - 1]

for i in range(1, n):
    for j in range(1, n):
        a2[i][j] += min(a2[i - 1][j], a2[i][j - 1])
        a5[i][j] += min(a5[i - 1][j], a5[i][j - 1])

if a2[-1][-1] < a5[-1][-1]:
    dp = a2
else:
    dp = a5
if ans == 1 and dp[-1][-1]:
    print(ans)
    print(path)

else:
    i, j = n - 1, n - 1
    path = ''
    while i or j:
        if not i:
            path += 'R'
            j -= 1
        elif not j:
            path += 'D'
            i -= 1
        else:
            if dp[i - 1][j] < dp[i][j - 1]:
                path += 'D'
                i -= 1
            else:
                path += 'R'
                j -= 1
    path = path[::-1]
    print(dp[-1][-1])
    print(path)


n = int(input())
xr = range(n)

a5 = [list(map(int, input().split())) for _ in xr]
a2 = [[0 for _ in xr] for _ in xr]
y = 0
x0 = -1

for y in xr:
    for x in xr:
        i = a5[y][x]
        m5 = 0
        m2 = 0

        if i == 0:
            x0 = x

        while i and i%2 == 0:
            i/=2
            m2+=1

        while i and i%5 == 0:
            i/=5
            m5+=1

        if y == 0 and x == 0:
            a5[y][x] = m5
            a2[y][x] = m2
            continue

        left5 = a5[y][x-1]
        left2 = a2[y][x-1]
        up5 = a5[y-1][x]
        up2 = a2[y-1][x]

        if y == 0:
            a5[y][x] = left5 + m5
            a2[y][x] = left2 + m2
            continue

        if x == 0:
            a5[y][x] = up5 + m5
            a2[y][x] = up2 + m2
            continue

        a5[y][x] = min(up5, left5) + m5
        a2[y][x] = min(up2, left2) + m2

def getpath(k):
    p = ''
    y = x = n-1

    while not (y == 0 and x == 0):
        if y and x:
            if k == 5:
                if a5[y-1][x] < a5[y][x-1]:
                    p+='D'
                    y-=1
                else:
                    p+='R'
                    x-=1
            else:
                if a2[y-1][x] < a2[y][x-1]:
                    p+='D'
                    y-=1
                else:
                    p+='R'
                    x-=1
        elif y == 0:
            p+='R'
            x-=1
        elif x == 0:
            p+='D'
            y-=1

    return p[::-1]

ten = 0
path = ''
if a5[n-1][n-1] < a2[n-1][n-1]:
    ten = a5[n-1][n-1]
    path = getpath(5)
else:
    ten = a2[n-1][n-1]
    path = getpath(2)

if ten > 1 and x0 > -1:
    ten = 1
    path = 'R'*x0 + 'D'*(n-1) + 'R'*(n-1-x0)

print(ten)
print(path)


n = int(input())
xr = range(n)

a5 = [list(map(int, input().split())) for _ in xr]
a2 = [[0 for _ in xr] for _ in xr]
y = 0
x0 = -1

for y in xr:
    for x in xr:
        i = a5[y][x]
        m5 = 0
        m2 = 0

        if i == 0:
            x0 = x

        while i and i % 2 == 0:
            i /= 2
            m2 += 1

        while i and i % 5 == 0:
            i /= 5
            m5 += 1

        if y == 0 and x == 0:
            a5[y][x] = m5
            a2[y][x] = m2
            continue

        left5 = a5[y][x - 1]
        left2 = a2[y][x - 1]
        up5 = a5[y - 1][x]
        up2 = a2[y - 1][x]

        if y == 0:
            a5[y][x] = left5 + m5
            a2[y][x] = left2 + m2
            continue

        if x == 0:
            a5[y][x] = up5 + m5
            a2[y][x] = up2 + m2
            continue

        a5[y][x] = min(up5, left5) + m5
        a2[y][x] = min(up2, left2) + m2

def getpath(k):
    p = ''
    y = x = n - 1

    while not (y == 0 and x == 0):
        if y and x:
            if k == 5:
                if a5[y - 1][x] < a5[y][x - 1]:
                    p += 'D'
                    y -= 1
                else:
                    p += 'R'
                    x -= 1
            else:
                if a2[y - 1][x] < a2[y][x - 1]:
                    p += 'D'
                    y -= 1
                else:
                    p += 'R'
                    x -= 1
        elif y == 0:
            p += 'R'
            x -= 1
        elif x == 0:
            p += 'D'
            y -= 1

    return p[::-1]

ten = 0
path = ''
if a5[n - 1][n - 1] < a2[n - 1][n - 1]:
    ten = a5[n - 1][n - 1]
    path = getpath(5)
else:
    ten = a2[n - 1][n - 1]
    path = getpath(2)

if ten > 1 and x0 > -1:
    ten = 1
    path = 'R' * x0 + 'D' * (n - 1) + 'R' * (n - 1 - x0)

print(ten)
print(path)


# -*- coding:utf-8 -*-

"""

created by shuangquan.huang at 1/3/20

"""

import collections
import time
import os
import sys
import bisect
import heapq
from typing import List

def count(val, div):
    c = 0
    while val % div == 0:
        val //= div
        c += 1
    return c

def solved(A, N, div):
    dp = [[float('inf') for _ in range(N)] for _ in range(N)]
    pre = [['' for _ in range(N)] for _ in range(N)]
    dp[0][0] = count(A[0][0], div)
    for r in range(N):
        for c in range(N):
            dc = count(A[r][c], div)
            if r > 0 and dp[r-1][c] + dc < dp[r][c]:
                dp[r][c] = dp[r-1][c] + dc
                pre[r][c] = 'U'
            if c > 0 and dp[r][c-1] + dc < dp[r][c]:
                pre[r][c] = 'L'
                dp[r][c] = dp[r][c-1] + dc

    path = []
    r, c = N-1, N-1
    while r >= 0 and c >= 0:
        if pre[r][c] == 'U':
            path.append('D')
            r, c = r-1, c
        else:
            path.append('R')
            r, c = r, c-1

    return dp[N-1][N-1], ''.join(path[::-1][1:])

def solve(A, N):
    a, b = solved(A, N, 2)
    c, d = solved(A, N, 5)
    if a < c:
        print(a)
        print(b)
    else:
        print(c)
        print(d)

N = int(input())
A = []
for i in range(N):
    row = [int(x) for x in input().split()]
    A.append(row)
solve(A, N)

# import random
# while True:
#     N = 1000
#     A = []
#     for i in range(N):
#         row = [random.randint(0, 10 ** 9) for _ in range(N)]
#         A.append(row)
#     solve(A, N)