#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2005;
int n, m;
char g[MAX_N][MAX_N];
vector<tuple<int, int, int, int>> out;
vector<pair<int, int>> s[30];
pair<int, int> lo[30], hi[30], dt[30];
bool make_valid(int i) {
  dt[i] = {0, 1};
  for (int j = 0; j < 2; j++) {
    bool work = true;
    for (auto &p : s[i]) work &= p.first == s[i][0].first;
    if (work) {
      lo[i] = {INT_MAX, INT_MAX};
      hi[i] = {0, 0};
      for (auto &p : s[i]) {
        if (lo[i].second > p.second) lo[i] = p;
        if (hi[i].second < p.second) hi[i] = p;
      }
      if (j == 1) {
        swap(lo[i].first, lo[i].second);
        swap(hi[i].first, hi[i].second);
      }
      return true;
    }
    for (auto &p : s[i]) swap(p.first, p.second);
    dt[i] = {1, 0};
  }
  return false;
}
char draw[MAX_N][MAX_N];
bool ihateyourproblem(int last) {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) draw[i][j] = '.';
  for (int i = 0; i <= last; i++) {
    auto pos = lo[i];
    auto paint = [&] { draw[pos.first][pos.second] = 'a' + i; };
    out.emplace_back(lo[i].first, lo[i].second, hi[i].first, hi[i].second);
    while (pos != hi[i]) {
      paint();
      pos.first += dt[i].first;
      pos.second += dt[i].second;
    }
    paint();
  }
  bool work = true;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) work &= g[i][j] == draw[i][j];
  return work;
}
bool solve() {
  for (int i = 0; i < 30; i++) s[i].clear();
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (g[i][j] != '.') s[g[i][j] - 'a'].emplace_back(i, j);
  int hi = -1;
  for (int i = 25; i >= 0; i--)
    if (!s[i].empty()) {
      hi = i;
      break;
    }
  if (hi == -1) return true;
  auto inv = s[hi][0];
  for (int i = 0; i < hi; i++)
    if (s[i].empty()) s[i].push_back(inv);
  for (int i = 0; i <= hi; i++)
    if (!make_valid(i)) return false;
  return ihateyourproblem(hi);
}
int main() {
  int tc;
  scanf("%d", &tc);
  while (tc--) {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++) scanf("%s", &g[i][1]);
    out.clear();
    if (solve()) {
      printf("YES\n");
      printf("%lu\n", out.size());
      for (auto &x : out)
        printf("%d %d %d %d\n", get<0>(x), get<1>(x), get<2>(x), get<3>(x));
    } else
      printf("NO\n");
  }
  return 0;
}
