#include <bits/stdc++.h>
const long long INF = 10000000000000;
const long long mod = 1e9 + 7;
using namespace std;
void add(int& a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
long long mul(long long a, long long b) { return (a * b) % mod; }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, m;
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    vector<string> inp(n);
    for (int i = 0; i < n; i++) cin >> inp[i];
    std::vector<int> r1(26, -1);
    std::vector<int> r2(26, -1);
    std::vector<int> c1(26, -1);
    std::vector<int> c2(26, -1);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (inp[i][j] != '.') {
          int c = (int)inp[i][j] - (int)'a';
          if (r1[c] == -1) {
            r1[c] = i;
            r2[c] = i;
            c1[c] = j;
            c2[c] = j;
          } else {
            r1[c] = min(i, r1[c]);
            r2[c] = max(i, r2[c]);
            c1[c] = min(j, c1[c]);
            c2[c] = max(j, c2[c]);
          }
        }
      }
    }
    string s = "";
    for (int i = 0; i < m; i++) s += '.';
    vector<string> ans(n, s);
    for (int c = 0; c < 26; c++) {
      if (r1[c] != -1) {
        if (r1[c] == r2[c]) {
          for (int j = c1[c]; j <= c2[c]; j++) {
            ans[r1[c]][j] = (char)(c + (int)'a');
          }
        } else {
          for (int i = r1[c]; i <= r2[c]; i++) {
            ans[i][c1[c]] = (char)(c + (int)'a');
          }
        }
      }
    }
    int nb = 0;
    bool b = false;
    bool affiche = true;
    for (int i = 0; i < 26; i++) {
      if (r1[i] != -1 && b)
        affiche = false;
      else if (r1[i] != -1 && !b)
        nb++;
      else
        b = true;
    }
    if (ans == inp && affiche) {
      cout << "YES"
           << "\n";
      cout << nb << "\n";
      for (int i = 0; i < 26; i++) {
        if (r1[i] != -1) {
          cout << r1[i] + 1 << " " << c1[i] + 1 << " " << r2[i] + 1 << " "
               << c2[i] + 1 << "\n";
        }
      }
    } else if (ans == inp) {
      int last;
      for (int i = 0; i < 26; i++) {
        if (r1[i] != -1) {
          last = i;
        }
      }
      cout << "YES\n";
      cout << last + 1 << "\n";
      for (int i = 0; i <= last; i++) {
        if (r1[i] == -1)
          cout << r1[last] + 1 << " " << c1[last] + 1 << " " << r2[last] + 1
               << " " << c2[last] + 1 << "\n";
        else
          cout << r1[i] + 1 << " " << c1[i] + 1 << " " << r2[i] + 1 << " "
               << c2[i] + 1 << "\n";
      }
    } else {
      cout << "NO\n";
    }
  }
  return 0;
}
