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 <cstdlib>

using namespace std;

const static int SIZE = 11;
const static int H_LEN = 4;
const static int V_LEN = 5;
int main() {
  int field [ SIZE  ][ SIZE ] = { 0 };
  for( int i = 0; i < SIZE; i++ ) {
    if( i == 0 || i == SIZE - 1 ) { continue; }
    string line;
    cin >> line;
    if( i % 2 ) {
      for( int j = 0; j < H_LEN; j++ ) {
        field[ i ][ 2 + j * 2 ] = line[ j ] - '0';
      }
    } else {
      for( int j = 0; j < V_LEN; j++ ) {
        field[ i ][ 1 + j * 2 ] = line[ j ] - '0';
      }
 
    }
  }
/*
  for( int i = 0; i < SIZE; i++ ) {
    for( int j = 0; j < SIZE; j++ ) {
      if( i % 2 ) {
        cout << ( field[ i ][ j ] ? string("-") : string(".") ) << " " << flush;
      } else {
        cout << ( field[ i ][ j ] ? string("|") : string(".") ) << " " << flush;
      }
    }
    cout << endl;
  }
*/
  int counter = 0;
  int dir = 0;
  int x = 1, y = 1;
  int vx[ 4 ] = { 2, 0, -2, 0 };
  int vy[ 4 ] = { 0, 2, 0, -2 };
  int ax[ 4 ] = { 2, 1, -2, -1 };
  int ay[ 4 ] = { -1, 2, 1, -2 };
  int bx[ 4 ] = { 3, 0, -3, 0 };
  int by[ 4 ] = { 0, 3, 0, -3 };
  int cx[ 4 ] = { 2, -1, -2, 1 };
  int cy[ 4 ] = { 1, 2, -1, -2 };
  do {
    if( field[ y + ay[ dir ] ][ x + ax[ dir ] ] ) {
      x += vx[ dir ];
      y += vy[ dir ];
      cout << (
        dir == 0 ? "R" :
        dir == 1 ? "D" :
        dir == 2 ? "L" : "U"
      ) << flush;
      dir = ( dir - 1 + 4 ) % 4;
    } else if( field[ y + by[ dir ] ][ x + bx[ dir ] ] ) {
      x += vx[ dir ];
      y += vy[ dir ];
      cout << (
        dir == 0 ? "R" :
        dir == 1 ? "D" :
        dir == 2 ? "L" : "U"
      ) << flush;
    } else if( field[ y + cy[ dir ] ][ x + cx[ dir ] ] ) {
      x += vx[ dir ];
      y += vy[ dir ];
      cout << (
        dir == 0 ? "R" :
        dir == 1 ? "D" :
        dir == 2 ? "L" : "U"
      ) << flush;
      dir = ( dir + 1 ) % 4;
    } else {
      x += vx[ dir ];
      y += vy[ dir ];
       cout << (
        dir == 0 ? "R" :
        dir == 1 ? "D" :
        dir == 2 ? "L" : "U"
      ) << flush;
      dir = ( dir + 2 ) % 4;
    }
  } while( x != 1 || y != 1 );
  cout << endl;
  return EXIT_SUCCESS;
}

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

#define MAX 10

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

bool wall[4][MAX][MAX];

void print(int d) {
  switch(d) {
  case 0: cout<<"L"; break;
  case 1: cout<<"U"; break;
  case 2: cout<<"R"; break;
  case 3: cout<<"D"; break;
  }
}

int main() {
  
  char ch;
  for(int i=0; i<5; i++) {
    for(int j=0; j<4; j++) {
      cin >> ch;
      wall[3][i][j+1] = wall[1][i+1][j+1] = 1;
    }
    if(i<4) {
      for(int j=0; j<5; j++) {
	cin >> ch;
	wall[2][i+1][j] = wall[0][i+1][j+1] = 1;
      }
    }
  }
  
  bool start = 0;
  int x = 1, y = 0;
  int d = 2;
  while( !(x == 1 && y == 0 && start) ) {
    start = 1;
    
    x += dx[d], y += dy[d]; print(d);
    
    if(!wall[d][y][x]) {
      d = (d + 1) % 4;
      x += dx[d], y += dy[d]; print(d);
    }
  }
  cout << endl;
  
  return 0;
}