#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define sset(s) cout<<#s<<":";each(i,s)cout <<" "<<i;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 11;
const int dx[] = {0,0,-1,1};
const int dy[] = {-1,1,0,0};

bool flag;
vector<int> ans;

void dfs(int u,int v,int dir,set<int>* h,set<int>* w,vector<int>& route,int rem)
{
    if(flag){
        return;
    }
    if(rem == 0){
        ans = route;
        flag = true;
        return;
    }
    int dame = (dir%2 == 0)?dir+1:dir-1;
    rep(i,4){
        if(flag){
            return;
        }
        if(i != dame){
            if(i == 0){
                auto it = lower_bound(all(h[v]),u);
                if(it != h[v].begin()){
                    it--;
                    int hoge = *it;
                    h[v].erase(hoge);
                    w[hoge].erase(v);
                    route.pb(0);
                    dfs(hoge,v,0,h,w,route,rem-1);
                    h[v].insert(hoge);
                    w[hoge].insert(v);
                    route.pop_back();
                }
            }
            if(i == 1){
                auto it = upper_bound(all(h[v]),u);
                if(it != h[v].end()){
                    int hoge = *it;
                    h[v].erase(hoge);
                    w[hoge].erase(v);
                    route.pb(1);
                    dfs(hoge,v,1,h,w,route,rem-1);
                    h[v].insert(hoge);
                    w[hoge].insert(v);
                    route.pop_back();
                }
            }
            if(i == 2){
                auto it = lower_bound(all(w[u]),v);
                if(it != w[u].begin()){
                    it--;
                    int hoge = *it;
                    w[u].erase(hoge);
                    h[hoge].erase(u);
                    route.pb(2);
                    dfs(u,hoge,2,h,w,route,rem-1);
                    w[u].insert(hoge);
                    h[hoge].insert(u);
                    route.pop_back();
                }
            }
            if(i == 3){
                auto it = upper_bound(all(w[u]),v);
                if(it != w[u].end()){
                    int hoge = *it;
                    w[u].erase(hoge);
                    h[hoge].erase(u);
                    route.pb(3);
                    dfs(u,hoge,3,h,w,route,rem-1);
                    w[u].insert(hoge);
                    h[hoge].insert(u);
                    route.pop_back();
                }
            }
        }
    }
    return;
}

int main()
{
    int n,m;
    set<int> h[MAX_N];
    set<int> w[MAX_N];
    vector<int> v;
    cin >> n >> m;
    int sx,sy,dir;
    int cnt  = 0;
    flag = false;
    rep(i,n){
        string s;
        cin >> s;
        rep(j,s.length()){
            if(s[j] == 'o'){
                h[i].insert(j);
                w[j].insert(i);
                cnt++;
            }else if(s[j] == 'U'){
                sx = i,sy = j,dir = 0;
            }else if(s[j] == 'D'){
                sx = i,sy = j,dir = 1;
            }else if(s[j] == 'L'){
                sx = i,sy = j,dir = 2;
            }else if(s[j] == 'R'){
                sx = i,sy = j,dir = 3;
            }
        }
    }
    char d[] = {'U','D','L','R'};
    dfs(sx,sy,dir,w,h,v,cnt);
    rep(i,ans.size()){
        cout << d[ans[i]];
    }
    cout << "\n";
}

Measured memory_bytes: 3220