#include <bits/stdc++.h>
using namespace std;
const int sz = 2005, alp = 26;
string s[sz];
int ind(char a) { return int(a - 97); }
vector<pair<int, int> > v[alp];
void print(pair<int, int> p) {
  cout << p.first + 1 << " " << p.second + 1 << " ";
}
bool valid() {
  for (int i = 0; i < alp; i++) {
    int n = v[i].size();
    if (n > 1) {
      if (v[i][1].first == v[i][0].first) {
        int row = v[i][0].first;
        for (int j = 0; j < n; j++) {
          if (v[i][j].first != row) {
            return false;
          }
        }
        for (int j = v[i][0].second; j <= v[i][n - 1].second; j++) {
          if (s[row][j] == '.') {
            return false;
          }
          int index = ind(s[row][j]);
          if (index < i) {
            return false;
          }
        }
      } else if (v[i][1].second == v[i][0].second) {
        int col = v[i][0].second;
        for (int j = 0; j < n; j++) {
          if (v[i][j].second != col) {
            return false;
          }
        }
        for (int j = v[i][0].first; j <= v[i][n - 1].first; j++) {
          if (s[j][col] == '.') {
            return false;
          }
          int index = ind(s[j][col]);
          if (index < i) {
            return false;
          }
        }
      } else {
        return false;
      }
    }
  }
  return true;
}
int main() {
  int t;
  cin >> t;
  while (t-- > 0) {
    for (int i = 0; i < alp; i++) {
      v[i].clear();
    }
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
    }
    int mx = -1;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (s[i][j] != '.') {
          v[ind(s[i][j])].push_back(make_pair(i, j));
          mx = max(mx, ind(s[i][j]));
        }
      }
    }
    if (valid() == false) {
      cout << "NO" << endl;
      continue;
    }
    cout << "YES" << endl;
    if (mx == -1) {
      cout << 0 << endl;
      continue;
    } else {
      cout << mx + 1 << endl;
    }
    for (int i = 0; i <= mx; i++) {
      int index = i;
      if (v[i].size() == 0) {
        index = mx;
      }
      print(v[index][0]);
      print(v[index][v[index].size() - 1]);
      cout << endl;
    }
  }
  return 0;
}
