#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 2010;
char g[N][N], res[N][N];
int r1[30], r2[30], c1[30], c2[30];
int n, m;
int main() {
  int T;
  for (scanf("%d", &T); T--;) {
    int R, C;
    scanf("%d%d", &R, &C);
    for (int i = 0; i < R; i++) scanf("%s", g[i]);
    memset(r1, 0xbf, sizeof r1);
    memset(r2, 0x3f, sizeof r2);
    memset(c1, 0x3f, sizeof c1);
    memset(c2, 0xbf, sizeof c2);
    for (int i = 0; i < R; i++)
      for (int j = 0; j < C; j++)
        if (g[i][j] != '.') {
          int k = g[i][j] - 'a';
          r1[k] = max(r1[k], i);
          c1[k] = min(c1[k], i);
          r2[k] = min(r2[k], j);
          c2[k] = max(c2[k], j);
        }
    int ans1 = 0;
    for (int i = 0; i < 26; i++) {
      if (r1[i] >= 0) ans1 = i + 1;
    }
    for (int i = ans1 - 1; i >= 0; i--) {
      if (r1[i] < 0) {
        r1[i] = r1[i + 1];
        r2[i] = r2[i + 1];
        c1[i] = c1[i + 1];
        c2[i] = c2[i + 1];
      }
    }
    bool ok = 1;
    for (int i = 0; i < R; i++)
      for (int j = 0; j < C; j++) res[i][j] = '.';
    for (int i = 0; ok && i < ans1; i++) {
      if (r1[i] == c1[i]) {
        for (int j = r2[i]; j <= c2[i]; j++) res[r1[i]][j] = i + 'a';
      } else if (r2[i] == c2[i]) {
        for (int j = c1[i]; j <= r1[i]; j++) res[j][r2[i]] = i + 'a';
      } else
        ok = 0;
    }
    for (int i = 0; i < R && ok; i++)
      for (int j = 0; j < C && ok; j++)
        if (res[i][j] != g[i][j]) ok = 0;
    if (!ok) {
      puts("NO");
      continue;
    }
    printf("YES\n%d\n", ans1);
    for (int i = 0; i < ans1; i++)
      printf("%d %d %d %d\n", r1[i] + 1, r2[i] + 1, c1[i] + 1, c2[i] + 1);
  }
  return 0;
}
