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: 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
print("")

Python: def is_wall(x1,y1,x2,y2):
    if x1<0 or 4<x1 or y1<0 or 4<y1 or x2<0 or 4<x2 or y2<0 or 4<y2:
        return False
    elif x1 == x2:
        if y1>y2: y1,y2 = y2,y1
        if y2-y1 != 1: return False
        return (walls[y1*2+1][x1] == "1")
    elif y1 == y2:
        if x1>x2: x1,x2 = x2,x1
        if x2-x1 != 1: return False
        return (walls[y1*2][x1] == "1")
    else: return False

def nextmove(x,y):
    lastmove = moves[-1]
    if lastmove == 3: lastmove = -1
    if lastmove < -1: lastmove += 4
    if is_wall(x,y,x+direction[lastmove+1][1],y+direction[lastmove+1][2]):
        return lastmove+1,x+direction[lastmove+1][1],y+direction[lastmove+1][2]

    if is_wall(x,y,x+direction[lastmove][1],y+direction[lastmove][2]):
        return lastmove,x+direction[lastmove][1],y+direction[lastmove][2]

    if is_wall(x,y,x+direction[lastmove-1][1],y+direction[lastmove-1][2]):
        return lastmove-1,x+direction[lastmove-1][1],y+direction[lastmove-1][2]

    if is_wall(x,y,x+direction[lastmove-2][1],y+direction[lastmove-2][2]):
        return lastmove-2,x+direction[lastmove-2][1],y+direction[lastmove-2][2]

direction = [["R",1,0],["U",0,-1],["L",-1,0],["D",0,1]]
walls = []
moves = [0]
for _ in range(9):
    walls.append(input())
lastx = 1
lasty = 0
print("R", end = "")
while True:
    move,lastx,lasty = nextmove(lastx, lasty)
    moves.append(move)
    print(direction[move][0], end = "")
    if lastx == 0 and lasty == 0: break
print()

Python: g=[[0]*5 for _ in[0]*5]
for i in range(9):
 e=input()
 for j in range(4+i%2):
  if int(e[j]):
   if i%2:g[i//2][j]+=4;g[i//2+1][j]+=1
   else:r=g[i//2];r[j]+=2;r[j+1]+=8
y,x=0,1
k=1
a=[1]
while 1:
 k+=2
 for _ in[0]*4:
  k+=1
  if g[y][x]&int(2**(k%4)):a+=[k%4];break
 if k%2:x+=1-2*((k%4)>0)
 else:y+=2*((k%4)>0)-1
 if x+y==0:break
print(''.join('URDL'[c]for c in a))

Python: import sys

point = [[[0 for i in range(4)] for j in range(5)] for k in range(5)]
raw = 0
for line in sys.stdin:
    way = list(map(int, line.strip()))
    if len(way) == 4:
        for col in range(4):
            if way[col] == 1:
                point[raw][col][1] = point[raw][col + 1][3] = 1

    elif len(way) == 5:
        for col in range(5):
            if way[col] == 1:
                point[raw][col][2] = point[raw + 1][col][0] = 1
        raw += 1

dict = {0:"U", 1:"R", 2:"D", 3:"L"}
cold = [0, 1, 0, -1]
rawd = [-1, 0, 1, 0]

raw = 0
col = 0
nowd = 1
ans = ""

while True:
    for dirc in [(x - 1) % 4 for x in range(nowd, nowd + 4)]:
        if point[raw][col][dirc] == 1:
            ans += dict[dirc]
            raw += rawd[dirc]
            col += cold[dirc]
            nowd = dirc
            break
    if raw == 0 and col == 0:
        break
        
print(ans)

Python: g=[[0]*5 for _ in[0]*5]
for i in range(9):
 e=input()
 for j in range(4+i%2):
  if int(e[j]):
   if i%2:g[i//2][j]+=4;g[i//2+1][j]+=1
   else:r=g[i//2];r[j]+=2;r[j+1]+=8
y,x=0,1
k=1
a=[1]
while 1:
 k+=2
 for _ in[0]*4:
  k+=1
  if g[y][x]&int(2**(k%4)):a+=[k%4];break
 if k%2:x+=1-2*((k%4)>1)
 else:y+=2*((k%4)>0)-1
 if x+y<1:break
print(''.join('URDL'[c]for c in a))