#include <bits/stdc++.h>
using namespace std;
pair<int, int> st[256], en[256];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T;
  cin >> T;
  for (int cs = 1; cs <= T; cs++) {
    int n, m;
    cin >> n >> m;
    vector<string> dat, rec;
    string emp = "";
    for (int i = 0; i < m; i++) emp += '.';
    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;
      dat.emplace_back(std::move(s));
      rec.push_back(emp);
    }
    if (dat == rec) {
      puts(
          "YES"
          "\n"
          "0");
      continue;
    }
    for (int i = 'a'; i <= 'z'; i++) {
      st[i] = {999999, 999999};
      en[i] = {-1, -1};
    }
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        if (dat[i][j] != '.') {
          st[dat[i][j]] = min(st[dat[i][j]], make_pair(i, j));
          en[dat[i][j]] = max(en[dat[i][j]], make_pair(i, j));
        }
    pair<int, int> st1 = {999999, 999999}, en1 = {-1, -1};
    for (int i = 'z'; i >= 'a'; i--) {
      if (st[i].first == 999999) {
        st[i] = st1;
        en[i] = en1;
      } else {
        st1 = st[i];
        en1 = en[i];
      }
    }
    int fail = 0;
    int lasti;
    for (int i = 'a'; i <= 'z' && st[i].first != 999999; i++) {
      lasti = i;
      if (st[i].first == en[i].first)
        for (int k = st[i].second; k <= en[i].second; k++)
          rec[st[i].first][k] = i;
      else if (st[i].second == en[i].second)
        for (int k = st[i].first; k <= en[i].first; k++)
          rec[k][st[i].second] = i;
      else {
        fail = 1;
        break;
      }
    }
    if (fail || rec != dat) {
      puts("NO");
      continue;
    }
    puts("YES");
    printf("%d\n", lasti - 'a' + 1);
    for (int i = 'a'; i <= lasti; i++)
      printf("%d %d %d %d\n", st[i].first + 1, st[i].second + 1,
             en[i].first + 1, en[i].second + 1);
  }
  return 0;
}
