#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const long long INF = 1e9 + 47;
const long long LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 1 << 11;
int n, m;
string s[N];
char t[N][N];
pair<pair<int, int>, pair<int, int> > field[26];
void MIN(int& x, int y) {
  if (x == -1)
    x = y;
  else
    x = min(x, y);
}
void MAX(int& x, int y) { x = max(x, y); }
bool check() {
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (m); ++j)
      if (s[i][j] != t[i][j]) return false;
  return true;
}
void solve() {
  cin >> n >> m;
  for (int i = (0); i < (n); ++i) cin >> s[i];
  char last = -1;
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (m); ++j)
      if (s[i][j] != '.') last = max(last, s[i][j]);
  if (last == -1) {
    cout << "YES\n0\n";
    return;
  }
  memset(field, -1, sizeof(field));
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (m); ++j)
      if (s[i][j] != '.') {
        char tut = s[i][j];
        MIN(field[tut - 'a'].first.first, i);
        MAX(field[tut - 'a'].second.first, i);
        MIN(field[tut - 'a'].first.second, j);
        MAX(field[tut - 'a'].second.second, j);
      }
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (m); ++j) t[i][j] = '.';
  bool ok = true;
  for (int i = (0); i < (last - 'a' + 1); ++i) {
    if (field[i].first.first == -1) continue;
    for (int x = (field[i].first.first); x < (field[i].second.first + 1); ++x)
      for (int y = (field[i].first.second); y < (field[i].second.second + 1);
           ++y)
        t[x][y] = (char)('a' + i);
    ok &= (field[i].first.first == field[i].second.first) ||
          (field[i].first.second == field[i].second.second);
  }
  if (!ok || !check()) {
    cout << "NO\n";
    return;
  }
  cout << "YES\n" << last - 'a' + 1 << '\n';
  for (int i = (0); i < (last - 'a' + 1); ++i) {
    if (field[i].first.first == -1) {
      cout << field[last - 'a'].first.first + 1 << ' '
           << field[last - 'a'].first.second + 1 << ' ';
      cout << field[last - 'a'].first.first + 1 << ' '
           << field[last - 'a'].first.second + 1 << endl;
      continue;
    }
    cout << field[i].first.first + 1 << ' ' << field[i].first.second + 1 << ' ';
    cout << field[i].second.first + 1 << ' ' << field[i].second.second + 1
         << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int tc;
  cin >> tc;
  while (tc--) solve();
  cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
  return 0;
}
