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<string>
#include<deque>
using namespace std;
#define MAX_MAP 10

deque<string> map;

int y=0,x=-1,vec=0;
string v="RULD";
int dvx[4]={1,0,-1,0};
int dvy[4]={0,-1,0,1};

bool wall_front(){
	switch(vec){
	case 0:
		if(map[y*2+1][(x+2)+1]=='1'){
			return true;
		}else{
			return false;
		}
	case 1:
		if(map[y*2][(x+2)]=='1'){
			return true;
		}else{
			return false;
		}
	case 2:
		//cout<<map[y*2+1]<<" "<<(x+2)<<endl;
		if(map[y*2+1][(x+2)]=='1'){
			return true;
		}else{
			return false;
		}
	case 3:
		if(map[y*2+2][(x+2)]=='1'){
			return true;
		}else{
			return false;
		}
	}
}

bool wall_straight(){
	switch(vec){
	case 0:
		if(map[y*2+2][(x+2)+1]=='1'){
			return true;
		}else{
			return false;
		}
	case 1:
		if(map[y*2-1][(x+2)+1]=='1'){
			return true;
		}else{
			return false;
		}
	case 2:
		if(map[y*2][(x+2)-1]=='1'){
			return true;
		}else{
			return false;
		}
	case 3:
		if(map[y*2+3][(x+2)]=='1'){
			return true;
		}else{
			return false;
		}
	}
}

bool wall_rightAngle(){
	switch(vec){
	case 0:
		if(map[(y*2+1)+2][(x+2)+1]=='1'){
			return true;
		}else{
			return false;
		}
	case 1:
		if(map[(y*2+1)-1][(x+2)+1]=='1'){
			return true;
		}else{
			return false;
		}
	case 2:
		if(map[(y*2)-1][(x+2)]=='1'){
			return true;
		}else{
			return false;
		}
	case 3:
		if(map[(y*2+1)+1][(x+2)-1]=='1'){
			return true;
		}else{
			return false;
		}
	}
}



void go_straight(){
	y+=dvy[vec];
	x+=dvx[vec];
	//cout<<"move now_pos="<<y<<" "<<x<<" "<<v[vec]<<endl;
}
void go_straight_move(){
	y+=dvy[vec];
	x+=dvx[vec];
	//cout<<"move now_pos="<<y<<" "<<x<<" "<<v[vec]<<endl;
}

void solve(){
	int count=0;
	while(y!=1||x!=-1){
		if(count>100)break;
		//cout<<y<<" "<<x<<" "<<v[vec]<<endl;
		if(wall_front()){
			//cout<<"front"<<endl;
			vec++;
			vec=vec%4;
			cout<<v[vec];
		}else if(wall_straight()){
			//cout<<"straight"<<endl;
			go_straight();
			cout<<v[vec];
		}else if(wall_rightAngle()){
			//cout<<"right"<<endl;
			go_straight_move();
			if(y==1&&x==-1){
				return;
			}
			vec+=3;
			vec=vec%4;
			go_straight();
			cout<<v[vec];
		}else{
			//cout<<"turn"<<endl;
			go_straight();
			if(y==1&&x==-1){
				return;
			}
			cout<<v[vec];
			vec+=3;
			vec=vec%4;
			go_straight_move();
			if(y==1&&x==-1){
				return;
			}
			vec+=3;
			vec=vec%4;
			go_straight();
			cout<<v[vec];
		}
		count++;
	}
}


int main(){
	string s;
	while(cin.eof()!=true){
		cin>>s;
		s="00"+s+"00";
		map.push_back(s);
	}
	map.push_front("000000000000000000000");
	map.push_front("000000000000000000000");
	map.push_back("000000000000000000000");
	map.push_back("000000000000000000000");
	/*
	for(int i=0;i<map.size();i++){
		cout<<map[i]<<endl;
	}*/
	solve();
	cout<<endl;
	return 0;
}

C++: #include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
using namespace std;


int main(){
	char w1[7][7],w2[7][7],dir;
	int x=1,y=1;
	for(int i=0;i<7;i++){
		for(int j=0;j<7;j++){
			w1[i][j] = '0';
			w2[i][j] = '0';
		}
	}
	fgets(w1[1],7,stdin);
	fgets(w2[1],7,stdin);
	fgets(w1[2],7,stdin);
	fgets(w2[2],7,stdin);
	fgets(w1[3],7,stdin);
	fgets(w2[3],7,stdin);
	fgets(w1[4],7,stdin);
	fgets(w2[4],7,stdin);
	fgets(w1[5],7,stdin);
	
	for(int i=5;i>=0;i--){
		w1[1][i+1]=w1[1][i];
		w2[1][i+1]=w2[1][i];
		w1[2][i+1]=w1[2][i];
		w2[2][i+1]=w2[2][i];
		w1[3][i+1]=w1[3][i];
		w2[3][i+1]=w2[3][i];
		w1[4][i+1]=w1[4][i];
		w2[4][i+1]=w2[4][i];
		w1[5][i+1]=w1[5][i];
	}
	w1[1][0]='0';
	w2[1][0]='0';
	w1[2][0]='0';
	w2[2][0]='0';
	w1[3][0]='0';
	w2[3][0]='0';
	w1[4][0]='0';
	w2[4][0]='0';
	w1[5][0]='0';/*
	for(int i=0;i<7;i++){
		for(int j=0;j<7;j++){
			if(w1[i][j]=='1') printf("+-");
			else printf("+ ");
		}
		printf("+\n");
		for(int j=0;j<7;j++){
			if(w2[i][j]=='1') printf("| ");
			else printf("  ");
		}
		
		printf("\n");
	}*/
	printf("R");
	dir = 'R';
	while(1){
		if(dir=='R'){
			if(w2[x-1][y+1]=='1'){
				dir = 'U';
				x = x-1;
				y = y+1;
			}
			else if(w1[x][y+1]=='1'){
				dir = 'R';
				x = x;
				y = y+1;
			}
			else if(w2[x][y+1]=='1'){
				dir = 'D';
				x = x;
				y = y+1;
			}
			else {
				dir = 'L';
				x = x;
				y = y;
			}
		}
		else if(dir=='L'){
			if(w2[x][y]=='1'){
				dir = 'D';
				x = x;
				y = y;
			}
			else if(w1[x][y-1]=='1'){
				dir = 'L';
				x = x;
				y = y-1;
			}
			else if(w2[x-1][y]=='1'){
				dir = 'U';
				x = x-1;
				y = y;
			}
			else {
				dir = 'R';
				x = x;
				y = y;
			}
		}
		else if(dir=='U'){
			if(w1[x][y-1]=='1'){
				dir = 'L';
				x = x;
				y = y-1;
			}
			else if(w2[x-1][y]=='1'){
				dir = 'U';
				x = x-1;
				y = y;
			}
			else if(w1[x][y]=='1'){
				dir = 'R';
				x = x;
				y = y;
			}
			else {
				dir = 'D';
				x = x;
				y = y;
			}
		}
		
		else if(dir=='D'){
			if(w1[x+1][y]=='1'){
				dir = 'R';
				x = x+1;
				y = y;
			}
			else if(w2[x+1][y]=='1'){
				dir = 'D';
				x = x+1;
				y = y;
			}
			else if(w1[x+1][y-1]=='1'){
				dir = 'L';
				x = x+1;
				y = y-1;
			}
			else {
				dir = 'U';
				x = x;
				y = y;
			}
		}
		printf("%c",dir);
		if(x==1&&y==1)break;
	}
	printf("\n");
	return 0;
}

C++: #include<iostream>
using namespace std;
string s[9];
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
int r;
bool in(int a)
{
	return 0<=a&&a<=4;
}
bool check(int a,int b,int c,int d)
{
	if(!(in(a)&&in(b)&&in(c)&&in(d)))return false;
	if(a==c)
	{
		return s[2*a][b<d?b:d]=='1';
	}
	else
	{
		return s[2*(a<c?a:c)+1][b]=='1';
	}
}
main()
{
	for(int i=0;i<9;i++)cin>>s[i];
	int x=0,y=0;
	while(1)
	{
		for(int dr=3;dr<7;dr++)
		{
			int nr=(r+dr)%4;
			int tx=x+dx[nr],ty=y+dy[nr];
			if(check(x,y,tx,ty))
			{
				r=nr;
				x=tx;
				y=ty;
				break;
			}
		}
		cout<<"RDLU"[r];
		if(x==0&&y==0)break;
	}
	cout<<endl;
}