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>
using namespace std;

enum eCOURSE{
	COURSE_U,
	COURSE_R,
	COURSE_D,
	COURSE_L,
};

struct tDataSet{
	int *pX, *pY, *field;
	eCOURSE* course;
};

const int SIZE_X = 7;
const int SIZE_Y = 11;

bool checkGoal( tDataSet& data ){
	if ( ( *data.pX == 0 && *data.pY == 1 && *data.course == COURSE_U && data.field[ 2*SIZE_X + 1 ] ) ||
		 ( *data.pX == 1 && *data.pY == 1 && *data.course == COURSE_L && data.field[ 1*SIZE_X + 1 ] && !data.field[ 2*SIZE_X + 1 ] ) ){
		return true;
	}
	return false;
}

int main(){
	string s;
	int field[ SIZE_Y * SIZE_X ];

	for ( int i = 0; i < SIZE_Y * SIZE_X; ++i ){
		field[ i ] = 0;
	}

	for ( int i = 1; i < SIZE_Y - 1; ++i ){
		cin >> s;
		for ( unsigned j = 0; j < s.size(); ++j ){
			field[ i*7 + (j+1) ] = static_cast< int >( s[ j ] - '0' );
		}
	}

	s = "";
	int pX = 1, pY = 0;
	eCOURSE course = COURSE_R;

	tDataSet data;
	data.pX = &pX;
	data.pY = &pY;
	data.course = &course;
	data.field = field;

	bool goal = false;

	while ( !goal ){
		int defU = ( 2 * pY ) * SIZE_X + ( pX + 1 );
		int defR = ( 2 * pY + 1 ) * SIZE_X + pX;
		int defD = ( 2 * pY ) * SIZE_X + pX;
		int defL = ( 2 * ( pY - 1 ) + 1 ) * SIZE_X + pX;

		switch ( course ){
			case COURSE_U : 
				if ( field[ defU ] ){
					s += 'U';
					goal = checkGoal( data );
					if ( field[ defL ] ){
						course = COURSE_L;
					}else{
						--pY;
					}
				}else{
					course = COURSE_R;
					++pX;
				}
				break;
			case COURSE_R :
				if ( field[ defR ] ){
					s += 'R';
					goal = checkGoal( data );
					if ( field[ defU ] ){
						course = COURSE_U;
					}else{
						++pX;
					}
				}else{
					course = COURSE_D;
					++pY;
				}
				break;
			case COURSE_D :
				if ( field[ defD ] ){
					s += 'D';
					goal = checkGoal( data );
					if ( field[ defR ] ){
						course = COURSE_R;
					}else{
						++pY;
					}
				}else{
					course = COURSE_L;
					--pX;
				}
				break;
			case COURSE_L :
				if ( field[ defL ] ){
					s += 'L';
					goal = checkGoal( data );
					if ( field[ defD ] ){
						course = COURSE_D;
					}else{
						--pX;
					}
				}else{
					course = COURSE_U;
					--pY;
				}
				break;
			
		}
	}

	cout << s << endl;

	return 0;
}

C++: #include <iostream>
#include <string>

using namespace std;

int d;
int x, y;
bool data[9][5];

main(){
  for(int i=0;i<9;i++){
    for(int j=0;j<5;j++){
      data[i][j]=false;
    }
  }
  for(int i=0;i<9;i++){
    for(int j=0;j<=5;j++){
      char c;
      scanf("%c", &c);
      if(c=='\n') break;
      if(c=='1') data[i][j]=true;
    }
  }
  
  x=0;
  y=0;
  d=0;
  for(int i=0;;i++, d++){
    //    printf("(%d,%d,%d)\n", x, y, d);
    if(d==4) d=0;
    if(d==0){
      if(y==0) continue;
      if(data[2*(y-1)+1][x]){
	cout << 'U';
	y--;
	d=2;
      }
    }else if(d==1){
      if(x==4) continue;
      if(data[2*y][x]){
	cout << 'R';
	x++;
	d=-1;
      }
    }else if(d==2){
      if(y==4) continue;
      if(data[2*y+1][x]){
	cout << 'D';
	y++;
	d=0;
      }
    }else if(d==3){
      if(x==0) continue;
      if(data[2*y][x-1]){
	cout << 'L';
	x--;
	d=1;
      }
    }
    if(y==0 && x==0) break;
  }
  cout << endl;
  return 0;
}

C++: #include<stdio.h>//////////AOJ0037
                               int
i,j,w[5][5];char*p,b[1<<7];;   int
F(int(v)){scanf("%s",b);for(   p=b
;*p;++p                 ){w[   p-b
+1-v][j   +v]|=((w[p-   b][j   ]|=
(*p==49   )<<3-v)&8>>   v)>>   2;}
return(   j+=v          );/*   */}
main(){   for(   ;4-F   (0);   F(1
));for(   p=b,   i=j=   (*b=   3)^
3;i+=""   "BA"          "BC"   [*b
]-66,j=   (*b)["ABCB"]-66+j,   *++
p="ULDR   "[*b],i+j;)for((*    b+=
1)&=~4;                        !(w
[i][j]&(1<<*b));(*b+=3)&=3);return
!puts(b+1);}///////05-2018,@siikya

C++: #include <bits/stdc++.h>
using namespace std;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const char ch[] = {"ULDR"};

bool g[10][10][10][10];

int main()
{
	char c;
	
	for (int i = 1; i <= 5; i++){
		for (int j = 1; j <= 4; j++){
			scanf(" %c", &c);
			if (c == '0') continue;
			g[i][j][i][j + 1] = true;
			g[i][j + 1][i][j] = true;
		}
		if (i == 5) continue;
		for (int j = 1; j <= 5; j++){
			scanf(" %c", &c);
			if (c == '0') continue;
			g[i][j][i + 1][j] = true;
			g[i + 1][j][i][j] = true;
		}
	}
	
	int dir = 3;
	int x = 1, y = 2;
	while (true){
		printf("%c", ch[dir]);
		if (x == 1 && y == 1) break;
		for (int t = 1; t >= -2; t--){
			int nd = (dir + t + 4) % 4;
			int nx = x + dx[nd];
			int ny = y + dy[nd];
			if (g[x][y][nx][ny]){
				x = nx;
				y = ny;
				dir = nd;
				break;
			}
		}
	}
	puts("");
	return 0;
}