#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
const int Mod = 1e9 + 7;
const int N = 2e3 + 100;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
inline long long dpow(long long a, long long b) {
  long long r = 1, t = a;
  while (b) {
    if (b & 1) r = (r * t) % Mod;
    b >>= 1;
    t = (t * t) % Mod;
  }
  return r;
}
inline long long fpow(long long a, long long b) {
  long long r = 1, t = a;
  while (b) {
    if (b & 1) r = (r * t);
    b >>= 1;
    t = (t * t);
  }
  return r;
}
struct node {
  int x1, y1, x2, y2;
} a[N];
int dir[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};
char str[N][N], s[N][N];
bool vis[N], ok;
int n, m, nx, ny;
void Init() {
  for (char i = 'a'; i <= 'z'; i++) vis[i] = false, a[i] = {0, 0, 0, 0};
}
void DFS(int x, int y, int k, char ch) {
  if (str[x][y] == ch) nx = x, ny = y;
  int xx = x + dir[k][0];
  int yy = y + dir[k][1];
  if (xx >= 1 && xx <= n && yy >= 1 && yy <= m) DFS(xx, yy, k, ch);
}
int main() {
  int T;
  cin >> T;
  while (T--) {
    scanf("%d %d", &n, &m);
    Init();
    for (int i = 1; i <= n; i++) scanf("%s", str[i] + 1);
    char mx = '0';
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (str[i][j] == '.' || vis[str[i][j]]) continue;
        vis[str[i][j]] = true;
        mx = max(mx, str[i][j]);
        ok = false;
        nx = ny = 0;
        for (int k = 0; k < 4; k++) {
          DFS(i, j, k, str[i][j]);
          if (nx != i || ny != j) {
            ok = true;
            a[str[i][j]] = {i, j, nx, ny};
            break;
          }
        }
        if (!ok) a[str[i][j]] = {i, j, i, j};
      }
    }
    if (mx == '0') {
      printf("YES\n0\n");
      continue;
    }
    for (char i = 'a'; i <= mx; i++) {
      if (!a[i].x1) a[i] = a[mx];
      if (a[i].x1 > a[i].x2) swap(a[i].x1, a[i].x2);
      if (a[i].y1 > a[i].y2) swap(a[i].y1, a[i].y2);
    }
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) s[i][j] = '.';
    for (char i = 'a'; i <= mx; i++) {
      int l = a[i].y1, r = a[i].y2;
      int u = a[i].x1, d = a[i].x2;
      for (int j = l; j <= r; j++) s[u][j] = i;
      for (int j = u; j <= d; j++) s[j][l] = i;
    }
    bool ok = true;
    for (int i = 1; i <= n && ok; i++) {
      for (int j = 1; j <= m; j++) {
        if (s[i][j] != str[i][j]) {
          ok = false;
          break;
        }
      }
    }
    if (!ok)
      puts("NO");
    else {
      printf("YES\n%d\n", mx - 'a' + 1);
      for (char i = 'a'; i <= mx; i++)
        printf("%d %d %d %d\n", a[i].x1, a[i].y1, a[i].x2, a[i].y2);
    }
  }
  return 0;
}
