CodeEff/ECCO huggingface dataset:
# Original solution
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
mod = 10 ** 9 + 7

def main():
    result = 1
    i = -1
    j = -1
    used_area = 0

    A.sort(reverse=True)
    B.sort(reverse=True)

    for x in range(N * M, 0, -1):
        while i < N-1:
            if A[i+1] >= x:
                i += 1
            else:
                break

        while j < M-1:
            if B[j+1] >= x:
                j += 1
            else:
                break

        marked_row = False
        marked_col = False

        count_row = A[0:i+1].count(x)
        if count_row > 1:
            return(0)
        if count_row == 1:
            usable_row = 1
            marked_row = True
        else:
            usable_row = i+1

        count_col = B[0:j+1].count(x)
        if count_col > 1:
            return(0)
        if count_col == 1:
            usable_col = 1
            marked_col = True
        else:
            usable_col = j+1

        if marked_row or marked_col:
            usable_area = usable_row * usable_col
        else:
            usable_area = usable_row * usable_col - used_area

        if usable_area <= 0:
            return(0)

        result = result * usable_area % mod
        used_area += 1

    return(result)


if __name__ == '__main__':
    print((main()))


# Optimized solution
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
mod = 10 ** 9 + 7

def main():
    result = 1
    i = -1
    j = -1
    used_area = 0

    A.sort(reverse=True)
    B.sort(reverse=True)

    for x in range(N * M, 0, -1):
        expanded_row = 0
        expanded_col = 0
        while i < N-1:
            if A[i+1] >= x:
                i += 1
                expanded_row += 1
            else:
                break

        while j < M-1:
            if B[j+1] >= x:
                j += 1
                expanded_col += 1
            else:
                break

        marked_row = False
        marked_col = False

        if expanded_row > 1:
            return(0)
        if expanded_row == 1:
            usable_row = 1
            marked_row = True
        else:
            usable_row = i+1

        if expanded_col > 1:
            return(0)
        if expanded_col == 1:
            usable_col = 1
            marked_col = True
        else:
            usable_col = j+1

        if marked_row or marked_col:
            usable_area = usable_row * usable_col
        else:
            usable_area = usable_row * usable_col - used_area

        # print('x:', x)
        # print('usable_row:', A[0:i+1])
        # print('usable_col:', B[0:j+1])
        # print('usable_area:', usable_area)

        if usable_area <= 0:
            return(0)

        result = result * usable_area % mod
        used_area += 1

    return(result)


if __name__ == '__main__':
    print((main()))
# Original solution
def solve():
    MOD = 10 ** 9 + 7
    N, M = list(map(int, input().split()))
    A = set(map(int, input().split()))
    B = set(map(int, input().split()))
    
    row, columun = 0, 0
    ans = 1
    for i in range(N * M, 0, -1):
        in_A = i in A
        in_B = i in B
        if in_A and in_B:
            row += 1
            columun += 1
        elif in_A:
            row += 1
            ans *= columun
        elif in_B:
            columun += 1
            ans *= row
        else:
            ans *= row * columun - (N * M - i)
    print((ans % MOD))


if __name__ == '__main__':
    solve()


# Optimized solution
def solve():
    MOD = 10 ** 9 + 7
    N, M = list(map(int, input().split()))
    A = set(map(int, input().split()))
    B = set(map(int, input().split()))
    
    row, columun = 0, 0
    ans = 1
    for i in range(N * M, 0, -1):
        in_A = i in A
        in_B = i in B
        if in_A and in_B:
            row += 1
            columun += 1
        elif in_A:
            row += 1
            ans *= columun
        elif in_B:
            columun += 1
            ans *= row
        else:
            ans *= row * columun - (N * M - i)
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    solve()
# Original solution
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

# A.sort(reverse=True)
# B.sort(reverse=True)

rowrange = 0
colrange = 0
ans = 1
for i in reversed(list(range(1, N * M + 1))):
    r = i in A
    c = i in B
    if r is True and c is True:
        rowrange += 1
        colrange += 1
    elif r is True and c is False:
        rowrange += 1
        ans = (colrange * ans) % (10 ** 9 + 7)
    elif r is False and c is True:
        colrange += 1
        ans = (rowrange * ans) % (10 ** 9 + 7)
    else:
        ans = ((rowrange * colrange - (N * M - i)) * ans) % (10 ** 9 + 7)
print(ans)


# Optimized solution
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

# A.sort(reverse=True)
# B.sort(reverse=True)

rowrange = 0
colrange = 0
ans = 1
for i in reversed(list(range(1, N * M + 1))):
    r = i in A
    c = i in B
    if r is True and c is True:
        rowrange += 1
        colrange += 1
        A.remove(i)
        B.remove(i)
    elif r is True and c is False:
        rowrange += 1
        ans = (colrange * ans) % (10 ** 9 + 7)
        A.remove(i)
    elif r is False and c is True:
        colrange += 1
        ans = (rowrange * ans) % (10 ** 9 + 7)
        B.remove(i)
    else:
        ans = ((rowrange * colrange - (N * M - i)) * ans) % (10 ** 9 + 7)
print(ans)
# Original solution
from math import ceil


def main():
    l = [int(eval(input())) for _ in range(6)]
    n, a, b, c, d, e = l
    group = ceil(n / min(a, b, c, d, e))
    print((4 + group))


if __name__ == '__main__':
    main()



# Optimized solution
from math import ceil


def main():
    n = int(eval(input()))
    required_times = [int(eval(input())) for _ in range(5)]
    groups = ceil(n / min(required_times))
    print((groups + 4))


if __name__ == '__main__':
    main()
# Original solution
n = int(eval(input()))
move = [int(eval(input())) for i in range(5)]
div,mod = divmod(n,min(move))
if mod == 0:
    print((div + 4))
else:print((div + 5))

# Optimized solution
import math
n = int(eval(input()))
move = [int(eval(input())) for i in range(5)]
print((math.ceil(n / min(move)) + 4))
# Original solution
import math

N=int(eval(input()))
A=[int(eval(input())) for _ in range(5)]
n=min(A)
for i in range(5):
  if n==A[i]:
    p=i
    break
k=math.ceil(N/n)
print((k+4))

# Optimized solution
import math

N=int(eval(input()))
A=[int(eval(input())) for _ in range(5)]
print((math.ceil(N/min(A))+4))
# Original solution
N = int(eval(input()))
A = [int(eval(input())) for i in range(5)] #A[i]:amount of people able to be carried at once from i to i+1
B = [0] * 6 #B[i]:amount of people at i now 
cnt = 0

#max people able to be transported in m minutes
P = [0] * 9
B[0] = 10**15
for m in range(9):
    for i in range(5,0,-1):
        B[i] += min(A[i-1],B[i-1])
        B[i-1] -= min(A[i-1],B[i-1])
        
    P[m] = B[5]
    cnt += 1
#print(P)
x = N // P[-1]
y = N % P[-1]
if y == 0:
    print((5*x+4))
    exit(0)
for j in range(7,2,-1):
    if P[j]<y:
        time = 5 * x + j + 2
        print(time)
        exit(0)
        


# Optimized solution
import math
N = int(eval(input()))
A = [int(eval(input())) for i in range(5)]
print((math.ceil(N/min(A))+4))
# Original solution
n = int(eval(input()))
L = [int(eval(input())) for i in range(5)]
ans = 5

max_ = -1
for l in L:
    if n <= l:
        continue
    else:
        q, r = divmod(n, l)
        if r == 0:
            max_ = max(max_, q-1)
        else:
            max_ = max(max_, q)
if max_ != -1:
    ans += max_
print(ans)


# Optimized solution
n = int(eval(input()))
L = [int(eval(input())) for _ in range(5)]

ans = 5
if n%min(L) == 0:
    ans += n//min(L)-1
else:
    ans += n//min(L)+1-1
print(ans)
# Original solution
#!/usr/bin/env python3

import re

n = int(eval(input()))
p = []
min = 1000000000000000

for i in range(5):
    x = int(eval(input()))
    p.append(x)
    if(min > x):
        min = x

if(n%min == 0):
    print((int(n/min) + 4))
else:
    print((int(n/min) + 5))


# Optimized solution
#!/usr/bin/env python3
#ABC123 C
import math
L = [int(eval(input())) for _ in range(6)]

N = L[0]
L.remove(L[0])
L.sort()
min = L[0]
print((math.ceil(N/L[0]) + 4))
# Original solution
n,*a=list(map(int,open(0).read().split()));a=min(a);print((4+(n+a-1)//a))

# Optimized solution
n, *a = list(map(int, open(0).read().split()))
b = min(a)
print((4 + (n+b-1)//b))
# Original solution
import math
n = int(eval(input()))
l = [int(eval(input())) for i in range(5)]
print((math.ceil(n/min(l))+4))


# Optimized solution
import math

n = int(eval(input()))
ls = [int(eval(input())) for _ in range(5)]
print((math.ceil(n/min(ls))+4))
# Original solution
from math import ceil
n = int(eval(input()))
A = [int(eval(input())) for i in range(5)]
print((ceil(n/min(A))+4))


# Optimized solution
from math import ceil
n = int(eval(input()))
t = [int(eval(input())) for i in range(5)]
print((4+ceil(n/min(t))))
# Original solution
import math
n = int(eval(input()))
a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
d = int(eval(input()))
e = int(eval(input()))
time = min(a, b, c, d, e)
if n < time:
    print((5))
else:
    print((math.ceil(n / time) + 4))


# Optimized solution
import math
N = int(eval(input()))
carry = [int(eval(input())) for _ in range(5)]
print((math.ceil(N / min(carry))+4))
# Original solution
def main():
    N = int(eval(input()))
    T = [int(eval(input())) for i in range(5)]
    minT = min(T)
    bo = (N + minT - 1)//minT
    print((4+bo))


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    N = int(eval(input()))
    A = [int(eval(input())) for i in range(5)]
    print((0--N//min(A) + 4))


if __name__ == '__main__':
    main()
# Original solution
def ii2ss(n):
    ss = []
    for i in range(n):
        ss.append(eval(input()))
    return ss

def sp2nn(sp, sep=' '):
    return [int(s) for s in sp.split(sep)]

def ss2nn(ss):
    return [int(s) for s in list(ss)]

import math
def main(ss):
    N, A, B, C, D, E = ss2nn(ss)
    m = min(A, B, C, D, E)
    return math.ceil(N / m) + 4

ss = ii2ss(6)
print((main(ss)))

# Optimized solution
# AtCoder Beginner Contest 123
# https://atcoder.jp/contests/abc123
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

import math
def main():
    N = i2n()
    ABCDE = ii2nn(5)
    m = min(ABCDE)
    n = int(math.ceil(N / m)) + 4
    print(n)

main()
# Original solution
import sys
import math

ns = [int(i) for i in sys.stdin.read().strip().split('\n')]
n = ns[0]
ns = ns[1:]
m = min(ns)

ans = math.ceil(n / m) + 4
print(ans)


# Optimized solution
import math
import sys

n, *ns = [int(i) for i in sys.stdin.read().strip().split('\n')]
m = min(ns)

ans = math.ceil(n / m) + 4
print(ans)
# Original solution
import math

N = int(eval(input()))
d = [int(eval(input())) for i in range(5)]

mi = d[0]
Ans = math.ceil(N / mi)
for i in d[1:]:
  Ans += 1
  if i < mi:
    x = math.ceil(N / i) - math.ceil(N / mi)
    Ans += x
    mi = i   

print(Ans)

# Optimized solution
N = int(eval(input()))
A = int(eval(input()))
B = int(eval(input()))
C = int(eval(input()))
D = int(eval(input()))
E = int(eval(input()))

x = min(A, B, C, D, E)

ans = 4 + N // x
if N % x != 0:
  ans += 1

print(ans)
# Original solution
N = int(eval(input()))
L = [0 for i in range(5)]
for i in range(5):
    L[i] = int(eval(input()))
    
time = [0 for i in range(5)]
time[0] = (N-1)//L[0] + 1
for i in range(4):
    if L[i] <= L[i+1]:
        time[i+1] = time[i]
    else:
        time[i+1] = (N-1)//L[i+1] + 1
        
ans = max(time) + 4
        
print(ans)

# Optimized solution
N = int(eval(input()))
L = [int(eval(input())) for _ in range(5)]

n = min(L)
ans = (N+n-1) // n + 4
print(ans)
# Original solution
n=int(eval(input()))
m=10**15+1
mi=0
for i in range(5):
  a=int(eval(input()))
  if a<m:
    m=a
    mi=i
print(((n-1)//m+1+5-1))

# Optimized solution
n=int(eval(input()))
m=10**15+1
a=[int(eval(input())) for _ in range(5)]
print(((n-1)//min(a)+5))
# Original solution
import sys
import math
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n = ni()
a = []
for _ in range(5):
    a.append(ni())
print((math.ceil(n/min(a))+4))



# Optimized solution
import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n = ni()
a = []
for _ in range(5):
    a.append(ni())

amin = min(a)
ans = (n-1)//min(a) + 1 + 4
print(ans)
# Original solution
n=int(eval(input()))
a=int(eval(input()))
b=int(eval(input()))
c=int(eval(input()))
d=int(eval(input()))
e=int(eval(input()))
m = min(a,b,c,d,e)
cnt = (n-1)//m + 1
print((cnt+4))

# Optimized solution
n = int(eval(input()))
m = min([int(eval(input())) for _ in range(5)])
cnt = (n-1)//m + 1
print((cnt + 4))
# Original solution
N = int(eval(input()))
MIN = float("inf")
for _ in range(5):
    MIN = min(MIN, int(eval(input())))

from math import ceil

print((ceil(N / MIN) + 4))

# Optimized solution
N = int(eval(input()))
MIN = float("inf")
for _ in range(5):
    MIN = min(MIN, int(eval(input())))

print(((N + MIN - 1) // MIN + 4))
# Original solution
from math import ceil

N = int(eval(input()))
v = [int(eval(input())) for _ in range(5)]

print((ceil(N / min(v)) + 4))

# Optimized solution
from math import ceil

n = int(eval(input()))
a = [int(eval(input())) for _ in range(5)]

print((ceil(n / min(a)) + 4))
# Original solution
#coding: utf-8
from math import ceil
N = int(eval(input()))
l = []
for i in range(5):
    l.append(int(eval(input())))
print((ceil(N / min(l) + 4)))

# Optimized solution
#coding: utf-8
N = int(eval(input()))
l = []
for i in range(5):
    l.append(int(eval(input())))
if N % min(l) != 0:
    print((N // min(l) + 5))
else:
    print((N // min(l) + 4))
# Original solution
N = int(eval(input()))
A = int(eval(input()))
B = int(eval(input()))
C = int(eval(input()))
D = int(eval(input()))
E = int(eval(input()))

dp = [0] * 6
dp[0] = N
T = [A,B,C,D,E]
ans = 0

ans = -(-N//min(T)) + 4
# while dp[5] < N:
#     for i in range(4, -1, -1):
#         if dp[i] == 0:
#             continue
#         dp[i+1] += min(dp[i],T[i])
#         dp[i] -= min(dp[i],T[i])
#     ans += 1
print(ans)


# Optimized solution
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = [0] * 5
for i in range(5):
    A[i] = ir()

mi = min(A)
plus = -(-N//mi)
answer = 4 + plus
print(answer)
# Original solution
import math

N = int(eval(input()))

A = [0] * 5

human_in_city = [0]*6
human_in_city[0] = N
moving_human = [0]*5

for i in range(5):
    A[i] = int(eval(input()))

# count = 0
# while human_in_city[-1] != N:
#     count += 1
#     for i in range(5):
#         if human_in_city[i] >= A[i]:
#             moving_human[i] = A[i]
#         else:
#             moving_human[i] = human_in_city[i]
#     for i in range(5):
#         human_in_city[i+1] += moving_human[i]
#         human_in_city[i] -= moving_human[i]

min_A = min(A)

count = 5 + math.ceil(N / min_A) -1

print(count)

# Optimized solution
N = int(eval(input()))
A = int(eval(input()))
B = int(eval(input()))
C = int(eval(input()))
D = int(eval(input()))
E = int(eval(input()))

min_p = min(A, B, C, D, E)

import math

min_p = math.ceil(N / min_p)
print((min_p+4))
# Original solution
from math import ceil
N = int(eval(input()))
L = [int(eval(input())) for k in range(5)]
ans = 5
for k in range(5):
    ans = max(ans,4+ceil(N/L[k]))
print(ans)


# Optimized solution
from math import ceil
N = int(eval(input()))
A = int(eval(input()))
B = int(eval(input()))
C = int(eval(input()))
D = int(eval(input()))
E = int(eval(input()))
L = [A,B,C,D,E]
m = min(L)
print((4+ceil(N/m)))
# Original solution
N = int(eval(input()))
A = [int(eval(input())) for _ in range(5)]
a = min(A)
n = N//a
k = N%a
ans = 0
if n>0:
    ans = 5+(n-1)
    if k>0:
        ans += 1
else:
    if k>0:
        ans = 5
print(ans)

# Optimized solution
N = int(eval(input()))
A = [int(eval(input())) for _ in range(5)]
a = min(A)
n = N//a
b = N%a
if b==0:
    print((5+n-1))
else:
    print((5+n))
# Original solution
n = int(eval(input()))
lis = [int(eval(input())) for i in range(5)]
key = 0
if n % min(lis) == 0:key = 1
print((5 + n//min(lis)-key))

# Optimized solution
n = int(eval(input()))
nu = min([int(eval(input())) for i in range(5)])
print((4 + bool(n%nu) + n//nu))
# Original solution
import itertools
import math
import fractions
import functools
import copy
n = int(eval(input()))
a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
d = int(eval(input()))
e = int(eval(input()))
original = [a,b,c,d,e]

print((math.ceil(n / min(original))+4))

# Optimized solution
import math


def main():
    n = int(eval(input()))
    # n, m = map(int, input().split())
    # a = list(map(int, input().split()))
    # s = input()
    # h = [int(input()) for _ in rane(n)]

    a = int(eval(input()))
    b = int(eval(input()))
    c = int(eval(input()))
    d = int(eval(input()))
    e = int(eval(input()))
    print((math.ceil(n / min(a, b, c, d, e)) + 4))


if __name__ == '__main__':
    main()
# Original solution
import copy
N = int(eval(input()))

A, B, C, D, E = [int(eval(input())) for i in range(5)]
Xs = [N, 0, 0, 0, 0, 0]
Fs = [A, B, C, D, E]
Fmin = min(Fs)
c = 0
while True:
    #print(Xs)
    nXs = copy.copy(Xs)
    for i in range(len(Fs)):
        if Xs[i] - Fs[i] > 0:
            nXs[i] -= Fs[i]
            nXs[i+1] += Fs[i]
        else:
            nXs[i] -= Xs[i]
            nXs[i+1] += Xs[i]
        #print(nXs)
    Xs = nXs
    c+=1
    if max(Xs[1:5]) == Fmin:
        c+=Xs[0]//Fmin
        Xs[0]%=Fmin
    if sum(Xs[0:5]) == 0:
        break

print(c)

# Optimized solution
N = int(eval(input()))
min_ = min([int(eval(input())) for i in range(5)])

suf = 1 if N%min_ != 0 else 0
print((N//min_+4+suf))
# Original solution
import math

n = int(eval(input()))

m = 10 ** 15 + 1

for _ in range(5):
  m = min(m, int(eval(input())))

print((math.ceil(n / m) + 5 - 1))

# Optimized solution
import math

n = int(eval(input()))
m = min([int(eval(input())) for _ in range(5)])
print((math.ceil(n/m) + 4))
# Original solution
n = int(eval(input()))
a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
d = int(eval(input()))
e = int(eval(input()))
dic ={0:n,1:0,2:0,3:0,4:0,5:0}
time =0
if n == 10000000007:
    print((5000000008))
    exit()
while sum(dic)>0:
    if dic[5] == n:
        print(time)
        exit()
    if dic[4] > e:
        dic[4] -= e
        dic[5] += e
    else:
        dic[5] += dic[4]
        dic[4] = 0
    
    if dic[3] > d:
        dic[3] -= d
        dic[4] += d
    else:
        dic[4] += dic[3]
        dic[3] = 0
    
    if dic[2] > c:
        dic[2] -= c
        dic[3] += c
    else:
        dic[3] += dic[2]
        dic[2] = 0
    
    if dic[1] > b:
        dic[1] -= b
        dic[2] += b
    else:
        dic[2] += dic[1]
        dic[1] = 0
    
    if dic[0] > a:
        dic[0] -= a
        dic[1] += a
    else:
        dic[1] += dic[0]
        dic[0] = 0
    time += 1

# Optimized solution
n = int(eval(input()))
a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
d = int(eval(input()))
e = int(eval(input()))
time =0
amin = min(a,b,c,d,e)
time=(n//amin+1 if n%amin != 0 else n/amin)+4
print((int(time)))
# Original solution
import math
N = int(eval(input()))
A = int(eval(input()))
B = int(eval(input()))
C = int(eval(input()))
D = int(eval(input()))
E = int(eval(input()))
X = min([A,B,C,D,E])
t=math.ceil(N/X)
print((t+4))

# Optimized solution
N = int(eval(input()))
ls = [int(eval(input())) for _ in range(5)]
X = min(ls)
print(((N+X-1)//X+4))
# Original solution
import math

N = int(eval(input()))
A = int(eval(input()))
B = int(eval(input()))
C = int(eval(input()))
D = int(eval(input()))
E = int(eval(input()))

bottleneck = min([A, B, C, D, E])
n_addition = math.ceil(N / bottleneck) - 1
print((5 + n_addition))


# Optimized solution
import math

n_paths = 5
N = int(eval(input()))
ABCDE = [int(eval(input())) for _ in range(n_paths)]

bottleneck = min(ABCDE)
n_addition = math.ceil(N / bottleneck) - 1
print((n_paths + n_addition))
# Original solution
n = int(eval(input()))
a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
d = int(eval(input()))
e = int(eval(input()))


ans = 0 - -n//min(a, b, c, d, e) + 4

print(ans)

# Optimized solution
n = int(eval(input()))
l = [int(eval(input())) for _ in range(5)]
ans = 0 - -n//min(l) + 4
print(ans)
# Original solution
import sys
f = sys.stdin


board = [[0 for i in range(11)] for j in range(11)]
for i, line in enumerate(f):
    for j, c in enumerate(line.strip()):
        board[i + 1][1 + (i + 1) % 2 + j * 2] = int(c)

step = {(-1, 0 ):'L',(0, -1 ):'U',(1, 0 ):'R',(0, 1):'D'}
    
    
start = pre_loc = 1 + 1j
loc = 3 + 1j
print('R',end='')
while loc != start:
    for direct in [(pre_loc - loc) / 2 * 1j ** (i + 1) for i in range(3)]:
        if board[int(loc.imag + direct.imag)][int(loc.real + direct.real)]:
            pre_loc = loc
            loc += direct * 2
            print(step[(direct.real,direct.imag)],end='')
            break
print()


# Optimized solution
import sys
f = sys.stdin

board = [[0 for i in range(11)] for j in range(11)]
for i, line in enumerate(f):
    for j, c in enumerate(line.strip()):
        board[i + 1][1 + (i + 1) % 2 + j * 2] = int(c)

step = {(-1, 0 ):'L',(0, -1 ):'U',(1, 0 ):'R',(0, 1):'D'}
    
    
start = pre_loc = 1 + 1j
loc = 3 + 1j
print('R',end='')
while loc != start:
    for direct in [(pre_loc - loc) / 2 * 1j ** (i + 1) for i in range(4)]:
        if board[int(loc.imag + direct.imag)][int(loc.real + direct.real)]:
            pre_loc = loc
            loc += direct * 2
            print(step[(direct.real,direct.imag)],end='')
            break
print()
# Original solution
wx=[]
wy=[]

def readdata():
    z=[]
    try:
        while True:
            z.append(input())
    except: return z

def nextpath(p, dir0):
    for e in [3,0,1,2]:
        dp = ispath(p, (dir0+e)%4)
        if dp!=[]: break
    return dp

def ispath(p, dir1):
    y,x = p
    dp = []
    if   dir1==0 and y>0            and wy[y-1][x]=="1": dp= 0
    elif dir1==1 and x<len(wx[0])   and wx[y][x]  =="1": dp = 1
    elif dir1==2 and y<len(wy[0])-1 and wy[y][x]  =="1": dp = 2
    elif dir1==3 and x>0            and wx[y][x-1]=="1": dp = 3
    return dp

def f0037():
    p =[0,0]
    dp = 1
    msg = []
    while True:
        dp = nextpath(p, dp)
        p[0]+=[-1,0,1,0][dp]
        p[1]+=[0,1,0,-1][dp]
        msg.append("URDL"[dp])
        if p==[0,0]: break 
    return msg

z = readdata()
wx = z[0::2]
wy = z[1::2]
msg = f0037()    
print("".join(msg))

# Optimized solution
wx=[]
wy=[]

def readdata():
    z=[]
    try:
        while True:
            z.append(input())
    except: return z

def nextpath(p,dir0):
    for e in [3,0,1,2]:
        d = (dir0+e)%4
        if ispath(p,d): return d
    return None

def ispath(p,d):
    y,x = p
    f=""
    try:
        if   d==0 and y>0: f = wy[y-1][x]
        elif d==1 and x<len(wy): f = wx[y][x]
        elif d==2 and y<len(wx): f = wy[y][x]
        elif d==3 and x>0: f = wx[y][x-1]
    except: pass
    return f=="1"

def f0037():
    p =[0,0]
    dp = 1
    msg = []
    while True:
        dp = nextpath(p, dp)
        p[0] += [-1,0,1,0][dp]
        p[1] += [0,1,0,-1][dp]
        msg.append("URDL"[dp])
        if p==[0,0]: break
    return "".join(msg)

z = readdata()
wx = z[0::2]
wy = z[1::2]
print(f0037())
# Original solution
D, L = list(map(int, input().split()))
print((sum(divmod(D, L))))

# Optimized solution
D, L = list(map(int, input().split()))
print((D//L + D%L))