#include <bits/stdc++.h>
using namespace std;
struct node {
  int a, b, c, d;
};
void solvre() {
  int n, m;
  cin >> n >> m;
  char mapa[2002][2002];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf(" %c", &mapa[i][j]);
    }
  }
  vector<node> v;
  v.resize(30);
  for (int i = 0; i < 30; i++) {
    v[i].a = v[i].b = 9999999;
    v[i].c = v[i].d = -1;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mapa[i][j] != '.') {
        int g = mapa[i][j] - 97;
        v[g].a = min(v[g].a, i);
        v[g].b = min(v[g].b, j);
        v[g].c = max(v[g].c, i);
        v[g].d = max(v[g].d, j);
      }
    }
  }
  bool loc = true;
  int cont = 0;
  for (int g = 0; g < 30; g++) {
    if (v[g].c != -1) {
      cont = g + 1;
    }
  }
  if (cont == 0) {
    cout << "YES\n0\n";
    return;
  }
  for (int g = 0; g < 30; g++) {
    if (v[g].c == -1) {
      v[g].a = v[cont - 1].a;
      v[g].b = v[cont - 1].b;
      v[g].c = v[cont - 1].c;
      v[g].d = v[cont - 1].d;
      continue;
    }
    char letra = g + 97;
    if (v[g].a == v[g].c) {
      int i = v[g].a;
      for (int j = v[g].b; j <= v[g].d; j++) {
        if (mapa[i][j] < letra) {
          cout << "NO\n";
          return;
        }
      }
    } else if (v[g].b == v[g].d) {
      int j = v[g].b;
      for (int i = v[g].a; i <= v[g].c; i++) {
        if (mapa[i][j] < letra) {
          cout << "NO\n";
          return;
        }
      }
    } else {
      cout << "NO\n";
      return;
    }
  }
  cout << "YES\n";
  cout << cont << endl;
  for (int g = 0; g < cont; g++) {
    cout << v[g].a + 1 << " " << v[g].b + 1 << " " << v[g].c + 1 << " "
         << v[g].d + 1 << endl;
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) solvre();
}
