#include <bits/stdc++.h>
using namespace std;
const int N = 2020;
int T, n, m;
char s[N][N], t[N][N];
int fx, fy, cnt;
int mix[30], miy[30], mxx[30], mxy[30];
void print() {
  printf("YES\n");
  printf("%d\n", cnt + 1);
  for (int i = 0; i <= cnt; i++) {
    if (!mxx[i]) {
      printf("%d %d %d %d\n", fx, fy, fx, fy);
    } else {
      printf("%d %d %d %d\n", mix[i], miy[i], mxx[i], mxy[i]);
    }
  }
}
bool check() {
  for (int i = 0; i <= cnt; i++) {
    if (mxx[i] && mix[i] != mxx[i] && miy[i] != mxy[i]) {
      return 0;
    }
  }
  return 1;
}
bool can() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      t[i][j] = '.';
    }
  }
  for (int i = 0; i <= cnt; i++) {
    for (int j = mix[i]; j <= mxx[i]; j++) {
      for (int k = miy[i]; k <= mxy[i]; k++) {
        t[j][k] = 'a' + i;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (s[i][j] != t[i][j]) {
        return 0;
      }
    }
  }
  return 1;
}
int main() {
  scanf("%d", &T);
  while (T--) {
    fx = 0;
    fy = 0;
    cnt = -1;
    memset(mix, 0x3f, sizeof mix);
    memset(mxx, 0, sizeof mxx);
    memset(miy, 0x3f, sizeof miy);
    memset(mxy, 0, sizeof mxy);
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) {
      scanf("%s", s[i] + 1);
    }
    for (int i = 1, rc; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (s[i][j] != '.') {
          rc = s[i][j] - 'a';
          if (rc > cnt) {
            fx = i;
            fy = j;
            cnt = rc;
          }
          mix[rc] = min(mix[rc], i);
          mxx[rc] = max(mxx[rc], i);
          miy[rc] = min(miy[rc], j);
          mxy[rc] = max(mxy[rc], j);
        }
      }
    }
    if (!fx) {
      printf("YES\n0\n");
      continue;
    }
    if (check()) {
      if (can()) {
        print();
      } else {
        printf("NO\n");
      }
    } else {
      printf("NO\n");
    }
  }
  return 0;
}
