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;

int main(int argc, char *argv[]) {
  int vwall[5][6] = {0}, hwall[5][6] = {0};
  string tmp;
  for (int i = 0; i < 9; i++) {
    cin >> tmp;
    if (i % 2 == 0)
      for (int j = 0; j < 4; j++)
        hwall[i/2][j+1] = tmp[j]-'0';
    else
      for (int j = 0; j < 5; j++)
        vwall[j][i/2+1] = tmp[j]-'0';
  }

  string str = "";
  enum Compass {N = 0, E, W, S};
  enum Compass compass = E;
  int x = 0, y = 0;
  while (true) {
    if (compass == E)
      if (vwall[x][y]) {
        compass = N;
        str += 'U';
        y--;
      } else if (hwall[y][x+1]) {
        x++;
        str += 'R';
      } else if (vwall[x][y+1]) {
        compass = S;
        str += 'D';
        y++;
      } else {
        compass = W;
      }
    else if (compass == W)
      if (vwall[x][y+1]) {
        compass = S;
        str += 'D';
        y++;
      } else if (hwall[y][x]) {
        x--;
        str += 'L';
      } else if (vwall[x][y]) {
        compass = N;
        str += 'U';
        y--;
      } else {
        compass = E;
      }
    else if (compass == N)
      if (hwall[y][x]) {
        compass = W;
        str += 'L';
        x--;
      } else if (vwall[x][y]) {
        y--;
        str += 'U';
      } else if (hwall[y][x+1]) {
        compass = E;
        str += 'R';
        x++;
      } else {
        compass = S;
      }
    else if (compass == S)
      if (hwall[y][x+1]) {
        compass = E;
        str += 'R';
        x++;
      } else if (vwall[x][y+1]) {
        y++;
        str += 'D';
      } else if (hwall[y][x]) {
        compass = W;
        str += 'L';
        x--;
      } else {
        compass = N;
      }
    if (x == 0 && y == 0) {
      cout << str << endl;
      break;
    }
  }
  return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int field[6][6] = {0},a,x = 1,y = 0,t = 2;
  for(int i=0; i<5; i++){
    for(int j=0; j<4; j++){
      scanf("%1d",&a);
      field[j+1][i]+=(a<<2);
      field[j+1][i+1]+=(a<<0);
    }
    if(i<4){
      for(int j=0; j<5; j++){
	scanf("%1d",&a);
	field[j][i+1]+=(a<<1);
	field[j+1][i+1]+=(a<<3);
      }
    }
  }
  for(;;){
    if(t == 0){
      if(field[x][y]&1){
	cout <<"U";
	if(field[x][y]&1){t = 3;}
	else{y--;}
      }
      else{x++;t = 1;}
    }
    else if(t == 1){
      if(field[x][y]&2){
	cout <<"R";
	if(field[x][y]&2){t = 0;}
	else{x++;}
      }
      else{y++;t = 2;}
    }
    else if(t == 2){
      if(field[x][y]&3){
	cout <<"D";
	if(field[x][y]&3){t = 1;}
	else{y++;}
      }
      else{x--;t = 3;}
    }
    else if(t == 3){
      if(field[x][y]&0){
	cout <<"L";
	if(field[x][y]&0){t = 2;}
	else{x--;}
      }
      else{y--;t = 0;}
    }
    if(!x && !y){break;}
  }
  cout <<endl;
  return 0;
}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    vector<vector<vector<bool> > > wall(5, vector<vector<bool> >(5, vector<bool>(4, false)));

    for(int i=0; i<5; ++i){
        for(int j=0; j<4; ++j){
            char a;
            cin >> a;
            if(a == '1')
                wall[i][j][0] = wall[i][j+1][2] = true;
        }
        if(i < 4){
            for(int j=0; j<5; ++j){
                char a;
                cin >> a;
                if(a == '1')
                    wall[i][j][1] = wall[i+1][j][3] = true;
            }
        }
    }

    char dir[] = {'R', 'D', 'L', 'U'};
    int dy[] = {0, 1, 0, -1};
    int dx[] = {1, 0, -1, 0};

    int y = 0;
    int x = 0;
    int d = 0;
    do{
        if(wall[y][x][d]){
            y += dy[d];
            x += dx[d];
            cout << dir[d];
            d += 3;
            d %= 4;
        }else{
            ++ d;
            d %= 4;
        }
    }while(y != 0 || x != 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() {
	int 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 <bits/stdc++.h>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

string wall[9];

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

inline int iswall(int cx,int cy,int d){
	switch(d){
		case 0:
			cy=2*cy;
			cx=cx;
			break;
		case 1:
			cy=2*cy+1;
			cx=cx;
			break;
		case 2:
			cy=2*cy;
			cx=cx-1;
			break;
		case 3:
			cy=2*cy-1;
			cx=cx;
			break;
	}
	if(cy<0||9<=cy||cx<0||5<=cx) return 0;
	return wall[cy][cx]=='1';
}

int main(void){
	rep(i,9){
		cin >> wall[i];
		if(wall[i].size()==4) wall[i]+="0";
	}
	cout << 'R';
	int cx=1,cy=0,cd=0;
	map<int,char> dir;
	dir[0]='R',dir[1]='D',dir[2]='L',dir[3]='U';
	while(1){
		rep(i,4){
			int nd=(cd+i+3)%4;
			if(iswall(cx,cy,nd)){
				cout << dir[nd];
				cy+=dy[nd],cx+=dx[nd],cd=nd;
				break;
			}
		}
		if(cx==0&&cy==0) break;
	}
	cout << endl;
	return 0;
}