#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int MAX = 2005;
const int N = 500005;
const long long mod = 1e9 + 7;
int t;
char c[2005][2005], a[2005][2005];
pair<int, int> p1[27], p2[27];
void solve() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= 26; ++i) {
    p1[i].first = p1[i].second = p2[i].first = p2[i].second = 0;
  }
  int maxx = 0;
  bool ok = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> c[i][j];
      if (c[i][j] == '.') continue;
      ok = 0;
      int now = c[i][j] - 'a' + 1;
      maxx = max(maxx, now);
      if (p1[now].first == 0) {
        p1[now].first = i;
        p1[now].second = j;
      }
      p2[now].first = i;
      p2[now].second = j;
    }
  }
  if (ok) {
    cout << "YES"
         << "\n"
         << 0 << "\n";
    return;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) a[i][j] = '.';
  }
  for (int i = 1; i <= maxx; ++i) {
    if (!p1[i].first) {
      p1[i].first = p2[i].first = p1[maxx].first;
      p1[i].second = p2[i].second = p1[maxx].second;
    }
    if (p1[i].first != p2[i].first && p1[i].second != p2[i].second) {
      cout << "NO"
           << "\n";
      return;
    }
    for (int j = p1[i].first; j <= p2[i].first; ++j) {
      for (int d = p1[i].second; d <= p2[i].second; ++d) {
        a[j][d] = i - 1 + 'a';
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (c[i][j] != a[i][j]) {
        cout << "NO"
             << "\n";
        return;
      }
    }
  }
  cout << "YES"
       << "\n"
       << maxx << "\n";
  for (int i = 1; i <= maxx; ++i) {
    cout << p1[i].first << " " << p1[i].second << " " << p2[i].first << " "
         << p2[i].second << "\n";
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  cin >> t;
  while (t--) {
    solve();
  }
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
