require 'pp'

class Grid
  def initialize
    results = []
    while input = $stdin.gets do 
      if /\d/ =~ input
        @x = 0
        @y = 0
        @direct = 0
        @result = ""
        @map = []
        count = 1
        @map << ["1"] + input.chomp.split('').join("1").split('') + ["1"]
        8.times do 
          if count % 2 == 0  
            @map << ["1"] + $stdin.gets.chomp.split('').join("1").split('') + ["1"]
          else
            @map << $stdin.gets.chomp.split('').join("0").split('')
          end
          count += 1
        end
        @width = @map[0].size
        @height = @map.size
        walk_map
        results << @result
      end
    end

    results.each do |ans|
      puts ans
    end
  end

  def walk_map
    count = 0
    loop do
      case @direct
      when 0
        walk_right
      when 1
        walk_down
      when 2
        walk_left
      when 3
        walk_up
      end
      break if @y == 0 && @x == 0
      count += 1
      if count > 1000
        s = ""
        9.times do |n|
          s += @map[n].to_s + "\n"
        end
        #$stderr.puts s
        break
      end
    end
  end

  def check_up_or_down
    case @direct
    when 0
      if @y != 0 && @map[@y-1][@x] == "1"
        @direct = 3
      elsif @y != @height-1 && @map[@y+1][@x] == "1"
        @direct = 1
      else
        @direct = 2
      end
    when 2
      if @y != @height-1 && @map[@y+1][@x] == "1"
        @direct = 1
      elsif @y != 0 && @map[@y-1][@x] == "1"
        @direct = 3
      else
        @direct = 0
      end
    end
  end

  def check_right_or_left
    case @direct
    when 1
      if @x != @width-1 && @map[@y][@x+1] == "1"
        @direct = 0
      elsif @x != 0 && @map[@y][@x-1] == "1"
        @direct = 2
      else
        @direct = 3
      end
    when 3
      if @x != 0 && @map[@y][@x-1] == "1"
        @direct = 2
      elsif @x != @width-1 && @map[@y][@x+1] == "1"
        @direct = 0
      else
        @direct = 1
      end
    end
  end

  def walk_right
    count = 0
    (@x+1).upto(@width-1) do |index|
      if @map[@y][index] == "1"
        count += 1
        if @y != 0 && @map[@y-1][index] == "1"
          break
        end
      else
        break
      end
    end
    step = count/2
    @x += step*2 if step > 0
    @result << "R"*step
    check_up_or_down
  end

  def walk_down
    count = 0
    (@y+1).upto(@height-1) do |index|
      if @map[index][@x] == "1"
        count += 1
        if @x != @width-1 && @map[index][@x+1] == "1"
          break
        end
      else
        break
      end
    end
    step = count/2
    @y += step*2 if step > 0
    @result << "D"*step
    check_right_or_left
  end

  def walk_left
    count = 0
    (@x-1).downto(0) do |index|
      if @map[@y][index] == "1"
        count += 1
        if @y != @height-1 && @map[@y+1][index] == "1"
          break
        end
      else
        break
      end
    end
    step = count/2
    @x -= step*2 if step > 0
    @result << "L"*step
    check_up_or_down
  end

  def walk_up
    count = 0
    (@y-1).downto(0) do |index|
      if @map[index][@x] == "1"
        count += 1
        if @x != 0 && @map[index][@x-1] == "1"
          break
        end
      else
        break
      end
    end
    step = count/2
    @y -= step*2 if step > 0
    @result << "U"*step
    check_right_or_left
  end
end

g = Grid.new

Measured memory_bytes: 3356