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<string> 
#include<vector>
#include<iostream>
using namespace std;
bool map[20][20][4];
vector< string > maphor,mapver;
int xsize,ysize;
void init(){
	for(int i=0;i<20;i++){
		for(int j=0;j<20;j++){
			for(int k=0;k<4;k++){
				map[i][j][k]=0;
			}
		}
	}
}
void setmap(){
	for(int i=0;i<20;i++){
		for(int j=0;j<20;j++){
			if(-1<i&&i<maphor.size()&&-1<j&&j<maphor[0].size()){
				if(maphor[i][j]=='1'){
					map[i][j][0]=1;
				}
			}
			if(-1<i&&i<maphor.size()&&-1<j-1&&j-1<maphor[0].size()){
				if(maphor[i][j-1]=='1'){
					map[i][j][2]=1;
				}
			}
			if(-1<i&&i<mapver.size()&&-1<j&&j<mapver[0].size()){
				if(mapver[i][j]=='1'){
					map[i][j][3]=1;
				}
			}
			if(-1<i-1&&i-1<mapver.size()&&-1<j&&j<mapver[0].size()){
				if(mapver[i-1][j]=='1'){
					map[i][j][1]=1;
				}
			}
		}
	}
}

int solve(){
	int x=0,y=0;
	int v=0;
	string vec="RULD";
	int loop[4]={1,0,3,2};
	int vx[4]={1,0,-1,0};
	int vy[4]={0,-1,0,1};
	int count=0;
	while(1){
		count++;
		if(count>100)return -1;
		for(int i=0;i<5;i++){
			if(i==4)return -1;
			if(x==0
				&& y==0
				&&(((v+loop[i])%4)==2)){
				return 0;
			}
			if(map[y][x][(v+loop[i])%4]==1){
				v+=loop[i];
				v=v%4;
				x+=vx[v];
				y+=vy[v];
				cout<<vec[v];
				break;
			}
		}
	}
}

int main(){
	string tmp;
	for(int i=0;cin>>tmp;i++){
		if(i%2==0){
			maphor.push_back(tmp);
		}else{
			mapver.push_back(tmp);
		}
	}
	xsize=maphor[0].size()+1;
	ysize=mapver.size()+1;
	init();setmap();
	
	/*
	for(int i=0;i<xsize;i++){
		for(int j=0;j<ysize;j++){
			for(int k=0;k<4;k++){
				cout<<map[i][j][k];
			}
			cout<<" ";
		}
		cout<<endl;
	}
	*/
	if(solve()==-1)return -1;
	cout<<endl;
	
	return 0;
	
}

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

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

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

C++: #include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define sc(x) cin >> x
#define sc2(x, y) cin >> x >> y
#define sc3(x, y, z) cin >> x >> y >> z
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define debugn(i, n, a) rep(i, n)cout << " --- " << a[i] << "\n";
#define debugin(i, n, a) rep(i, n)printf(" --- %10d\n", a[i])
#define debugi2n(i, n, a, b) rep(i, n)printf(" --- %10d %10d\n", a[i], b[i])
#define debugiin(i, n, a) rep(i, n)printf(" --- %10d %10d\n", a[i].first, a[i].second)
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)



signed main(void){
  int i, j, k;
  int dx[4] = {0, 1, 0, -1};
  int dy[4] = {1, 0, -1, 0};
  string res = "RDLU";
  for(int testcase = 0;testcase < 1234567;testcase++){
    bool f[11][11] = {false};
    string s;
    sc(s);
    rep(i, 4){
      if(s[i] == '1')f[1][i * 2 + 2] = true;
      else f[1][i * 2 + 2] = false;
    }

    rep(i, 4){
      sc(s);
      rep(j, 5){
        if(s[j] == '1')f[i * 2 + 2][2 * j + 1] = true;
        else f[i * 2 + 2][2 * j + 1] = false;
      }
      sc(s);
      rep(j, 4){
        if(s[j] == '1')f[i * 2 + 3][2 * j + 2] = true;
        else f[i * 2 + 3][2 * j + 2] = false;
      }
    }
/*
    rep(i, 11){
      rep(j, 11){
        if(f[i][j])cout << "1";
        else cout << "0";
      }
      kara;
    }*/

    pair<i_i, int> now = mp(mp(0, 2), 0);

    for(int times = 50;times--;){
      if(f[now.X.X + dx[now.Y]][now.X.Y + dy[now.Y]]){
        cout << res[now.Y];
        now.Y = (now.Y + 3) % 4;
      }else{
        now.X.X += dx[now.Y] * 2;
        now.X.Y += dy[now.Y] * 2;
        cout << res[now.Y];
        for(int qwe = 4;qwe--;){
          if(!f[now.X.X + dx[(now.Y + 1) % 4]][now.X.Y + dy[(now.Y + 1) % 4]]){
            now.Y = (now.Y + 1) % 4;
            now.X.X += dx[now.Y] * 2;
            now.X.Y += dy[now.Y] * 2;
          }else break;
        }
      }
      if(now.X.X == 0 && now.X.Y == 2)break;
    }

    kara;

/*/

//*/ break;
  }
  return 0;
}