#include <bits/stdc++.h>
using namespace std;
long long t, n, m, cont;
char mdo[2010][2010], ans[2010][2010];
vector<vector<pair<long long, long long> > > pos;
pair<long long, pair<long long, long long> > rango[30];
pair<long long, long long> some;
bool use[30];
bool fn(long long p) {
  if (pos[p].empty()) {
    use[p] = false;
    return true;
  }
  cont = p + 1;
  some = pos[p][0];
  use[p] = true;
  bool myAns = true;
  long long mini = 1e9, maxi = -1;
  for (long long i = 0; i < pos[p].size(); i++) {
    if (pos[p][i].first != pos[p][0].first) {
      myAns = false;
      break;
    }
    mini = min(mini, pos[p][i].second);
    maxi = max(maxi, pos[p][i].second);
  }
  if (myAns) {
    rango[p] = {0, {mini, maxi}};
    return true;
  }
  mini = 1e9;
  maxi = -1;
  for (long long i = 0; i < pos[p].size(); i++) {
    if (pos[p][i].second != pos[p][0].second) {
      return false;
    }
    mini = min(mini, pos[p][i].first);
    maxi = max(maxi, pos[p][i].first);
  }
  rango[p] = {1, {mini, maxi}};
  return true;
}
void draw(long long p) {
  if (!use[p]) return;
  if (!rango[p].first) {
    for (long long j = rango[p].second.first; j <= rango[p].second.second; j++)
      ans[pos[p][0].first][j] = 'a' + p;
  } else {
    for (long long j = rango[p].second.first; j <= rango[p].second.second; j++)
      ans[j][pos[p][0].second] = 'a' + p;
  }
  return;
}
bool same() {
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < m; j++)
      if (mdo[i][j] != ans[i][j]) return false;
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> t;
  pos.resize('z' - 'a' + 1);
  while (t--) {
    for (long long i = 0; i <= 'z' - 'a'; i++) pos[i].clear();
    cont = 0;
    cin >> n >> m;
    for (long long i = 0; i < n; i++)
      for (long long j = 0; j < m; j++) {
        cin >> mdo[i][j];
        if (mdo[i][j] != '.') pos[mdo[i][j] - 'a'].push_back({i, j});
      }
    bool band = true;
    for (long long i = 0; i <= 'z' - 'a'; i++) band &= fn(i);
    if (!band) {
      cout << "NO\n";
      continue;
    }
    for (long long i = 0; i < n; i++)
      for (long long j = 0; j < m; j++) ans[i][j] = '.';
    for (long long i = 0; i <= 'z' - 'a'; i++) draw(i);
    if (same()) {
      cout << "YES\n" << cont << "\n";
      for (long long i = 0; i < cont; i++) {
        if (!use[i]) {
          cout << 1 + some.first << " " << 1 + some.second << " "
               << 1 + some.first << " " << 1 + some.second << "\n";
          continue;
        }
        if (!rango[i].first) {
          cout << 1 + pos[i][0].first << " " << 1 + rango[i].second.first << " "
               << 1 + pos[i][0].first << " " << 1 + rango[i].second.second
               << "\n";
        } else {
          cout << 1 + rango[i].second.first << " " << 1 + pos[i][0].second
               << " " << 1 + rango[i].second.second << " "
               << 1 + pos[i][0].second << "\n";
        }
      }
    } else {
      cout << "NO\n";
    }
  }
  return 0;
}
