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
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    N = 5
    MP = [[[0]*4 for i in range(N)] for j in range(N)]
    dd = ((-1, 0), (0, -1), (1, 0), (0, 1))
    ds = "LURD"
    for i in range(N):
        s = readline().strip()
        for j in range(N-1):
            if s[j] == '1':
                MP[i][j][2] = MP[i][j+1][0] = 1
        if i < 4:
            s = readline().strip()
            for j in range(N):
                if s[j] == '1':
                    MP[i][j][3] = MP[i+1][j][1] = 1
    x = 1; y = 0; cd = 2
    de = [3, 0, 1, 2]
    ans = [2]
    while not x == y == 0:
        e = MP[y][x]
        for d in de:
            if e[cd + d - 4]:
                cd = (cd + d) % 4
                ans.append(cd)
                dx, dy = dd[cd]
                x += dx; y += dy
                break
    write("".join(map(ds.__getitem__, ans)))
    write("\n")
solve()

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+=str(k%4);break
 if k%2:x+=[1,-1][(k%4)>1]
 else:y+=[-1,1][(k%4)>0]
 if x+y==0:break
print(''.join('URDL'[int(c)]for c in a))

Python: grid = []
for i in range(9):
    grid += [input()]

position = [0, 0]
direction = 'R'
path = ''
while True:
    print(direction)
    if direction == 'R':
        path += direction
        position[1] += 1
        if position[0] > 0 and grid[position[0] - 1][position[1]] == '1':
            direction = 'U'
        elif position[1] < 4 and grid[position[0]][position[1]] == '1':
            direction = 'R'
        elif position[0] < 8 and grid[position[0] + 1][position[1]] == '1':
            direction = 'D'
        else:
            direction = 'L'
    elif direction == 'L':
        path += direction
        position[1] -= 1
        if position[0] < 8 and grid[position[0] + 1][position[1]] == '1':
            direction = 'D'
        elif position[1] > 0 and grid[position[0]][position[1] - 1] == '1':
            direction = 'L'
        elif position[0] > 0 and grid[position[0] - 1][position[1]] == '1':
            direction = 'U'
        else:
            if position[0] == position[1] == 0:
                break
            direction = 'R'
    elif direction == 'D':
        path += direction
        position[0] += 2
        if position[1] < 4 and grid[position[0]][position[1]] == '1':
            direction = 'R'
        elif position[0] < 8 and grid[position[0] + 1][position[1]] == '1':
            direction = 'D'
        elif position[1] > 0 and grid[position[0]][position[1] - 1] == '1':
            direction = 'L'
        else:
            direction = 'U'
    else:
        path += direction
        position[0] -= 2
        if position[1] > 0 and grid[position[0]][position[1] - 1] == '1':
            print('hello')
            direction = 'L'
        elif position[0] > 0 and grid[position[0] - 1][position[1]] == '1':
            direction = 'U'
        elif position[1] < 4 and grid[position[0]][position[1]] == '1':
            direction = 'R'
        else:
            direction = 'D'
print(path)

Python: class Coordinate(object):
    def __init__(self):
        self.path = [None, None, None, None]


class Maze(object):
    def __init__(self):
        self.a = [[Coordinate() for _ in [0]*5] for _ in [0]*5]

    def get_room(self, x, y):
        return self.a[y][x]

    def set_path(self, pos1, pos2):
        dir1, dir2 = (0, 2) if pos1[1] == pos2[1] else (1, 3)
        self.get_room(*pos1).path[dir1] = pos2
        self.get_room(*pos2).path[dir2] = pos1

    def solve(self):
        result, x, y, direction = "R", 1, 0, 0
        direction_sign = "RDLU"

        while not(x == 0 and y == 0):
            current = self.get_room(x, y)
            if current.path[(direction-1)%4]:
                direction = (direction-1)%4
            elif current.path[direction]:
                pass
            elif current.path[(direction+1)%4]:
                direction = (direction+1)%4
            else:
                direction = (direction+2)%4
            x, y = current.path[direction]
            result += direction_sign[direction]

        return result


maze = Maze()
for i in range(9):
    y = i//2
    dx, dy = (1, 0) if i%2 == 0 else (0, 1)
    for x, c in enumerate(input()):
        if c == "1":
            maze.set_path((x, y), (x+dx, y+dy))

print(maze.solve())

Python: grid = []
for i in range(9):
    grid += [input()]

position = [0, 0]
direction = 'R'
path = ''
while True:
    if direction == 'R':
        path += direction
        position[1] += 1
        if position[1] == 4 or grid[position[0]][position[1]] == '0':
            if position[0] > 0 and grid[position[0] - 1][position[1]] == '1':
                direction = 'U'
            elif position[0] < 8 and grid[position[0] + 1][position[1]] == '1':
                direction = 'D'
            else:
                direction = 'L'
    elif direction == 'L':
        path += direction
        position[1] -= 1
        if position[1] == 0 or grid[position[0]][position[1] - 1] == '0':
            if position[0] < 8 and grid[position[0] + 1][position[1]] == '1':
                direction = 'D'
            elif position[0] > 0 and grid[position[0] - 1][position[1]] == '1':
                direction = 'U'
            else:
                if position[0] == position[1] == 0:
                    break
                direction = 'R'
    elif direction == 'D':
        path += direction
        position[0] += 2
        if position[0] == 8 or grid[position[0] + 1][position[1]] == '0':
            if position[1] < 4 and grid[position[0]][position[1]] == '1':
                direction = 'R'
            elif position[1] > 0 and grid[position[0]][position[1] - 1] == '1':
                direction = 'L'
            else:
                direction = 'U'
    else:
        path += direction
        position[0] -= 2
        if position[0] == 0 or grid[position[0] - 1][position[1]] == '0':
            if position[1] > 0 and grid[position[0]][position[1] - 1] == '1':
                direction = 'L'
            elif position[1] < 4 and grid[position[0]][position[1]] == '1':
                direction = 'R'
            else:
                direction = 'D'
print(path)

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,-1][(k%4)>1]
 else:y+=[-1,1][(k%4)>0]
 if x+y==0:break
print(''.join('URDL'[c]for c in a))