#include <bits/stdc++.h>
using namespace std;
const long long int N = 250001;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, m;
    cin >> n >> m;
    string s[n];
    int until = -1;
    string br[n];
    for (long long int i = 0; i < n; ++i) {
      cin >> s[i];
      br[i] = "";
    }
    set<pair<long long int, long long int> > ss[26];
    for (long long int i = 0; i < n; ++i) {
      for (long long int j = 0; j < m; ++j) {
        br[i] += '.';
        if (s[i][j] != '.') {
          until = max(until, s[i][j] - 'a');
          ss[s[i][j] - 'a'].insert(make_pair(i, j));
        }
      }
    }
    int f = 1;
    for (long long int i = 0; i < 26; ++i) {
      int ch = 0;
      int ff = 1;
      auto prev = make_pair(-1, -1);
      for (auto x : ss[i]) {
        if (ch != 0) {
          if (x.first != prev.first) {
            ff = 0;
            break;
          }
        }
        ++ch;
        prev = x;
      }
      if (ff == 1) {
        continue;
      }
      ff = 1;
      ch = 0;
      for (auto x : ss[i]) {
        if (ch != 0) {
          if (x.second != prev.second) {
            ff = 0;
            break;
          }
        }
        ++ch;
        prev = x;
      }
      if (ff == 0) {
        f = 0;
        break;
      }
    }
    if (f == 0) {
      cout << "NO" << endl;
      continue;
    }
    if (until == -1) {
      cout << "YES" << endl << "0" << endl;
      continue;
    }
    for (long long int i = 0; i <= until; ++i) {
      if (!ss[i].empty()) {
        pair<long long int, long long int> x = *ss[i].begin();
        set<pair<long long int, long long int> >::iterator it = ss[i].end();
        advance(it, -1);
        pair<long long int, long long int> y = *it;
        if (x.first == y.first) {
          for (long long int j = min(x.second, y.second);
               j <= max(x.second, y.second); ++j) {
            br[x.first][j] = char('a' + i);
          }
        } else {
          for (long long int j = min(x.first, y.first);
               j <= max(x.first, y.first); ++j) {
            br[j][x.second] = char('a' + i);
          }
        }
      }
    }
    f = 1;
    for (long long int i = 0; i < n; ++i) {
      for (long long int j = 0; j < m; ++j) {
        if (s[i][j] != br[i][j]) {
          f = 0;
        }
      }
    }
    if (f == 0) {
      cout << "NO" << endl;
      continue;
    }
    cout << "YES" << endl << until + 1 << endl;
    vector<long long int> ccopy;
    vector<pair<pair<long long int, long long int>,
                pair<long long int, long long int> > >
        ans(until + 1);
    for (long long int i = 0; i <= until; ++i) {
      if (ss[i].empty()) {
        ccopy.push_back(i);
      } else {
        ans[i].first = *ss[i].begin();
        set<pair<long long int, long long int> >::iterator it = ss[i].end();
        advance(it, -1);
        ans[i].second = *it;
      }
    }
    if (ccopy.size() > 0) {
      for (long long int i = ccopy.size() - 1; i >= 0; --i) {
        ans[ccopy[i]] = ans[ccopy[i] + 1];
      }
    }
    for (long long int i = 0; i < ans.size(); ++i) {
      cout << ans[i].first.first + 1 << " " << ans[i].first.second + 1 << " "
           << ans[i].second.first + 1 << " " << ans[i].second.second + 1
           << endl;
    }
  }
  return (0);
}
