#include <bits/stdc++.h>
using namespace std;
long long n, m;
char board[2005][2005], redraw[2005][2005];
vector<pair<long long, long long> > pos[27];
pair<pair<long long, long long>, pair<long long, long long> > Ans[27];
void refresh() {
  for (long long i = 0; i < 27; i++) pos[i].clear(), Ans[i] = {{0, 0}, {0, 0}};
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= m; j++) board[i][j] = redraw[i][j] = '.';
}
bool horCheck(long long i) {
  if (pos[i].size() <= 1) return 1;
  for (long long j = 1; j < pos[i].size(); j++)
    if (pos[i][j].first != pos[i][0].first) return 0;
  return 1;
}
bool verCheck(long long i) {
  if (pos[i].size() <= 1) return 1;
  for (long long j = 1; j < pos[i].size(); j++)
    if (pos[i][j].second != pos[i][0].second) return 0;
  return 1;
}
bool snakeCheck(long long i) { return (horCheck(i) || verCheck(i)); }
bool boardCheck() {
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= m; j++)
      if (board[i][j] != redraw[i][j]) return 0;
  return 1;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  for (long long i = 0; i < 2005; i++)
    for (long long j = 0; j < 2005; j++) redraw[i][j] = '.';
  long long T;
  cin >> T;
  while (T--) {
    cin >> n >> m;
    for (long long i = 1; i <= n; i++)
      for (long long j = 1; j <= m; j++) {
        cin >> board[i][j];
        if (board[i][j] != '.') pos[board[i][j] - 'a'].push_back({i, j});
      }
    bool linearCheck = 1;
    for (long long i = 0; i < 26; i++)
      if (!snakeCheck(i)) {
        linearCheck = 0;
        break;
      }
    if (!linearCheck) {
      cout << "NO\n";
      refresh();
      continue;
    }
    long long ans3 = 0;
    for (long long i = 25; i > -1; i--) {
      if (pos[i].empty()) {
        if (pos[i + 1].empty()) continue;
        pos[i] = pos[i + 1];
        Ans[i] = Ans[i + 1];
      } else
        Ans[i] = {pos[i][0], pos[i].back()};
      ans3++;
    }
    for (long long i = 0; i < ans3; i++) {
      if (horCheck(i)) {
        long long x = Ans[i].first.first, y = Ans[i].first.second,
                  yy = Ans[i].second.second;
        for (long long j = y; j <= yy; j++) redraw[x][j] = i + 'a';
      } else {
        long long x = Ans[i].first.first, xx = Ans[i].second.first,
                  y = Ans[i].second.second;
        for (long long j = x; j <= xx; j++) redraw[j][y] = i + 'a';
      }
    }
    bool c = boardCheck();
    if (!c)
      cout << "NO\n";
    else {
      cout << "YES\n" << ans3 << "\n";
      for (long long i = 0; i < ans3; i++)
        cout << Ans[i].first.first << " " << Ans[i].first.second << " "
             << Ans[i].second.first << " " << Ans[i].second.second << "\n";
    }
    refresh();
  }
}
