#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long m, n;
  cin >> m >> n;
  vector<string> arr(m);
  for (int i = 0; i < m; i++) cin >> arr[i];
  vector<vector<int>> store(26);
  for (int i = 0; i < 26; i++) {
    store[i] = {-1, -1, -1, -1};
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (arr[i][j] == '.') continue;
      int ind = arr[i][j] - 'a';
      if (store[ind][0] == -1) {
        store[ind][0] = i;
        store[ind][1] = j;
        store[ind][2] = i;
        store[ind][3] = j;
      } else {
        store[ind][2] = i;
        store[ind][3] = j;
      }
    }
  }
  for (int i = 24; i >= 0; i--) {
    if (store[i][0] == -1) {
      store[i][0] = store[i + 1][0];
      store[i][1] = store[i + 1][1];
      store[i][2] = store[i + 1][2];
      store[i][3] = store[i + 1][3];
    }
  }
  vector<string> ans(m);
  string temp = "";
  for (int i = 0; i < n; i++) {
    temp += '.';
  }
  for (int i = 0; i < m; i++) ans[i] = temp;
  int count = 0;
  for (int i = 0; i < 26; i++) {
    if (store[i][0] == -1) break;
    if (store[i][0] == store[i][2]) {
      for (int j = store[i][1]; j <= store[i][3]; j++) {
        ans[store[i][0]][j] = (char)('a' + i);
      }
    } else if (store[i][1] == store[i][3]) {
      for (int j = store[i][0]; j <= store[i][2]; j++) {
        ans[j][store[i][1]] = (char)('a' + i);
      }
    } else {
      cout << "NO" << endl;
      return;
    }
    count++;
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (ans[i][j] != arr[i][j]) {
        cout << "NO" << endl;
        return;
      }
    }
  }
  cout << "YES" << endl;
  cout << count << endl;
  for (int i = 0; i < count; i++) {
    cout << store[i][0] + 1 << " " << store[i][1] + 1 << " " << store[i][2] + 1
         << " " << store[i][3] + 1 << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
