#include using namespace std; //高速化 struct ponjuice{ponjuice(){cin.tie(0);ios::sync_with_stdio(0);cout<= 0; i--) #define per2(i, n) for(ll i = n-1; i >= 0; i--) #define per3(i, a, b) for(ll i = b-1; i >= a; i--) #define per4(i, a, b, step) for(ll i = b-1; i >= a; i-= step) #define per(...) overload4(__VA_ARGS__, per4, per3, per2, per1)(__VA_ARGS__) //関数 #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() templateinline bool chmax(S& a, T b){return a < b && ( a = b , true);} templateinline bool chmin(S& a, T b){return a > b && ( a = b , true);} //定数 constexpr ll mod = 998244353; constexpr ll minf=-(1<<29); constexpr ll inf=(1<<29); constexpr ll MINF=-(1LL<<60); constexpr ll INF=(1LL<<60); const int dx[4] ={-1, 0, 1, 0}; const int dy[4] ={ 0, 1, 0,-1}; const int dx8[8] ={-1,-1,-1, 0, 1, 1, 1, 0}; const int dy8[8] ={-1, 0, 1, 1, 1, 0,-1,-1}; void solve(); int main() { int t = 1; // cin >> t; while(t--)solve(); } struct Ans { pair S = {0,0}, D = {0, 0}; string command; bool ok = 0; }; Ans sol(vector s) { // for(auto x: s) cout << x << endl; int h = s.size(); int w = s[0].size(); vector> u(h, vector(w, 0)),d(h, vector(w, 0)),r(h, vector(w, 0)),l(h, vector(w, 0)); rep(i,0,h) { rep(j,0,w) { // u, l if(i && s[i-1][j]=='.' && s[i][j]=='.') chmax(u[i][j], u[i-1][j]+1); if(j && s[i][j-1]=='.' && s[i][j]=='.') chmax(l[i][j], l[i][j-1]+1); } } per(i,0,h){ per(j,0,w) { if(i> h >> w; vector s(h); rep(i,0,h) cin >> s[i]; Ans ans; rep(i,0,4) { if(ans.ok == false) ans = sol(s); { // rotate ans ans map vector nx(w, string(h,'?')); rep(i,0,h) { rep(j,0,w) { nx[j][h-1-i] = s[i][j]; } } s.swap(nx); pair nxa = {ans.S.second, h-1-ans.S.first}; ans.S = nxa; pair nxd = {ans.D.second, -ans.D.first}; ans.D = nxd; swap(h,w); } } if(ans.ok) { cout << ans.S.first+1 << " " << ans.S.second+1 << " "; if(ans.D==pair{1, 0}) cout << "D" << endl; if(ans.D==pair{-1, 0}) cout << "U" << endl; if(ans.D==pair{0, 1}) cout << "R" << endl; if(ans.D==pair{0, -1}) cout << "L" << endl; cout << ans.command.size() << endl; cout << ans.command << endl; }else{ cout << -1 << endl; } }