#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long m, n, i, t, j, k, lb, ub;
  char var;
  bool tag;
  map<char,
      pair<pair<long long, long long>, pair<long long, long long> > >::iterator
      it;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    string a[n];
    set<char> b;
    map<char, pair<set<long long>, set<long long> > > pres;
    map<char, pair<pair<long long, long long>, pair<long long, long long> > >
        ans;
    tag = true;
    for (i = 0; i < n; i++) {
      cin >> a[i];
      for (j = 0; j < m; j++) {
        b.insert(a[i][j]);
        if (tag && a[i][j] != '.') {
          pres[a[i][j]].first.insert(i);
          pres[a[i][j]].second.insert(j);
          if (pres[a[i][j]].first.size() > 1 && pres[a[i][j]].second.size() > 1)
            tag = false;
        }
      }
    }
    b.erase('.');
    if (b.empty()) {
      cout << "YES\n0\n";
      continue;
    }
    if (!tag) {
      cout << "NO\n";
      continue;
    }
    tag = false;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        if (a[i][j] == '.' || b.find(a[i][j]) == b.end()) continue;
        b.erase(a[i][j]);
        if (pres[a[i][j]].second.size() > 1) {
          lb = *pres[a[i][j]].second.begin() + 1;
          ub = *pres[a[i][j]].second.rbegin();
          for (k = lb; k <= ub; k++) {
            if (a[i][k] != a[i][j] && (a[i][k] == '.' || a[i][j] > a[i][k])) {
              tag = true;
              break;
            }
          }
          if (tag) break;
          ans[a[i][j]] =
              make_pair(make_pair(i + 1, j + 1), make_pair(i + 1, ub + 1));
        } else {
          lb = *pres[a[i][j]].first.begin() + 1;
          ub = *pres[a[i][j]].first.rbegin();
          for (k = lb; k <= ub; k++) {
            if (a[k][j] != a[i][j] && (a[k][j] == '.' || a[i][j] > a[k][j])) {
              tag = true;
              break;
            }
          }
          if (tag) break;
          ans[a[i][j]] =
              make_pair(make_pair(i + 1, j + 1), make_pair(ub + 1, j + 1));
        }
      }
      if (tag) break;
    }
    if (tag) {
      cout << "NO\n";
      continue;
    } else {
      cout << "YES\n" << ans.rbegin()->first - 'a' + 1 << "\n";
      var = 'a' - 1;
      for (it = ans.begin(); it != ans.end(); it++) {
        do {
          cout << it->second.first.first << " " << it->second.first.second
               << " ";
          cout << it->second.second.first << " " << it->second.second.second
               << "\n";
          var++;
        } while (it->first != var);
      }
    }
  }
  return 0;
}
