#include <bits/stdc++.h>
using namespace std;
vector<string> v;
vector<vector<bool>> vis(1005, vector<bool>(1005, 0));
vector<vector<char>> grid(1005, vector<char>(1005, '-1'));
long long N, M, si, sj, ei, ej;
long long dx[] = {1, -1, 0, 0};
long long dy[] = {0, 0, 1, -1};
char dir[] = {'L', 'R', 'U', 'D'};
bool ispossible(long long i, long long j) {
  return (i >= 0 && i < N && j >= 0 && j < M);
}
long long BFS(long long i, long long j) {
  cout << i << " " << j << endl;
  queue<pair<long long, long long>> q;
  map<pair<long long, long long>, pair<long long, long long>> parent;
  q.push(pair<long long, long long>(i, j));
  while (!q.empty()) {
    pair<long long, long long> p = q.front();
    long long nx = p.first, ny = p.second;
    cout << nx << " " << ny << endl;
    vis[nx][ny] = 1;
    q.pop();
    for (long long i = 0; i < 4; i++) {
      if (!ispossible(nx + dx[i], ny + dy[i]) || vis[nx + dx[i]][ny + dy[i]])
        continue;
      cout << "andar" << endl;
      vis[nx + dx[i]][ny + dy[i]] = 1;
      q.push(pair<long long, long long>(nx + dx[i], ny + dy[i]));
      parent[pair<long long, long long>(nx + dx[i], ny + dy[i])] = p;
      grid[nx + dx[i]][ny + dy[i]] = dir[i];
    }
  }
  if (vis[ei][ej] == 0) {
    cout << "NO" << endl;
    return (0);
  } else {
    string ans;
    cout << "YES" << endl;
    pair<long long, long long> fin = pair<long long, long long>(ei, ej);
    while (fin.first != si && fin.second != sj) {
      ans.push_back(grid[fin.first][fin.second]);
      fin = parent[pair<long long, long long>(fin.first, fin.second)];
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return (0);
  }
}
void solve() {
  cin >> N >> M;
  cout << N << " " << M << endl;
  v.resize(N);
  for (long long i = 0; i < N; i++) {
    cin >> v[i];
  }
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j < M; j++) {
      if (v[i][j] == 'A') {
        si = i;
        sj = j;
      }
      if (v[i][j] == 'B') {
        ei = i;
        ej = j;
      }
      if (v[i][j] == '#') {
        vis[i][j] = 1;
      }
      if (v[i][j] == '.') {
        vis[i][j] = 0;
      }
    }
  }
  cout << si << " " << sj << endl;
  cout << ei << " " << ej << endl;
  BFS(si, sj);
}
int main(int argc, char **argv) {
  long long t = 1;
  while (t--) {
    solve();
  }
  return (0);
}
