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


using namespace std;



int main()
{
	bool points[5][5][4];
	for (int i = 0; i < 5; ++i)
		for (int j = 0; j < 5; ++j)
			for (int k = 0; k < 4; ++k)
				points[i][j][k] = false;

	for (int i = 0; i < 9; ++i)
	{
		int y = i/2;
		if (i%2 == 0)
		{
			for (int j = 0; j < 4; ++j)
			{
				int e;
				scanf("%1d", &e);
				if (e)
					points[y][j][1] = points[y][j+1][3] = true;
			}
		}
		else
		{
			for (int j = 0; j < 5; ++j)
			{
				int e;
				scanf("%1d", &e);
				if (e)
					points[y][j][2] = points[y+1][j][0] = true;
			}
		}
	}

	int x, y;
	x = 1;
	y = 0;
	int dir = 1;
	int dx[] = { 0, 1, 0, -1 };
	int dy[] = { -1, 0, 1, 0 };
	char* ds = "URDL";
	putchar(ds[dir]);
	while (!(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];
		putchar(ds[dir]);
	}
	putchar('\n');

	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
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) {
        if (i % 2 == 1) {
            for (int j=2; j<=8; j+=2) {
                cin >> c;
                g[i][j] = c - '0';
                g[i][j-1] |= g[i][j];
                g[i][j+1] |= g[i][j];
            }
        } else {
            for (int j=1; j<=9; j+=2) {
                cin >> c;
                g[i][j] = c - '0';
                g[i-1][j] |= g[i][j];
                g[i+1][j] |= g[i][j];
            }
        }
    }
    int x = 1, y = 1, d = 0;
    do {
        for (int t=3; t<=6; ++t) {
            if (g[y + dy[(d + t) % 4]][x + dx[(d + t) % 4]]) {
                d = (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>
#include <string>
using namespace std;

string s[9];
int x,y,t;

bool R()
{
	if(x < 4 && s[y][x] == '1'){
		cout << 'R'; t = 0;
		x++; return true;
	}
	return false;
}

bool L()
{
	if(0 < x && s[y][x-1] == '1'){
		cout << 'L'; t = 2;
		x--; return true;
	}
	return false;
}

bool U()
{
	if(1 < y && s[y-1][x] == '1'){
		cout << 'U'; t = 3;
		y -= 2; return true;
	}
	return false;
}

bool D()
{
	if(y < 7 && s[y+1][x] == '1'){
		cout << 'D'; t = 1;
		y += 2; return true;
	}
	return false;
}

int main()
{
	bool (*move[])() = {U,R,D,L};
	for(int i = 0; i < 9; ++i){
		cin >> s[i];
	}
	cout << 'R'; x = 1;
	while(!(x == 0 &&y == 0)){
		for(int i =0; i < 4; ++i){
			if(move[(t+i)%4]())break;
		}
	}
	cout << endl;
}

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

char const * direct_text[] = {"R", "D", "L", "U"};

bool can_move(int a[10][6], int x, int y, int d)
{
    if ( (d == 0 && a[2*x-1][y  ] == 1) ||
         (d == 1 && a[2*x  ][y  ] == 1) ||
         (d == 2 && a[2*x-1][y-1] == 1) ||
         (d == 3 && a[2*x-2][y  ] == 1) )
        return 1;
    else 
        return 0;
}

int main(void) {
    int a[10][6] = {{}};
    char c;

    for (int i = 1; i <= 9; ++i)
        for (int j = 1; j <= 5; ++j)
            if (j <= 4 || i%2==0) {
                cin >> c;
                a[i][j] = c - '0';
            }

    int x = 1, y = 1, d = 0;

    while (true) {
        for (int i = 0; i < 4; ++i) {
            if (can_move(a, x, y, (d+3+i)%4)) {
                d = (d+3+i)%4;
                if (d == 0)
                    y += 1;
                else if (d == 1)
                    x += 1;
                else if (d == 2)
                    y -= 1;
                else
                    x -= 1;
                cout << direct_text[d];
                break;
            }
        }
        if (x == 1 && y == 1)
            break;
    }
    cout << endl;
    return 0;
}

C++: #include <iostream>

using namespace std;

int main(void){
  int state; //ツ前ツ嘉アツづ個督ョツつ「ツつスツ陛サツ古シ
  int x, y; //current position
  bool horizon[5][4];
  bool vertical[4][5];
  char tmp;
  int i,j;

  for(i=0;i<9;i++){
	if(i%2 == 0){
	  for(j=0;j<4;j++){
		cin >> tmp;
		if(tmp == '1'){
		  horizon[i/2][j] = true;
		}else{
		  horizon[i/2][j] = false;
		}
	  }
	}else{
	  for(j=0;j<5;j++){
		cin >> tmp;
		if(tmp == '1'){
		  vertical[i/2][j] = true;
		}else{
		  vertical[i/2][j] = false;
		}
	  }
	}
  }

  state = 'R';
  cout << "R";
  x = 0;
  y = 1;
  
  while(!(x == 0 && y == 0)){
	if(state == 'R'){
	  if(x - 1 >= 0 && vertical[x-1][y] ){
		state = 'U';
		x--;
		cout << "U";
	  }else if(y <= 3 && horizon[x][y]){
		state = 'R';
		y++;
		cout << "R";
	  }else{
		state = 'D';
		x++;
		cout << "D";
	  }
	}else if(state == 'D'){
	  if(y <= 3 && horizon[x][y]){
		state = 'R';
		y++;
		cout << "R";
	  }else if(x <= 3 && vertical[x][y]){
		state = 'D';
		x++;
		cout << "D";
	  }else{
		state = 'L';
		y--;
		cout << "L";
	  }
	}else if(state == 'L'){
	  if(x <= 3 && vertical[x][y]){
		state = 'D';
		x++;
		cout << "D";
	  }else if(y >= 1 && horizon[x][y-1]){
		state = 'L';
		y--;
		cout << "L";
	  }else{
		state = 'U';
		x--;
		cout << "U";
	  }
	}else{
	  if(y >= 1 && horizon[x][y-1]){
		state = 'L';
		y--;
		cout << "L";
	  }else if(x >= 1 && vertical[x-1][y]){
		state = 'U';
		x--;
		cout << "U";
	  }else{
		state = 'R';
		y++;
		cout << "R";
	  }
	}
	//cout << x << " " << y << endl;
	//cin >> i;
  }
  cout << endl;
  return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int field[6][6] = {0},a,x = 1,y = 0,t = 1;
  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]&2){
	cout <<"U";
	if(field[x][y]&1){t = 3;}
	else{y--;}
      }
      else{x++;t = 1;}
    }
    else if(t == 1){
      if(field[x][y]&4){
	cout <<"R";
	if(field[x][y]&2){t = 0;}
	else{x++;}
      }
      else{y++;t = 2;}
    }
    else if(t == 2){
      if(field[x][y]&8){
	cout <<"D";
	if(field[x][y]&4){t = 1;}
	else{y++;}
      }
      else{x--;t = 3;}
    }
    else if(t == 3){
      if(field[x][y]&1){
	cout <<"L";
	if(field[x][y]&8){t = 2;}
	else{x--;}
      }
      else{y--;t = 0;}
    }
    if(!x && !y){break;}
  }
  cout <<endl;
  return 0;
}