#include <bits/stdc++.h>
using namespace std;
const int N = 30;
const int M = 2010;
vector<pair<int, int> > pts[N];
int n, m, alignment[N], numSnakes;
char grid[M][M], newGrid[M][M];
int rs[N], re[N], cs[N], ce[N];
bool possible() {
  for (int i = 0; i < numSnakes; i++)
    if (alignment[i] == -1) return false;
  return true;
}
void findAlignment(int k) {
  if (pts[k].size() == 0) {
    alignment[k] = 0;
    return;
  }
  bool rA = true, cA = true;
  for (int i = 1; i < pts[k].size(); i++) {
    if (pts[k][i].first != pts[k][0].first) {
      rA = false;
      break;
    }
  }
  for (int i = 1; i < pts[k].size(); i++) {
    if (pts[k][i].second != pts[k][0].second) {
      cA = false;
      break;
    }
  }
  if (!(rA || cA)) {
    alignment[k] = -1;
    return;
  }
  if (rA)
    alignment[k] = 0;
  else
    alignment[k] = 1;
  sort(pts[k].begin(), pts[k].end());
}
bool sameGrid() {
  for (int i = 0; i < n; i++)
    ;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (grid[i][j] != newGrid[i][j]) return false;
  return true;
}
int main() {
  int tc;
  scanf("%d", &tc);
  while (tc--) {
    for (int i = 0; i < N; i++) pts[i].clear();
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++) scanf("%s", grid[i]);
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        if (grid[i][j] != '.') pts[grid[i][j] - 'a'].emplace_back(i, j);
    numSnakes = 0;
    for (int i = 25; i >= 0; i--)
      if (pts[i].size()) {
        numSnakes = i + 1;
        break;
      };
    for (int i = numSnakes - 1; i >= 0; i--) findAlignment(i);
    if (possible()) {
      for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) newGrid[i][j] = '.';
      for (int i = 0; i < n; i++) newGrid[i][m] = '\0';
      for (int i = numSnakes - 1; i >= 0; i--) {
        ;
        if (pts[i].size() == 0) {
          rs[i] = re[i] = rs[i + 1];
          cs[i] = ce[i] = cs[i + 1];
        } else {
          rs[i] = pts[i][0].first;
          cs[i] = pts[i][0].second;
          re[i] = pts[i].back().first;
          ce[i] = pts[i].back().second;
        }
      }
      for (int i = 0; i < numSnakes; i++) {
        if (alignment[i] == 0) {
          for (int c = cs[i]; c <= ce[i]; c++) newGrid[rs[i]][c] = 'a' + i;
        } else {
          for (int r = rs[i]; r <= re[i]; r++) newGrid[r][cs[i]] = 'a' + i;
        }
      }
      if (sameGrid()) {
        printf("YES\n%d\n", numSnakes);
        for (int i = 0; i < numSnakes; i++)
          printf("%d %d %d %d\n", rs[i] + 1, cs[i] + 1, re[i] + 1, ce[i] + 1);
      } else
        printf("NO\n");
    } else
      printf("NO\n");
  }
}
