#include <bits/stdc++.h>
using namespace std;
char mat[2005][2005];
char sim[2005][2005];
vector<int> row[256], col[256];
pair<pair<int, int>, pair<int, int>> ans[256];
int main() {
  int n, m, T;
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d", &n, &m);
    for (int i = 'a'; i <= 'z'; i++) row[i].clear(), col[i].clear();
    pair<int, int> can;
    int tot = 0;
    for (int i = 0; i < n; i++) {
      scanf(" %s", mat[i]);
      for (int j = 0; mat[i][j]; j++) {
        sim[i][j] = '.';
        if (mat[i][j] >= 'a') {
          row[mat[i][j]].push_back(i);
          col[mat[i][j]].push_back(j);
          int symbol = mat[i][j] - 'a';
          if (symbol + 1 > tot) {
            tot = symbol + 1;
            can = {i, j};
          }
        }
      }
    }
    if (!tot) {
      printf("YES\n0\n");
      continue;
    }
    bool flag = true;
    for (int i = 'a'; flag && i < tot + 'a'; i++) {
      sort(row[i].begin(), row[i].end());
      sort(col[i].begin(), col[i].end());
      if (row[i].empty())
        ans[i] = make_pair(can, can);
      else if (row[i][0] == row[i].back()) {
        ans[i] = make_pair(make_pair(row[i][0], col[i][0]),
                           make_pair(row[i][0], col[i].back()));
      } else if (col[i][0] == col[i].back()) {
        ans[i] = make_pair(make_pair(row[i][0], col[i][0]),
                           make_pair(row[i].back(), col[i][0]));
      } else
        flag = false;
    }
    for (int i = 'a'; flag && i < tot + 'a'; i++) {
      if (ans[i].first.first == ans[i].second.first) {
        for (int j = ans[i].first.second; j <= ans[i].second.second; j++)
          sim[ans[i].first.first][j] = i;
      } else {
        for (int j = ans[i].first.first; j <= ans[i].second.first; j++)
          sim[j][ans[i].first.second] = i;
      }
    }
    for (int i = 0; flag && i < n; i++)
      for (int j = 0; j < m; j++)
        if (sim[i][j] != mat[i][j]) {
          flag = false;
          break;
        }
    if (!flag) {
      printf("NO\n");
      continue;
    }
    printf("YES\n%d\n", tot);
    for (int i = 'a'; flag && i < tot + 'a'; i++)
      printf("%d %d %d %d\n", ans[i].first.first + 1, ans[i].first.second + 1,
             ans[i].second.first + 1, ans[i].second.second + 1);
  }
  return 0;
}
