#include <bits/stdc++.h>
using namespace std;
void doRoutine() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  srand(322179);
}
const int ALP = 26;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<vector<char> > arr(n, vector<char>(m));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> arr[i][j];
    }
  }
  vector<vector<pair<int, int> > > pos(ALP);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (arr[i][j] != '.') {
        pos[arr[i][j] - 'a'].push_back({i, j});
      }
    }
  }
  while (pos.size() > 0 && pos.back().size() == 0) {
    pos.pop_back();
  }
  if (pos.size() == 0) {
    cout << "YES" << endl;
    cout << 0 << endl;
    return;
  }
  int resolvx, resolvy;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (arr[i][j] == (char)('a' + pos.size() - 1)) {
        resolvx = i, resolvy = j;
      }
    }
  }
  vector<vector<char> > work(n, vector<char>(m, '.'));
  vector<pair<pair<int, int>, pair<int, int> > > ans;
  int k = pos.size();
  for (int i = 0; i < k; ++i) {
    set<int> rows, cols;
    for (auto elem : pos[i]) {
      rows.insert(elem.first);
      cols.insert(elem.second);
    }
    if (rows.size() > 1 && cols.size() > 1) {
      cout << "NO" << endl;
      return;
    }
    if (rows.size() == 1) {
      int row = *rows.begin();
      int from = m + 1, to = -1;
      for (auto elem : cols) {
        from = min(from, elem);
        to = max(to, elem);
      }
      for (int j = from; j <= to; ++j) {
        work[row][j] = (char)('a' + i);
      }
      ans.push_back({{row, from}, {row, to}});
    } else if (cols.size() == 1) {
      int col = *cols.begin();
      int from = n + 1, to = -1;
      for (auto elem : rows) {
        from = min(from, elem);
        to = max(to, elem);
      }
      for (int j = from; j <= to; ++j) {
        work[j][col] = (char)('a' + i);
      }
      ans.push_back({{from, col}, {to, col}});
    } else {
      ans.push_back({{resolvx, resolvy}, {resolvx, resolvy}});
    }
  }
  if (work == arr) {
    cout << "YES" << endl;
    cout << k << endl;
    for (auto elem : ans) {
      cout << elem.first.first + 1 << " " << elem.first.second + 1 << " "
           << elem.second.first + 1 << " " << elem.second.second + 1 << endl;
    }
  } else {
    cout << "NO" << endl;
  }
}
signed main() {
  doRoutine();
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
