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<bits/stdc++.h>
using namespace std;

int di[4] = {0, -1, 0, 1};
int dj[4] = {-1, 0, 1, 0};

void print(int c){
    if(c == 0) cout << "L";
    else if(c == 1) cout << "U";
    else if(c == 2) cout << "R";
    else cout << "D";
}

int main(){


    vector<vector<bool> > a(13, vector<bool> (13, true));
    for(int i = 0; i < 13; i++){
        a[i][0] = a[i][12] = false;
    }

    for(int j = 0; j < 13; j++){
        a[0][j] = a[12][j] = false;
    }

    for(int i = 0; i < 9; i++){

        if(i % 2 == 0){
            int h = i + 2;
            string s; cin >> s;
            for(int j = 0; j < 4; j++){
                int w = j * 2 + 3;
                if(s[j] == '1'){
                    a[h][w - 1] = false;
                    a[h][w] = false;
                    a[h][w + 1] = false;                    
                }
            }
        }else{
            int h = i + 2;
            string s; cin >> s;
            for(int j = 0; j < 5; j++){
                int w = j * 2 + 2;
                if(s[j] == '1'){
                    a[h - 1][w] = false;
                    a[h][w] = false;
                    a[h + 1][w] = false;                    
                }
            }
        }
    }

    /*for(int i = 0; i < 13; i++){
        for(int j = 0; j < 13; j++){
            cout << a[i][j];
        }
        cout << endl;
    }*/

    int s_k = 2;
    int s_i = 2;
    int s_j = 2;
    int k = 2;
    int i = 2;
    int j = 2;
    bool flag = false;
    while(1){

        if(flag && i == s_i && j == s_j) break;
        
        flag = true;
        for(int h = 0; h < 4; h++){

            int c = (k - 1 + 4 + h) % 4;
            if(a[i + di[c]][j + dj[c]] == 0 && a[i + 2*di[c]][j + 2*dj[c]] == 0){
                print(c);
                i = i + 2*di[c];
                j = j + 2*dj[c];
                k = c;
                break;
            }

        } 
    
    }
    cout << endl;
    
    return 0;
}

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

using namespace std;


int main(){

	while(1){
		char yoko[10][10];
		char tate[10][10];
		if(cin.eof())
			break;

		for(int i = 0; i < 5; i++){
			for(int j = 0; j < 4; j++){
				cin>>yoko[i][j];
			}
			for(int j = 0; j < 5; j++){
				cin>>tate[i][j];
			}
		}
		// 0,1,2,3ÅEAºA¶Aã
		int angle=0;
		int px,py;
		px=py=0;
		while(1){
			if(angle==0){
				if(px!=4&&yoko[py][px]=='1'){
					cout<<"R";
					px++;
				}
				else{
					// ãÖ
					if(py!=0&&tate[py-1][px]=='1'){
						py--;
						angle=3;
						cout<<"U";
					}
					// ºÉÇª êÎAºÖ
					else if(py!=4&&tate[py][px]=='1'){
						py++;
						angle=1;
						cout<<"D";
					}
					else{
						px--;
						angle=2;
						cout<<"L";
					}
				}
			}
			// º
			else if(angle==1){
				if(py!=4&&tate[py][px]=='1'){
					cout<<"D";
					py++;
				}
				else{
					// ºÉÇª³¯êÎA½]
					if(px!=4&&yoko[py][px]=='1'){
						cout<<"R";
						angle=0;
						px++;
					}
					else if(px!=0&&yoko[py][px-1]=='1'){
						cout<<"L";
						angle=2;
						px--;
					}
					else{
						py--;
						angle=3;
						cout<<"U";
					}
				}
			}
			// ¶
			else if(angle==2){
				if(px!=0&&yoko[py][px-1]=='1'){
					cout<<"L";
					px--;
				}
				else{
					// ºÉÇª êÎAºÖ
					if(py!=4&&tate[py][px]=='1'){
						py++;
						angle=1;
						cout<<"D";
					}
					// ãÖ
					else if(py!=0&&tate[py-1][px]=='1'){
						py--;
						angle=3;
						cout<<"U";
					}
					else{
						px++;
						angle=2;
						cout<<"R";
					}
				}
			}
			// ã
			else if(angle==3){
				if(py!=0&&tate[py-1][px]=='1'){
					cout<<"U";
					py--;
				}
				else{
					// ºÉÇª³¯êÎA½]
				if(px!=0&&yoko[py][px-1]=='1'){
					cout<<"L";
					angle=2;
					px--;
				}
				else if(px!=4&&yoko[py][px]=='1'){
					cout<<"R";
					angle=0;
					px++;
				}
				else{
					py++;
					angle=1;
					cout<<"D";
				}
				}
			}
			if(px==0&&py==0)
				break;
}
cout<<endl;
}

return 0;
}

C++: #include <iostream>

using namespace std;

enum Direction {R, L, U, D};

bool input(char b[][5])
{
	char dummy;
	for (int i=0; i<9; i++) {
		for (int j=0; j<5; j++) {
			if ((i&1)==0 && j==4) continue;
			if ( !(cin >> b[i][j]) ) return false;
		}
		//cin >> dummy;
	}
	return true;
}

int main()
{
	char board[9][5];
	input(board);
	
	pair<int, int> curr_pos = (board[1][0] == '1') ? pair<int,int>(1,0) : pair<int,int>(0,0);
	enum Direction curr_dir = (board[1][0] == '1') ? D : R;
	if (curr_dir == D) cout << D;
	else cout << R;
	
	do {
		switch (curr_dir) {
		case R:
			// priority : U > R > D
			if ( curr_pos.first > 0 && board[curr_pos.first-1][curr_pos.second+1] == '1' ) {
				curr_dir = U; cout << "U"; curr_pos.first--; curr_pos.second++;
			} else if ( curr_pos.second < 3 && board[curr_pos.first][curr_pos.second+1] == '1' ){
				curr_dir = R; cout << "R"; curr_pos.second++;
			} else {
				curr_dir = D; cout << "D"; curr_pos.first++; curr_pos.second++;
			} 
			break;
		case L:
			// priority : D > L > U
			if ( curr_pos.first < 8 && board[curr_pos.first+1][curr_pos.second] == '1' ) {
				curr_dir = D; cout << "D"; curr_pos.first++;
			} else if ( curr_pos.second > 0 && board[curr_pos.first][curr_pos.second-1] == '1' ) {
				curr_dir = L; cout << "L"; curr_pos.second--;
			} else {
				curr_dir = U; cout << "U"; curr_pos.first--;
			}
			break;
		case U:
			// priority : L > U > R
			if ( curr_pos.second > 0 && board[curr_pos.first-1][curr_pos.second-1] == '1' ) {
				curr_dir = L; cout << "L"; curr_pos.first--; curr_pos.second--;
			} else if ( curr_pos.first > 2 && board[curr_pos.first-2][curr_pos.second] == '1' ) {
				curr_dir = U; cout << "U"; curr_pos.first-=2;
			} else {
				curr_dir = R; cout << "R"; curr_pos.first--;
			}
			break;
		case D:
			// priority : R > D > L
			if ( board[curr_pos.first+1][curr_pos.second] == '1' ) {
				curr_dir = R; cout << "R"; curr_pos.first++;
			} else if ( curr_pos.first < 6 && board[curr_pos.first+2][curr_pos.second] == '1' ) {
				curr_dir = D; cout << "D"; curr_pos.first+=2;
			} else {
				curr_dir = L; cout << "L"; curr_pos.first++; curr_pos.second--;
			}
			break;
		}
	} while ( curr_pos.first != 0 || curr_pos.second != 0 );
	
	cout << endl;
	
	return 0;
}