#include <bits/stdc++.h>
using namespace std;
vector<array<int, 4>> V;
vector<vector<int>> E;
vector<int> vis, tp;
int cycle(int r) {
  if (vis[r] == 2) return 0;
  if (vis[r] == 1) return 1;
  vis[r] = 1;
  for (int i = 0; i < E[r].size(); ++i)
    if (cycle(E[r][i])) return 1;
  vis[r] = 2;
  return 0;
}
void tp_rec(int r) {
  if (vis[r]) return;
  vis[r] = 1;
  for (int i = 0; i < E[r].size(); ++i) {
    tp_rec(E[r][i]);
  }
  tp.push_back(r);
}
int main() {
  int tn;
  cin >> tn;
  while (tn--) {
    int n, m;
    cin >> n >> m;
    vector<string> sh;
    for (int i = 0; i < n; ++i) {
      string s;
      cin >> s;
      sh.push_back(s);
    }
    vector<vector<array<int, 2>>> snk(26, vector<array<int, 2>>());
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < m; ++j)
        if (sh[i][j] != '.') snk[sh[i][j] - 'a'].push_back({i, j});
    for (int i = 0; i < 26; ++i) sort(snk[i].begin(), snk[i].end());
    V.assign(26, {-1, -1, -1, -1});
    E.assign(26, vector<int>());
    int ok = 1;
    for (int i = 0; ok && i < snk.size(); ++i) {
      if (snk[i].size() == 0)
        continue;
      else if (snk[i].size() == 1) {
        auto [a, b] = snk[i].front();
        V[i] = {a, b, a, b};
      } else {
        auto [a, b] = snk[i].front();
        auto [c, d] = snk[i].back();
        V[i] = {a, b, c, d};
        if (a == c) {
          for (int j = 0; j < snk[i].size(); ++j)
            if (a != snk[i][j][0]) ok = 0;
          for (int j = b; j <= d; ++j) {
            if (sh[a][j] == '.')
              ok = 0;
            else if (sh[a][j] != 'a' + i) {
              E[i].push_back(sh[a][j] - 'a');
            }
          }
        } else {
          for (int j = 0; ok && j < snk[i].size(); ++j)
            if (b != snk[i][j][1]) ok = 0;
          for (int j = a; j <= c; ++j) {
            if (sh[j][b] == '.')
              ok = 0;
            else if (sh[j][b] != 'a' + i) {
              E[i].push_back(sh[j][b] - 'a');
            }
          }
        }
      }
    }
    if (ok) {
      int pv = -1;
      for (int i = 25; i >= 0; --i) {
        if (pv == -1) {
          if (V[i][0] != -1) pv = i;
          continue;
        }
        E[i].push_back(i + 1);
        if (V[i][0] == -1) V[i] = V[i + 1];
      }
      vis.assign(26, 0);
      for (int i = 0; i < 26; ++i) {
        auto [a, b, c, d] = V[i];
        if (a == -1) continue;
        if (cycle(i)) {
          ok = 0;
          break;
        }
      }
    }
    if (ok) {
      vis.assign(26, 0);
      tp.clear();
      for (int i = 0; i < 26; ++i) {
        auto [a, b, c, d] = V[i];
        if (a == -1) continue;
        tp_rec(i);
      }
      reverse(tp.begin(), tp.end());
      vector<int> ttp = tp;
      sort(ttp.begin(), ttp.end());
      if (ttp != tp) ok = 0;
    }
    cout << (ok ? "YES" : "NO") << endl;
    if (ok) {
      cout << tp.size() << endl;
      for (int i = 0; i < tp.size(); ++i) {
        auto [a, b, c, d] = V[tp[i]];
        cout << a + 1 << " " << b + 1 << " " << c + 1 << " " << d + 1 << endl;
      }
    }
  }
  return 0;
}
