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()
}

C++: #include<iostream>
#include<vector>
#include<map>
#include<string>
using namespace std;
vector<string> mp;
char c[]={'U','R','D','L'};
int dx[]={0,1,0,-1},
	dy[]={-1,0,1,0},
	fx[]={1,0,-1,0},
	fy[]={0,1,0,-1};
void func(int y,int x,int dir){
	cout<<c[dir];
	if(y==1&&(x==0||x==1)){
		cout<<endl;
		return;
	}
	//ツ前
	if(mp[dy[dir]+2*y][dx[dir]+2*x]=='1'){
		func(y,x,(dir+3)%4);
		return;
	}
	if(mp[y*2+dy[(dir+1)%4]+2*dy[dir]][x*2+dx[(dir+1)%4]+2*dx[dir]]=='1'){
		func(y+dy[dir],x+dx[dir],dir);
		return ;
	}
	//
	if(mp[2*y+dy[dir]+dy[(dir+1)%4]*2][2*x+dx[dir]+dx[(dir+1)%4]*2]=='1'){
		int q=(dir+1)%4;
		func(y+dy[dir]+dy[q],x+dx[dir]+dx[q],q);
		return;
	}
	func(y+fy[dir],x+fx[dir],(dir+2)%4);
	return;
}
int main(){
	string pre;
	mp.push_back(" 0 0 0 0 0 ");
	for(int i=0;i<9;i++){
		string s;
		if(i%2==0){
			s="0 ";
			cin>>pre;
			for(int j=0;j<4;j++){
				s+=pre[j];
				s+=' ';
			}
			s+='0';
			mp.push_back(s);
		}
		else{
			cin>>pre;
			s+=' ';
			for(int j=0;j<5;j++){
				s+=pre[j];
				s+=' ';
			}
			s+=' ';
			mp.push_back(s);
		}
	}
	mp.push_back(" 0 0 0 0 0 ");
	func(0,1,1);
	return 0;
}

C++: #include <string>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
typedef pair<int,int> P;
#define pb push_back
#define fi first
#define sec second
int angle=0;
int edge[6][6][4]={0};
vector<int> ans;
P now;
P nextpoint(P t,int angl)
{
	P f;
	f.fi=t.fi;
	f.sec=t.sec;
	if(angl==0)
	{
		f.sec++;
	}
	if(angl==1)
	{
		f.fi++;
	}
	if(angl==2)
	{
		f.sec--;
	}
	if(angl==3)
	{
		f.fi--;
	}
	return f;
}
void output(int n)
{
	if(n==0)
	{
		cout << 'R';
	}
	else if(n==1)
	{
		cout << 'D';
	}
	else if(n==2)
	{
		cout << 'L';
	}
	else
	{
		cout << 'U';
	}
	return ;
}
void step()
{
	int tmp;
	int ans;
	tmp=(angle+4-1)%4;
	while(1)
	{
		if(edge[now.fi][now.sec][tmp])break;
		tmp=(tmp+1)%4;
	}
	angle=tmp;
	P r;
	r.fi=nextpoint(now,angle).fi;
	r.sec=nextpoint(now,angle).sec;
	now.fi=r.fi;
	now.sec=r.sec;
	return ;
}
int main()
{
	now.fi=1;now.sec=1;
	for(int i=1;i<=9;i++)
	{
		if(i%2==1)
		{
			string s;
			cin >> s;
			for(int j=0;j<4;j++)
			{
				edge[(i+1)/2][j+1][0]=s[j]-'0';
				edge[(i+1)/2][j+2][2]=s[j]-'0';
			}
		}
		else
		{
			string s;
			cin >> s;
			for(int j=0;j<5;j++)
			{
				edge[i/2][j+1][1]=s[j]-'0';
				edge[i/2+1][j+1][3]=s[j]-'0';
			}
		}
	}
	while(1)
	{
		step();
		if(now.fi==1&&now.sec==1)
		{
			break;
		}
		ans.pb(angle);
	}
	for(int i=0;i<ans.size();i++)
	{
		output(ans[i]);
	}
	cout << endl;
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

typedef struct {
    int x, y;
    bool root[4];
} Node;

Node v[5][5];
const string ord = "URDL";
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};

void init() {
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < 5; j++) {
            v[i][j].x = i;
            v[i][j].y = j;
            for (int k = 0; k < 4; k++)
                v[i][j].root[k] = false;
        }
    }
}

void solve(int x, int y, char c) {
    cout << c;
    if (x == 0 && y == 0) {
        cout << '\n';
        return;
    }

    int start = (ord.find(c) + 3) % 4;
    for (int i = 0; i < 4; i++) {
        int ni = (i + start) % 4;
        if (v[x][y].root[ni]) {
            solve(x + dx[ni], y + dy[ni], ord[ni]);
            return;
        }
    }
}

int main() {
    init();

    for (int i = 0; i < 9; i++) {
        string input;
        cin >> input;

        for (int j = 0; j < input.size(); j++) {
            if (input[j] != '1') continue;
            
            if (i % 2) {
                v[(i + 1) / 2 - 1][j].root[2] = true;
                v[(i + 1) / 2][j].root[0] = true;
            } else {
                v[i / 2][j].root[1] = true;
                v[i / 2][j + 1].root[3] = true;
            }
        }
    }

    solve(0, 1, 'R');

    return 0;
}