#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int BIG = 1e9;
const int maxN = 2000 + 9;
const string FILENAME = "sample";
int n, m;
pair<int, int> upp[300], low[300];
char cell[maxN][maxN], ansCell[maxN][maxN];
void read() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> cell[i];
  }
}
void fillChar(char c, int i, int j, int u, int v) {
  if (i == u) {
    for (int k = j; k <= v; k++) {
      ansCell[i][k] = c;
    }
  } else if (j == v) {
    for (int k = i; k <= u; k++) {
      ansCell[k][j] = c;
    }
  }
}
pair<pair<int, int>, pair<int, int> > ans[26];
void solv() {
  for (int i = 0; i < 300; i++) {
    upp[i] = make_pair(maxN, maxN);
    low[i] = make_pair(-1, -1);
  }
  int mxChar = -1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      ansCell[i][j] = '.';
      if (cell[i][j] == '.') {
        continue;
      }
      int c = cell[i][j] - 'a';
      mxChar = max(mxChar, c);
      low[c] = max(low[c], make_pair(i, j));
      upp[c] = min(upp[c], make_pair(i, j));
    }
  }
  for (int i = 0; i < 26; i++) {
    ans[i] = make_pair(make_pair(-1, -1), make_pair(-1, -1));
    if (low[i] == make_pair(-1, -1)) {
      continue;
    }
    if (upp[i] == make_pair(maxN, maxN)) {
      continue;
    }
    if (low[i].first == upp[i].first || low[i].second == upp[i].second) {
      fillChar(i + 'a', upp[i].first, upp[i].second, low[i].first,
               low[i].second);
      ans[i] = make_pair(make_pair(upp[i].first, upp[i].second),
                         make_pair(low[i].first, low[i].second));
    } else {
      cout << "NO\n";
      return;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (cell[i][j] != ansCell[i][j]) {
        cout << "NO\n";
        return;
      }
    }
  }
  cout << "YES\n";
  pair<pair<int, int>, pair<int, int> > last;
  for (int i = mxChar; i >= 0; i--) {
    if (ans[i] != make_pair(make_pair(-1, -1), make_pair(-1, -1))) {
      last = ans[i];
    } else {
      ans[i] = last;
    }
  }
  cout << mxChar + 1 << '\n';
  for (int i = 0; i <= mxChar; i++) {
    cout << ans[i].first.first + 1 << ' ' << ans[i].first.second + 1 << ' '
         << ans[i].second.first + 1 << ' ' << ans[i].second.second + 1 << '\n';
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int nTest;
  cin >> nTest;
  while (nTest--) {
    read();
    solv();
  }
  return 0;
}
