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++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
template<typename V> typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();

// clang-format on

main {
  vs t(9);
  rep(i, 9) cin >> t[i];
  int h = 5, w = t[1].size();
  vvi m(h, vi(w));
  rep(i, h) {
    int k = i * 2;
    rep(j, t[k].size()) {
      if (t[k][j] == '1') {
        m[i][j] += 0b10;
        m[i][j + 1] += 0b1000;
      }
    }
  }
  rep(i, h - 1) {
    int k = i * 2 + 1;
    rep(j, t[k].size()) {
      if (t[k][j] == '1') {
        m[i][j] += 0b100;
        m[i + 1][j] += 0b1;
      }
    }
  }
  rep(i, h) {
    rep(j, w) cerr << setw(3) << m[i][j];
    cerr << endl;
  }
  int x = 0, y = 0, p = 1, wa = 2;
  char c[] = {'U', 'R', 'D', 'L'};
  int dx[] = {0, 1, 0, -1};
  int dy[] = {-1, 0, 1, 0};
  do {
    // TODO: simulation (aka yarudake)
    // Sorry, but I have no time to implement it.
  } while (!(x == 0 && y == 0));
  cout << endl;
  return 0;
}

C++: #include <iostream>
using namespace std;
//R:0 L:1 U:2 D:3


int map[11][7], type, x=2, y=1;
char a[4], b[5];


void init(){
	for(int i=1; i<=9; i++){
		if(i%2){
			cin>>a;
			for(int n=0; n<4; n++)map[i][n+1] = char(a[n])-'0';
		}
		else {
			cin>>b;
			for(int m=0; m<5; m++)map[i][m+1] = char(b[m])-'0';
		}			
	}
}


void Right(){
	if(map[y-1][x])type=2, y-=2, cout<<'U';
	else if(map[y][x])type=0, x+=1, cout<<'R';
	else if(map[y+1][x])type=3, y+=2, cout<<'D';
	else  type=1, x-=1, cout<<'L';
}
void Left(){
	if(map[y+1][x])type=3, y+=2, cout<<'D';
	else if(map[y][x-1])type=1, x-=1, cout<<'L';
	else if(map[y-1][x])type=2, y-=2, cout<<'U';
	else type=0, x+=1, cout<<'R';
}
void Up(){
	if(map[y][x-1])type=1, x-=1, cout<<'L';
	else if(map[y-1][x])type=2, y-=2, cout<<'U';
	else if(map[y][x])type=0, x+=1, cout<<'R';
	else type=3, y+=2, cout<<'D';
}
void Down(){
	if(map[y][x])type=0, x+=1, cout<<'R';
	else if(map[y+1][x])type=3, y+=2, cout<<'D';
	else if(map[y][x-1])type=1, x-=1, cout<<'L';
	else type=2, y-=2, cout<<'U';
}


void solve(){
	while(!(x==1&&y==1)){
		switch(type){
			case 0: Right(); break;
			case 1: Left(); break;
			case 2: Up(); break;
			case 3: Down(); break;
			default: return;
		}
	}
}
 
int main(){
	init();
	
	cout<<'R';
	solve();
	cout<<"\n";	
    return 0;  
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int field[6][6][4] = {0},p[3];
	int x,y;
	for(int i=0; i<9; i++){
		if(i%2 == 0){
			for(int j=0; j<4; j++){
				int n;
				scanf("%1d",&n);
				field[j+1][i/2][2] = n;
				field[j+1][i/2+1][0] = n;
			}
		}
		else{
			for(int j=0; j<5; j++){
				int n;
				scanf("%1d",&n);
				field[j][i/2+1][1] = n;
				field[j+1][i/2+1][3] = n;
			}
		}
	}
	p[0] = 1;p[1] = 0; p[2] = 1;
	for(;;){
		if(p[2] == 0){
			if(field[p[0]][p[1]][1] == 1){
				cout<<"U";
				if(field[p[0]][p[1]][0] == 1){p[2] = 3;}
				else{p[1]--;}
			}
			else if(field[p[0]][p[1]][1] == 0){p[2] = 1;p[0]++;}
		}
		else if(p[2] == 1){
			if(field[p[0]][p[1]][2] == 1){
				cout<<"R";
				if(field[p[0]][p[1]][1] == 1){p[2] = 0;}
				else{p[0]++;}
			}
			else if(field[p[0]][p[1]][2] == 0){p[2] = 2;p[1]++;}
		}
		else if(p[2] == 2){
			if(field[p[0]][p[1]][3] == 1){
				cout<<"D";
				if(field[p[0]][p[1]][2] == 1){p[2] = 1;}
				else{p[1]++;}
			}
			else if(field[p[0]][p[1]][3] == 0){p[2] = 3;p[0]--;}
		}
		else if(p[2] == 3){
			if(field[p[0]][p[1]][0] == 1){
				cout<<"L";
				if(field[p[0]][p[1]][3] == 1){p[2] = 2;}
				else{p[0]--;}
			}
			else if(field[p[0]][p[1]][0] == 0){p[2] = 0;p[1]--;}
		}
		if(p[0] == 1 && p[1] == 0){cout <<endl;break;}
	}
}

C++: #include <cstdio>
#include <string>
#include <iostream>
using namespace std;

string str[100];
int len;
int fie[101][101];
int m;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
char s[4]={'R','D','L','U'};
int main(void){
	int n=0;
	while(cin >> str[n])n++;
	if(n>9){
		printf("0\n");
		return 0;
	}
	m=str[0].size();
	for(int i=0;i<n;i++){
		for(int j=0;j<str[i].size();j++){
			if(str[i][j]=='1'){
				if(i%2==0)fie[j*2+2][i+1]=1;
				if(i%2==1)fie[j*2+1][i+1]=1;
			}
		}
	}
	int x=2,y=0,dir=0;
	while(1){
		int nx=x+dx[(dir+1)%4],ny=y+dy[(dir+1)%4];
		if(nx>=0 && nx<=m*2+2 && ny>=0 && ny<=n+1){
			if(fie[nx][ny]==1)printf("%c",s[dir]);
		}
		nx=x+dx[dir],ny=y+dy[dir];
		if(nx>=0 && nx<=m*2+2 && ny>=0 && ny<=n+1){
			if(fie[nx][ny]==0){
				x+=dx[dir]*2;
				y+=dy[dir]*2;
				if(fie[x+dx[(dir+1)%4]][y+dy[(dir+1)%4]]==0){
					dir=(dir+1)%4;
				}
			}else{
				if(fie[x+dx[(dir+3)%4]][y+dy[(dir+3)%4]]==0){
					dir=(dir+3)%4;
					x+=dx[dir]*2;
					y+=dy[dir]*2;
					printf("%c",s[dir]);
				}else{
					dir=(dir+2)%4;
					x+=dx[dir]*2;
					y+=dy[dir]*2;
					printf("%c",s[(dir+1)%4]);
					printf("%c",s[dir]);
				}
			}
		}else dir=(dir+1)%4;
		//printf("%d %d %d %d %d\n",x,y,dir,dx[dir],dy[dir]);
		if(x==0 && y==0)break;
	}
	printf("\n");
	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

int maze[20][20];

char s[6];
char ans[100];
int sz=0;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

char sym[]="RDLU";

int main(){
  REP(i,9){
    scanf("%s",s);
    REP(j,strlen(s)){
      if (i%2==0){
	maze[i+1][2*j+2]=s[j]-'0';
      }else{
	maze[i+1][2*j+1]=s[j]-'0';
      }
    }
  }
  REP(i,11){
    REP(j,11){
      fprintf(stderr,"%d",maze[i][j]);
    }
    fprintf(stderr,"\n");
  }
  ans[0]='R';
  sz++;
  int x=3,y=1;
  int dir=0;
  while (x!=1 || y!=1){
    REP(i,4){
      int d=(dir+3+i)%4;
      if (maze[y+dy[d]][x+dx[d]]){
	dir=d;
	break;
      }
    }
    x+=dx[dir]*2;
    y+=dy[dir]*2;
    ans[sz++]=sym[dir];
  }
  printf("%s\n",ans);
  return 0;
}