Go: package main

import (
	"bufio"
	"os"
	"strings"
	"strconv"
	"fmt"
)

var points [5][5][4]bool

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for i := 0; i < 9; i++ {
		y := i/2
		if i%2 == 0 {
			scanner.Scan()
			info := strings.Split(scanner.Text(), "")
			for k := range info {
				e, _ := strconv.Atoi(info[k])
				if e != 0 {
					points[y][k][1], points[y][k+1][3] = true, true
				}
			}
		} else {
			scanner.Scan()
			info := strings.Split(scanner.Text(), "")
			for k := range info {
				e, _ := strconv.Atoi(info[k])
				if e != 0 {
					points[y][k][2], points[y+1][k][0] = true, true
				}
			}
		}
	}
	x := 1
	y := 0
	dir := 1
	dx := []int{0, 1, 0, -1}
	dy := []int{-1, 0, 1, 0}
	ds := "URDL"
	fmt.Printf("%s", string(ds[dir]))
	for !(x == 0 && y == 0) {
		if points[y][x][(dir+3)%4] {
			dir = (dir+3)%4
		} else if points[y][x][dir] {

		} else if points[y][x][(dir+1)%4] {
			dir = (dir+1)%4
		} else {
			dir = (dir+2)%4
		}
		x += dx[dir]
		y += dy[dir]
		fmt.Printf("%s", string(ds[dir]))
	}
	fmt.Println()
}

Python: import sys

loc = [3, 1]

def print_dir(h):
    if h == 0:
        print('R', end='')
    elif h == 1:
        print('D', end='')
    elif h == 2:
        print('L', end='')
    elif h == 3:
        print('U', end='')

dir = [[1, 0], [0, 1], [-1, 0], [0, -1]]
hand = 3

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

print("R", end='')

while loc != [1, 1]:
    for i in range(4):
        if board[loc[1]+dir[(hand+i)%4][1]][loc[0]+dir[(hand+i)%4][0]] == 1:
            loc[0] += dir[(hand+i)%4][0]*2
            loc[1] += dir[(hand+i)%4][1]*2
            if i == 1:
                print_dir((hand+1)%4)
            elif i == 2:
                print_dir((hand+2)%4)
                hand = (hand+1)%4
            elif i == 3:
                print_dir((hand+3)%4)
                hand = (hand+2)%4
            elif i == 0:
                print_dir(hand%4)
                hand = (hand+3)%4

            break

print()

Python: import sys
n = [input() for i in range(9)]
path = [[0 for i in range(5)] for j in range(5)]

for i, v in enumerate([a[1] for a in enumerate(n) if a[0] % 2 == 0]):
    for j in range(4):
        if v[j] == '1':
            path[i][j] += 1
            path[i][j+1] += 2


for i, v in enumerate([a[1] for a in enumerate(n) if a[0] % 2 != 0]):
    for j in range(5):
        if v[j] == '1':
            path[i][j] += 4
            path[i+1][j] += 8

dur = {'R':(1, 0, 1),
       'L':(2, 0, -1),
       'U':(8, -1, 0),
       'D':(4, 1, 0)}

dur_next = {'R':('U','R','D'),
            'L':('D','L','U'),
            'U':('L','U','R'),
            'D':('R','D','L')}
def walk():
    global cx, cy
    cx = dur[d][2] + cx
    cy = dur[d][1] + cy

def next_D():
    global cx,cy,d,dur
    for nd in dur_next[d]:
        if path[cy][cx] & dur[nd][0]:
            d = nd
            break

cx = cy = 0
d = 'R'

while 1:
    sys.stdout.write(d)
    walk()
    if cx == cy == 0:
        break

    next_D()

Python: def move(position):
    x = position[0]
    y = position[1]
    d = position[2]
    if d == "L":
        p = "DLUR"
    elif d == "R":
        p = "URDL"
    elif d == "U":
        p = "LURD"
    else:
        p = "RDLU"
    for i in range(4):
        if p[i] in grid[y][x]:
            d = p[i]
            if d == "L":
                print("L",end="")
                x -= 1
                break
            elif d == "R":
                print("R",end="")
                x += 1
                break
            elif d == "U":
                print("U",end="")
                y -= 1
                break
            else:
                print("D",end="")
                y += 1
                break
    return [x, y, d]

pos = [1,1,"R"]
grid = [["" for i in range(6)] for j in range(6)]
for i in range(9):
    inp = input()
    if i%2 == 0:
        for j in range(4):
            if inp[j] == "1":
                grid[i//2 + 1][j + 1] += "R"
                grid[i//2 + 1][j + 2] += "L"
    else:
        for j in range(5):
            if inp[j] == "1":
                grid[i//2 + 1][j + 1] += "D"
                grid[i//2 + 2][j + 1] += "U"
while True:
    pos = move(pos)
    if pos[0] == 1 and pos[1] == 1:
        break

Python: import sys
n = [input() for i in range(9)]
path = [[0 for i in range(5)] for j in range(5)]

for i, v in enumerate([a[1] for a in enumerate(n) if a[0] % 2 == 0]):
    for j in range(4):
        if v[j] == '1':
            path[i][j] += 1
            path[i][j+1] += 2


for i, v in enumerate([a[1] for a in enumerate(n) if a[0] % 2 != 0]):
    for j in range(5):
        if v[j] == '1':
            path[i][j] += 4
            path[i+1][j] += 8

dur = {'R':(1, 0, 1),
       'L':(2, 0, -1),
       'U':(8, -1, 0),
       'D':(4, 1, 0)}

dur_next = {'R':('U','R','D','L'),
            'L':('D','L','U','R'),
            'U':('L','U','R','D'),
            'D':('R','D','L','U')}
def walk():
    global cx, cy
    cx = dur[d][2] + cx
    cy = dur[d][1] + cy

def next_D():
    global cx,cy,d,dur
    for nd in dur_next[d]:
        if path[cy][cx] & dur[nd][0]:
            d = nd
            break

cx = cy = 0
d = 'R'
log = []

while 1:
    log.append(d)
    walk()
    if cx == cy == 0:
        break

    next_D()

print(''.join(log))

Python: mat = [['0', '0', '0', '0', '0']]
for i in range(9):
    if i%2 ==0:
        tmpc = '0' + input() + '0'

    else:
        tmpc = input()

    mat.append(list(tmpc))
mat.append(['0', '0', '0', '0', '0'])

pos = [0,1]
move = ['R']
while True:
    mdict = {'U': [2*pos[0], pos[1]], 'R': [2*pos[0]+1, pos[1]+1], 'D': [2*pos[0]+2, pos[1]], 'L': [2*pos[0]+1, pos[1]]}
    if move[-1] == 'R':
        belst = ['U', 'R', 'D', 'L']

    elif move[-1] == 'D':
        belst = ['R', 'D', 'L', 'U']

    elif move[-1] == 'L':
        belst = ['D', 'L', 'U', 'R']

    else:
        belst = ['L', 'U', 'R', 'D']
            
    for i in belst:
        if mat[mdict[i][0]][mdict[i][1]] == '1':
            be = i
            break
    
    if be == 'U':
        pos[0] -= 1
    elif be == 'R':
        pos[1] += 1
    elif be == 'D':
        pos[0] += 1
    else:
        pos[1] -= 1
    
    move.append(be)

    if pos == [0, 0]:
        break

print(''.join(move))

Python: k = [[1,2,4,8],[4,8,1,2],[8,1,2,4],[2,4,8,1]]
m = [[0]*5 for _ in range(5)]

for i in range(9):
    a = input()
    if i%2:
        for j in range(5):
            if a[j] == '1':
                m[i//2][j] |= 4
                m[i//2+1][j] |= 1
    else:
        for j in range(4):
            if a[j] == '1':
                m[i//2][j] |= 2
                m[i//2][j+1] |= 8
y,x,direct = 0,0,0
ans = []
while True:
    for i in range(4):
        if m[y][x] & k[direct][i]:
            d = k[direct][i]
            if   d == 1: y -= 1; direct = 2
            elif d == 2: x += 1; direct = 0
            elif d == 4: y += 1; direct = 3
            else       : x -= 1; direct = 1
            ans.append(direct)
            break
    if not ( x or y ): break
print("".join("RLUD"[e] for e in ans))

Python: def idx_to_wxy(x, y, idx):
    return (2 * x + 1 + (idx % 2) * (2 - idx), 2 * y + 1 + (1 - idx % 2) * (1 - idx))
ws = [[0]*11 for _ in range(11)]
for i in range(1, 10):
    if i % 2:
        ws[i][2], ws[i][4], ws[i][6], ws[i][8] = map(int, list(input()))
    else:
        ws[i][1], ws[i][3], ws[i][5], ws[i][7], ws[i][9] = map(int, list(input()))
x = y = 0
ds = list('RDLU')
d = 'R'
while True:
    print(d, end='')
    idx = ds.index(d)
    x += (idx % 2) * (2 - idx)
    y += (1 - idx % 2) * (1 - idx)
    if x == y == 0:
        break
    for i in range(-1, 3):
        if ws[idx_to_wxy(x, y, (idx + i) % 4)[0]][idx_to_wxy(x, y, (idx + i) % 4)[1]]:
            d = ds[(idx + i) % 4]
            break
print('')