#include <bits/stdc++.h>
using namespace std;
struct item {
  int firstI;
  int firstJ;
  int lastI;
  int lastJ;
  bool row;
  bool column;
};
bool upd(char c, vector<item> &b, int i, int j) {
  if (b[c].firstI == -1 && b[c].firstJ == -1) {
    b[c].firstI = i;
    b[c].firstJ = j;
  } else if (i != b[c].firstI && j != b[c].firstJ) {
    return false;
  } else if (!b[c].row && !b[c].column) {
    if (i == b[c].firstI)
      b[c].row = true;
    else if (j == b[c].firstJ)
      b[c].column = true;
  } else if (b[c].row && i != b[c].firstI) {
    return false;
  } else if (b[c].column && j != b[c].firstJ) {
    return false;
  }
  b[c].lastI = i;
  b[c].lastJ = j;
  return true;
}
void solve() {
  int maxC = -1;
  int n, m;
  scanf("%d %d\n", &n, &m);
  vector<vector<char>> a(n + 1, vector<char>(m + 1));
  vector<item> b('z' + 1, {-1, -1, -1, -1, false, false});
  bool f = true;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf(" %c", &a[i][j]);
      if (!f) continue;
      if (a[i][j] == '.') continue;
      if (upd(a[i][j], b, i, j)) {
        maxC = max(maxC, int(a[i][j]));
      } else {
        f = false;
      }
    }
  }
  if (!f) {
    printf("NO\n");
    return;
  }
  if (maxC == -1) {
    printf("YES\n");
    printf("0\n");
    return;
  }
  int tempi = b[maxC].firstI;
  int tempj = b[maxC].firstJ;
  for (int i = maxC; i >= 'a'; i--) {
    if (b[i].firstI != b[i].lastI && b[i].firstJ != b[i].lastJ) {
      printf("NO\n");
      return;
    }
    if (b[i].firstI == -1 && b[i].firstJ == -1) {
      continue;
    } else {
      if (b[i].firstI == b[i].lastI) {
        for (int j = b[i].firstJ; j <= b[i].lastJ; j++) {
          if (a[b[i].firstI][j] != char(i) && a[b[i].firstI][j] < char(i)) {
            printf("NO\n");
            return;
          }
        }
      } else if (b[i].firstJ == b[i].lastJ) {
        for (int j = b[i].firstI; j <= b[i].lastI; j++) {
          if (a[j][b[i].firstJ] != char(i) && a[j][b[i].firstJ] < char(i)) {
            printf("NO\n");
            return;
          }
        }
      }
    }
  }
  printf("YES\n");
  printf("%d\n", maxC - 'a' + 1);
  for (int i = 'a'; i <= maxC; i++) {
    if (b[i].firstI == -1 && b[i].firstJ == -1)
      printf("%d %d %d %d\n", tempi, tempj, tempi, tempj);
    else
      printf("%d %d %d %d\n", b[i].firstI, b[i].firstJ, b[i].lastI, b[i].lastJ);
  }
  return;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}
