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>
using namespace std;
struct block{
  bool right;
  bool down;
  bool left;
  bool up;
  block():right(false),down(false),left(false),up(false){}
};
void ud(block* b,string& s,int row){
  for(int i=0;i<4;i++){
    if(s[i]=='1'){
      b[row*6+i+1].down=true;
      b[(row+1)*6+i+1].up=true;
    }
  }
}
void lr(block* b,string& s,int row){
  for(int i=0;i<5;i++){
    if(s[i]=='1'){
      b[row*6+i].right=true;
      b[row*6+i+1].left=true;
    }
  }
}
enum direction{UP,RIGHT,DOWN,LEFT};

int main(){
  block b[36]{};
  int p=1;
  direction d=direction::RIGHT;
  string s;
  cin>>s; ud(b,s,0);
  cin>>s; lr(b,s,1);
  cin>>s; ud(b,s,1);
  cin>>s; lr(b,s,2);
  cin>>s; ud(b,s,2);
  cin>>s; lr(b,s,3);
  cin>>s; ud(b,s,3);
  cin>>s; lr(b,s,4);
  cin>>s; ud(b,s,4);
  do{
    switch(d){
    case direction::UP:
      cout<<"U";
      if(b[p].up){
	d=direction::LEFT;
      }else{
	p-=6;
	if(!b[p].right){
	  p+=1;
	  d=direction::RIGHT;
	  if(!b[p].down){
	    p+=6;
	    d=direction::DOWN;
	  }
	}
      }
      break;
    case direction::RIGHT:
      cout<<"R";
      if(b[p].right){
	d=direction::UP;
      }else{
	p+=1;
	if(!b[p].down){
	  p+=6;
	  d=direction::DOWN;
	  if(!b[p].left){
	    p-=1;
	    d=direction::LEFT;
	  }
	}
      }
      break;
    case direction::DOWN:
      cout<<"D";
      if(b[p].down){
	d=direction::RIGHT;
      }else{
	p+=6;
	if(!b[p].left){
	  p-=1;
	  d=direction::LEFT;
	  if(!b[p].up){
	    p-=6;
	    d=direction::UP;
	  }
	}
      }
      break;
    case direction::LEFT:
      cout<<"L";
      if(b[p].left){
	d=direction::DOWN;
      }else{
	p-=1;
	if(!b[p].up){
	  p-=6;
	  d=direction::UP;
	  if(!b[p].right){
	    p+=1;
	    d=direction::RIGHT;
	  }
	}
      }
      break;
    }
  }while(p!=1);
  cout<<"\n";
}

C++: #include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const char *dat = "RDLU";

int w[6][6][4];

int main() {
    rep (i, 9) {
        char t;
        if (i % 2 == 0) {
            rep (j, 4) {
                scanf(" %c", &t);
                if (t == '1') w[i/2][j][0] = w[i/2][j+1][2] = 1;
            }
        }
        else {
            rep (j, 5) {
                scanf(" %c", &t);
                if (t == '1') w[i/2][j][1] = w[i/2+1][j][3] = 1;
            }
        }
    }
    int x = 0, y = 0, d = 0;
    do {
        rep (i, 4) {
            const int nd = (d+i) % 4;
            if (w[y][x][nd]) {
                putchar(dat[nd]);
                x += dx[nd];
                y += dy[nd];
                d = (nd + 3) % 4;
                break;
            }
        }
    } while (x != 0 || y != 0);
    putchar('\n');
    return 0;
}

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

using namespace std;

int xdir[4] = {0, 1, 0, -1}, ydir[4] = {-1, 0, 1, 0};
char dir[4] = {'U', 'R', 'D', 'L'};

int main()
{
  int l, x, y, d;
  string str;
  bool a[11][11][11][11];

  while(cin>>str){
    l = str.size()+1;
    y = 1;
    fill(&a[0][0][0][0], &a[l+1][0][0][0], false);

    for(int i = 1; i < l; ++i)
      if(str[i-1] == '1')
	a[0][i-1][0][i] = a[0][i][0][i-1] = true;

    for(int i = 1; i <= 8; ++i){
      cin >> str;
      if(i%2){
	for(int j = 0; j < l; ++j)
	  if(str[j] == '1') 
	    a[y-1][j][y][j] = a[y][j][y-1][j] = true;
      } else {
	for(int j = 1; j < l; ++j)
	  if(str[j-1] == '1')
	    a[y][j-1][y][j] = a[y][j][y][j-1] = true;
	y++;
      }
    }

    x = y = d = 0;
    do {
      for(int i = 3; i < 7; ++i){
	int nd = (d+i)%4;
	int dx = x+xdir[nd], dy = y+ydir[nd];
	
	if(0 <= dx && dx < l && 0 <= dy && dy < l && a[y][x][dy][dx]){
	  cout << dir[(d+i)%4];
	  a[y][x][dy][dx] = false;
	  x = dx;
	  y = dy;
	  d = nd;
	  break;
	}
      }
    } while(x+y != 0);
    
    cout << endl;
  }

  return 0;
}

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

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
char dc[] = "RDLU";

int main() {
	bool g[11][11];
	char c;
	for (int i=1; i<10; ++i) {
		for (int j=1+i%2; j<=9; j+=2) {
			cin >> c;
			g[i][j] |= c - '0';
		}
	}
	int x=1, y=1, d=0;
	do {
		for (int t=d+3; ; ++t) {
			if (g[y + dy[t%4]][x + dx[t%4]]) {
				d = t%4;
				break;
			}
		}
		x += dx[d] * 2;
		y += dy[d] * 2;
		cout << dc[d];
	} while (x != 1 || y != 1);
	cout << endl;
	return 0;
}

C++: #include<iostream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
const int N=6;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
const string op="RDLU";
enum{RIGHT=0,DOWN,LEFT,UP};
int m[N][N];
bool e[N][N][N];


string solve(){
  int y=0,x=1,r=RIGHT;
  string ret="";
  do{
    bool a=true;
    if (!e[y][x][(r+1)%4])r=(r+1)%4;
    while(e[y][x][r])ret+=op[r],r=(r+3)%4;
    if (e[y][x][(r+1)%4])ret+=op[r];
    y+=dy[r];
    x+=dx[r];
  }while(y != 0 || x != 1);
  return ret;
}

main(){
  rep(i,N)rep(j,N)rep(k,4)e[i][j][k]=false;
  rep(i,5){
    string tmp;
    cin>>tmp;
    rep(j,4)if (tmp[j] == '1')e[i][j+1][DOWN]=e[i+1][j+1][UP]=true;
    if (i == 4)break;
    cin>>tmp;
    rep(j,5)if (tmp[j] == '1')e[i+1][j][RIGHT]=e[i+1][j+1][LEFT]=true;
  }
  cout << solve() << endl;
}