#include <bits/stdc++.h>
using namespace std;
long long RAND(long long n) { return abs((rand() << 15) + rand()) % n; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    map<char, vector<pair<int, int>>> s;
    vector<vector<char>> a(n, vector<char>(m));
    pair<pair<int, int>, pair<int, int>> non_empty;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        cin >> a[i][j];
      }
    }
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        if (a[i][j] != '.') {
          s[a[i][j]].emplace_back(i, j);
          non_empty = {{i, j}, {i, j}};
        }
      }
    }
    vector<vector<char>> b(n, vector<char>(m, '.'));
    bool flag = true;
    vector<pair<pair<int, int>, pair<int, int>>> ans;
    if (s.empty()) {
      cout << "YES\n" << 0 << "\n";
      continue;
    }
    for (char sym = 'a'; sym <= 'z'; sym++) {
      if (s.find(sym) != end(s)) {
        non_empty = {{s[sym][0].first, s[sym][0].second},
                     {s[sym][0].first, s[sym][0].second}};
      }
    }
    for (char sym = 'a'; sym <= 'z'; sym++) {
      if (s.find(sym) == end(s)) {
        ans.push_back(non_empty);
      } else {
        sort(begin(s[sym]), end(s[sym]));
        vector<pair<int, int>> copy = s[sym];
        if (copy.size() == 1) {
          b[copy[0].first][copy[0].second] = sym;
          ans.push_back({{copy[0].first, copy[0].second},
                         {copy[0].first, copy[0].second}});
        } else {
          if (copy[0].first == copy[1].first) {
            int row = copy[0].first;
            for (int c = copy[0].second; c <= copy[copy.size() - 1].second;
                 ++c) {
              b[row][c] = sym;
            }
            ans.push_back(
                {{row, copy[0].second}, {row, copy[copy.size() - 1].second}});
          } else if (copy[0].second == copy[1].second) {
            int column = copy[0].second;
            for (int r = copy[0].first; r <= copy[copy.size() - 1].first; ++r) {
              b[r][column] = sym;
            }
            ans.push_back({{copy[0].first, column},
                           {copy[copy.size() - 1].first, column}});
          } else {
            flag = false;
            break;
          }
        }
        if (s.find(sym) == prev(end(s))) {
          break;
        }
      }
    }
    if (!flag) {
      cout << "NO\n";
    } else {
      if (a != b) {
        cout << "NO\n";
      } else {
        cout << "YES\n";
        cout << ans.size() << "\n";
        for (auto i : ans) {
          cout << i.first.first + 1 << ' ' << i.first.second + 1 << ' '
               << i.second.first + 1 << ' ' << i.second.second + 1 << "\n";
        }
      }
    }
  }
  return 0;
}
