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 <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <cstdio>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
string ans = "URDL";
bool f[5][5][5];

int main() {

    memset(f,0,sizeof(f));

    rep(i,9) {
        int y = i/2;
    
        if(i%2 == 0) {
            string t;
            cin >> t;
    
            rep(j,4) {
                if(t[j] == '1') {
                    f[y][j][1] = true;
                    f[y][j+1][3] = true;
                }
            }
        } else {
            string t;
            cin >> t;
    
            rep(j,5) {
                if(t[j] == '1') {
                    f[y+1][j][0] = true;
                    f[y][j][2] = true;
                }
            }
        }
    }

    int dy[4] = {-1,0,1,0};
    int dx[4] = {0,1,0,-1};
    string ans = "URDL";
    int y = 0, x = 0, dir = 1;

    do {
        if(f[y][x][(dir+3)%4]) {
            dir = (dir+3)%4;
        } else if(f[y][x][dir]) {

        } else if(f[y][x][(dir+1)%4]) {
            dir = (dir+1)%4;
        } else if(f[y][x][(dir+2)%4]) {
            dir = (dir+2)%4;
        }


        y += dy[dir];
        x += dx[dir];
        cout << ans[dir];
    } while(y != 0 || x != 0);
    cout << endl;

    return 0;
}

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

int main() {
  char w[9][9],e[5]="URDL";
  int x=0,y=0,h=1,i,g;
  int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
  for (i=0;i<9;i++) gets(w[i]);
  while(true) {
   h=(h+3) % 4;
   for (i=0;i<4;i++) {
	   if (y+dy[h]>=0 && y+dy[h]<=4 && x+dx[h]>=0 && x+dx[h]<=4) {
          if (dx[h]==-1) g=-1; else g=0;
		  if (w[2*y+dy[h]][x+g]=='1') break;
	   }
	   	  h=(h+1) % 4;
   }
   x+=dx[h]; y+=dy[h];
   cout << e[h];
   if (x==0 && y==0) break;
  }
  cout << endl;
  return 0;
}

C++: #include <iostream>
#include <istream>
#include <string>
#include <vector>
using namespace std;
int main() {
  vector<bool> w(11 * 11, false);
  for (int i = 1; i < 10; i++) {
    for (int j = 1 + i % 2; j < 10; j += 2) {
      char c;
      cin >> c;
      if (c - '0') w[i * 11 + j] = true;
    }
  }
  int x = 2, y = 0, d = 1, dy[] = {-1, 0, 1, 0}, dx[] = {0, 1, 0, -1};
  do {
    const string s = "URDL";
    d = (d + 1) % 4;
    while (w[(y + dy[d]) * 11 + x + dx[d]]) {
      cout << s[(d + 3) % 4];
      d = (d + 3) % 4;
    }
    y += dy[d] * 2;
    x += dx[d] * 2;
  }
  while (x || y);
  cout << endl;
}

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

const int N = 5;
const int di[] = {0,1,0,-1};
const int dj[] = {1,0,-1,0};
const char C[] = {'R','D','L','U'};
int g[N][N];
int main(void){
  fill(g[0],g[N],0);
  for(int s = 0 ; s < 2 * N - 1 ; s ++){
    for(int j = 0 ; j < N - 1 + s % 2 ; j ++){
      int i = s / 2;
      char a;
      cin>> a;
      if(a=='1'){
	if(s%2==0){
	  g[i][j] |= (1<<0);
	  g[i][j+1] |= (1<<2);
	} else{
	  g[i][j] |= (1<<1);
	  g[i+1][j] |= (1<<3); 
	}
      }
    }
  }

  int i,j,d;
  i = j = d = 0;
  do{
    for(int k = 0 ; k < 4 ; k ++){
      int nd = (d+3+k) % 4;
      if(g[i][j] & (1<<nd)){
	d = nd;
	i += di[d];
	j += dj[d];
	cout << C[d];
	break;
      }
    }
  }while(!(i==0 && j==0));
  cout<<endl;
  
}

C++: #include <bits/stdc++.h>
  
using namespace std;
  
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
const char d[4] = {'L', 'U', 'R', 'D'};
  
int main()
{
    char ch;
    bool G[6][6][4];
    memset(G, 0, sizeof(G));
    for (int i = 0; i < 9; i++) {
	int d = i%2;
	for (int j = 0; j < 4+d; j++) {
	    cin >> ch;
	    if (ch == '1') {
		if (d % 2) {
		    G[i/2+1][j][2] = G[i/2+1][j+1][0] = 1;
		} else {
		    G[i/2][j+1][3] = G[i/2+1][j+1][1] = 1;
		}
	    }
	}
    }
    int x = 1, y = 0, dir = 2;
    string ans;
    while(1){
	if (!x && !y) break;
	ans += d[dir];
	int rh = (dir+1) % 4;
	if (G[y][x][dir]) {
	    dir--;
	    dir = (dir == -1 ? 3 : dir);
	} else if (!G[y+dy[dir]][x+dx[dir]][rh]) {
	    x += dx[dir], y += dy[dir];
	    if (!x && !y) break;
	    x += dx[rh], y += dy[rh];
	    dir = rh;
	    int nrh = (rh+1) % 4;
	    if (!G[y][x][nrh] && !(!x && !y)) {
		x += dx[nrh], y += dy[nrh];
		dir = nrh;
	    }
	} else {
	    x += dx[dir]; y += dy[dir];
	}
    }
    cout << ans << endl;
    return 0;
}