#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long mult(long long a, long long b, long long p = MOD) {
  return ((a % p) * (b % p)) % p;
}
long long add(long long a, long long b, long long p = MOD) {
  return (a % p + b % p) % p;
}
string txt[4000];
int maxxx[5000], maxxy[5000], minnx[5000], minny[5000];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int casos;
  cin >> casos;
  while (casos--) {
    int n, m;
    cin >> n >> m;
    for (int chr = 'a'; chr < 'z' + 1; chr++) {
      maxxx[chr] = maxxy[chr] = -1;
      minnx[chr] = minny[chr] = 1e7;
    }
    for (int i = 0; i < n; i++) {
      cin >> txt[i];
      for (int j = 0; j < txt[i].size(); j++) {
        if (txt[i][j] != '.') {
          maxxx[txt[i][j]] = max(maxxx[txt[i][j]], j);
          minnx[txt[i][j]] = min(minnx[txt[i][j]], j);
          maxxy[txt[i][j]] = max(maxxy[txt[i][j]], i);
          minny[txt[i][j]] = min(minny[txt[i][j]], i);
        }
      }
    }
    int contador = 0;
    bool invalid = 0;
    vector<int> extras;
    int maxchar = 0;
    for (int chr = 'a'; chr < 'z' + 1; chr++) {
      if (maxxx[chr] == -1)
        continue;
      else
        maxchar = chr;
      if (maxxx[chr] == minnx[chr] || minny[chr] == maxxy[chr]) {
        for (int i = minny[chr]; i < maxxy[chr] + 1; i++) {
          for (int j = minnx[chr]; j < maxxx[chr] + 1; j++) {
            if (txt[i][j] >= chr) continue;
            invalid = 1;
          }
        }
      } else
        invalid = 1;
    }
    if (invalid == 1)
      cout << "NO\n";
    else {
      cout << "YES\n";
      contador = 0;
      for (int chr = 'a'; chr < 'z' + 1; chr++) {
        if (maxxx[chr] == -1) {
          if (maxchar >= chr) {
            contador++;
          }
          continue;
        }
        contador++;
      }
      cout << contador << endl;
      for (int chr = 'a'; chr < 'z' + 1; chr++) {
        if (maxxx[chr] == -1) {
          if (maxchar >= chr) {
            cout << minny[maxchar] + 1 << " " << minnx[maxchar] + 1 << " "
                 << minny[maxchar] + 1 << " " << minnx[maxchar] + 1 << endl;
            continue;
          } else
            continue;
        }
        cout << minny[chr] + 1 << " " << minnx[chr] + 1 << " " << maxxy[chr] + 1
             << " " << maxxx[chr] + 1 << endl;
      }
    }
  }
}
