#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mod 1000000007
#define inf 100000000000000000
#define ar array
#define fast ios::sync_with_stdio(false); cin.tie(0)
#define setpres(x) fixed<<setprecision(x)
using namespace std;
int m,n;
string s[1000];
int dx[]={0,0,-1,1};
int dy[]={1,-1,0,0};
queue<ar<int,2>> q;
map<ar<int,2>,ar<int,2>> par;
map<ar<int,2>,int> vis;
string ans;
bool ok(int i, int j)
{
return i>=0 && i<m && j>=0 && j<n && !vis[{i,j}] && s[i][j]!='#';
}
int32_t main()
{
cin>>m>>n;
for(int i=0;i<m;i++)
cin>>s[i];
int ia,ib, fx,fy;
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
if(s[i][j]=='A')
{
ia=i;
ib=j;
}
if(s[i][j]=='B')
{
fx=i;
fy=j;
}
}
}
par[{ia,ib}]={-1,-1};
q.push({ia,ib});
vis[{ia,ib}]=1;
while(!q.empty())
{
auto x=q.front();
q.pop();
if(x[0]==fx && x[1]==fy)
break;
int i=x[0];
int j=x[1];
for(int k=0;k<4;k++)
{
if(ok(i+dx[k],j+dy[k]))
{
q.push({i+dx[k],j+dy[k]});
vis[{i+dx[k],j+dy[k]}]=1;
par[{i+dx[k],j+dy[k]}]={x[0],x[1]};
}
}
}
if(par.find({fx,fy})==par.end())
{
cout<<"NO";
return 0;
}
cout<<"YES\n";
while(1)
{
if(par[{fx,fy}][0]==-1)
break;
int f1=par[{fx,fy}][0];
int f2=par[{fx,fy}][1];
if(f2==fy+1)
ans+='L';
else if(f2==fy-1)
ans+='R';
else if(f1==fx+1)
ans+='U';
else
ans+='D';
fx=f1;
fy=f2;
}
cout<<ans.length()<<"\n";
for(int i=ans.length()-1;i>=0;i--)
cout<<ans[i];
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgaW50IGxvbmcgbG9uZwojZGVmaW5lIHBiIHB1c2hfYmFjawojZGVmaW5lIG1vZCAxMDAwMDAwMDA3CiNkZWZpbmUgaW5mIDEwMDAwMDAwMDAwMDAwMDAwMAojZGVmaW5lIGFyIGFycmF5CiNkZWZpbmUgZmFzdCBpb3M6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7IGNpbi50aWUoMCkKI2RlZmluZSBzZXRwcmVzKHgpIGZpeGVkPDxzZXRwcmVjaXNpb24oeCkKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IG0sbjsKc3RyaW5nIHNbMTAwMF07CmludCBkeFtdPXswLDAsLTEsMX07CmludCBkeVtdPXsxLC0xLDAsMH07CnF1ZXVlPGFyPGludCwyPj4gcTsKbWFwPGFyPGludCwyPixhcjxpbnQsMj4+IHBhcjsKbWFwPGFyPGludCwyPixpbnQ+IHZpczsKc3RyaW5nIGFuczsKYm9vbCBvayhpbnQgaSwgaW50IGopCnsKICAgIHJldHVybiBpPj0wICYmIGk8bSAmJiBqPj0wICYmIGo8biAmJiAhdmlzW3tpLGp9XSAmJiBzW2ldW2pdIT0nIyc7Cn0KaW50MzJfdCBtYWluKCkKewogICAgY2luPj5tPj5uOwogICAgZm9yKGludCBpPTA7aTxtO2krKykKICAgICAgICBjaW4+PnNbaV07CiAgICBpbnQgaWEsaWIsIGZ4LGZ5OwogICAgZm9yKGludCBpPTA7aTxtO2krKykKICAgIHsKICAgICAgICBmb3IoaW50IGo9MDtqPG47aisrKQogICAgICAgIHsKICAgICAgICAgICAgaWYoc1tpXVtqXT09J0EnKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpYT1pOwogICAgICAgICAgICAgICAgaWI9ajsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZihzW2ldW2pdPT0nQicpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGZ4PWk7CiAgICAgICAgICAgICAgICBmeT1qOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgcGFyW3tpYSxpYn1dPXstMSwtMX07CiAgICBxLnB1c2goe2lhLGlifSk7CiAgICB2aXNbe2lhLGlifV09MTsKICAgIHdoaWxlKCFxLmVtcHR5KCkpCiAgICB7CiAgICAgICAgYXV0byB4PXEuZnJvbnQoKTsKICAgICAgICBxLnBvcCgpOwogICAgICAgIGlmKHhbMF09PWZ4ICYmIHhbMV09PWZ5KQogICAgICAgICAgICBicmVhazsKICAgICAgICBpbnQgaT14WzBdOwogICAgICAgIGludCBqPXhbMV07CiAgICAgICAgZm9yKGludCBrPTA7azw0O2srKykKICAgICAgICB7CiAgICAgICAgICAgIGlmKG9rKGkrZHhba10saitkeVtrXSkpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHEucHVzaCh7aStkeFtrXSxqK2R5W2tdfSk7CiAgICAgICAgICAgICAgICB2aXNbe2krZHhba10saitkeVtrXX1dPTE7CiAgICAgICAgICAgICAgICBwYXJbe2krZHhba10saitkeVtrXX1dPXt4WzBdLHhbMV19OwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgaWYocGFyLmZpbmQoe2Z4LGZ5fSk9PXBhci5lbmQoKSkKICAgIHsKICAgICAgICBjb3V0PDwiTk8iOwogICAgICAgIHJldHVybiAwOwogICAgfQogICAgY291dDw8IllFU1xuIjsKICAgIHdoaWxlKDEpCiAgICB7CiAgICAgICAgaWYocGFyW3tmeCxmeX1dWzBdPT0tMSkKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgaW50IGYxPXBhclt7ZngsZnl9XVswXTsKICAgICAgICBpbnQgZjI9cGFyW3tmeCxmeX1dWzFdOwogICAgICAgIGlmKGYyPT1meSsxKQogICAgICAgICAgICBhbnMrPSdMJzsKICAgICAgICBlbHNlIGlmKGYyPT1meS0xKQogICAgICAgICAgICBhbnMrPSdSJzsKICAgICAgICBlbHNlIGlmKGYxPT1meCsxKQogICAgICAgICAgICBhbnMrPSdVJzsKICAgICAgICBlbHNlCiAgICAgICAgICAgIGFucys9J0QnOwogICAgICAgIGZ4PWYxOwogICAgICAgIGZ5PWYyOwogICAgfQogICAgY291dDw8YW5zLmxlbmd0aCgpPDwiXG4iOwogICAgZm9yKGludCBpPWFucy5sZW5ndGgoKS0xO2k+PTA7aS0tKQogICAgICAgIGNvdXQ8PGFuc1tpXTsKfQ==