#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

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

int H,W;
char ans[31];

struct Info{
	void set(int arg_row,int arg_col){
		row = arg_row;
		col = arg_col;
	}
	int row,col,leaf_num,jump_num;
	char log[31],ike_map[10][11];
	DIR dir;
};

void find_next(int row,int col,DIR dir,char map[10][11],int& next_row,int& next_col){
	int calc_row = -1,calc_col = -1;

	switch(dir){
	case U:
		for(int tmp_row = row-1; tmp_row >= 0; tmp_row--){
			if(map[tmp_row][col] == 'o'){
				calc_row = tmp_row;
				calc_col = col;
				break;
			}
		}
		break;
	case D:
		for(int tmp_row = row+1; tmp_row <= H-1; tmp_row++){
			if(map[tmp_row][col] == 'o'){
				calc_row = tmp_row;
				calc_col = col;
				break;
			}
		}
		break;
	case L:
		for(int tmp_col = col-1; tmp_col >= 0; tmp_col--){
			if(map[row][tmp_col] == 'o'){
				calc_row = row;
				calc_col = tmp_col;
				break;
			}
		}

		break;
	case R:
		for(int tmp_col = col+1; tmp_col <= W-1; tmp_col++){
			if(map[row][tmp_col] == 'o'){
				calc_row = row;
				calc_col = tmp_col;
				break;
			}
		}
		break;
	}
	next_row = calc_row;
	next_col = calc_col;
}

void func(Info& next,Info info,DIR dir,int next_row,int next_col){

	next.set(next_row,next_col);

	next.leaf_num = info.leaf_num-1;
	for(int i = 0; i < info.jump_num; i++){
		next.log[i] = info.log[i];
	}

	char ch;

	switch(dir){
	case U:
		ch = 'U';
		break;
	case D:
		ch = 'D';
		break;
	case L:
		ch = 'L';
		break;
	case R:
		ch = 'R';
		break;
	}
	next.log[info.jump_num] = ch;

	next.jump_num = info.jump_num+1;
	next.dir = dir;
	for(int i = 0; i < H; i++){
		for(int k = 0; k < W; k++){
			next.ike_map[i][k] = info.ike_map[i][k];
		}
	}

	next.ike_map[info.row][info.col] = '.';

}

int debug = 0;

void recursive(Info info){

	if(info.leaf_num == 1){
		for(int i = 0; i < info.jump_num; i++){
			ans[i] = info.log[i];
		}
		ans[info.jump_num] = '\0';
		return;
	}

	int next_row = -1,next_col = -1;

	switch(info.dir){
	case U:
		find_next(info.row,info.col,U,info.ike_map,next_row,next_col);
		if(next_row != -1){
			Info next;
			func(next,info,U,next_row,next_col);
			recursive(next);
		}

		find_next(info.row,info.col,L,info.ike_map,next_row,next_col);
		if(next_row != -1){
			Info next;
			func(next,info,L,next_row,next_col);
			recursive(next);
		}

		find_next(info.row,info.col,R,info.ike_map,next_row,next_col);
		if(next_row != -1){
			Info next;
			func(next,info,R,next_row,next_col);
			recursive(next);
		}
		break;
	case D:
		find_next(info.row,info.col,D,info.ike_map,next_row,next_col);
		if(next_row != -1){
			Info next;
			func(next,info,D,next_row,next_col);
			recursive(next);
		}

		find_next(info.row,info.col,L,info.ike_map,next_row,next_col);
		if(next_row != -1){
			Info next;
			func(next,info,L,next_row,next_col);
			recursive(next);
		}

		find_next(info.row,info.col,R,info.ike_map,next_row,next_col);
		if(next_row != -1){
			Info next;
			func(next,info,R,next_row,next_col);
			recursive(next);
		}

		break;
	case L:
		find_next(info.row,info.col,U,info.ike_map,next_row,next_col);
		if(next_row != -1){
			Info next;
			func(next,info,U,next_row,next_col);
			recursive(next);
		}

		find_next(info.row,info.col,L,info.ike_map,next_row,next_col);
		if(next_row != -1){
			Info next;
			func(next,info,L,next_row,next_col);
			recursive(next);
		}

		find_next(info.row,info.col,D,info.ike_map,next_row,next_col);
		if(next_row != -1){
			Info next;
			func(next,info,D,next_row,next_col);
			recursive(next);
		}

		break;
	case R:

		find_next(info.row,info.col,U,info.ike_map,next_row,next_col);
		if(next_row != -1){
			Info next;
			func(next,info,U,next_row,next_col);
			recursive(next);
		}

		find_next(info.row,info.col,R,info.ike_map,next_row,next_col);
		if(next_row != -1){
			Info next;
			func(next,info,R,next_row,next_col);
			recursive(next);
		}

		find_next(info.row,info.col,D,info.ike_map,next_row,next_col);
		if(next_row != -1){
			Info next;
			func(next,info,D,next_row,next_col);
			recursive(next);
		}

		break;
	}
}

int main(){

	scanf("%d %d",&H,&W);

	Info first;
	first.leaf_num = 0;
	first.jump_num = 0;

	for(int i = 0; i < H; i++){
		scanf("%s",first.ike_map[i]);
		for(int k = 0; k < W; k++){

			switch(first.ike_map[i][k]){
			case '.':break;
			case 'o':
				first.leaf_num++;
				break;
			case 'U':
				first.leaf_num++;
				first.ike_map[i][k] = 'o';
				first.set(i,k);
				first.dir = U;
				break;
			case 'D':
				first.leaf_num++;
				first.ike_map[i][k] = 'o';
				first.set(i,k);
				first.dir = D;
				break;
			case 'L':
				first.leaf_num++;
				first.ike_map[i][k] = 'o';
				first.set(i,k);
				first.dir = L;
				break;
			case 'R':
				first.leaf_num++;
				first.ike_map[i][k] = 'o';
				first.set(i,k);
				first.dir = R;
				break;
			}
		}
	}

	recursive(first);

	printf("%s\n",ans);

	return 0;
}

Measured memory_bytes: 2680