#include <bits/stdc++.h>
using namespace std;
int t;
const int MAX_N = 2 * 1e3 + 100;
char s[MAX_N][MAX_N];
bool has[MAX_N][MAX_N];
int n, m;
vector<pair<int, int> > G[30];
bool ok(int idx, pair<int, int> &a, pair<int, int> &b) {
  bool okx = true, oky = true;
  int sz = G[idx].size();
  for (int i = 0; i < sz; ++i) {
    if (has[G[idx][i].first][G[idx][i].second]) return false;
  }
  for (int i = 1; i < sz; ++i) {
    okx &= (G[idx][i].first == G[idx][i - 1].first);
    if (!okx) break;
  }
  if (okx) {
    a = G[idx][0];
    b = G[idx][sz - 1];
    int first = G[idx][0].first;
    int y1 = G[idx][0].second, y2 = G[idx][sz - 1].second;
    for (int second = y1; second <= y2; ++second) {
      if (s[first][second] == '.') return false;
      has[first][second] = true;
    }
    return true;
  }
  for (int i = 1; i < sz; ++i) {
    oky &= (G[idx][i].second == G[idx][i - 1].second);
    if (!oky) break;
  }
  if (oky) {
    a = G[idx][0];
    b = G[idx][sz - 1];
    int x1 = G[idx][0].first, x2 = G[idx][sz - 1].first;
    int second = G[idx][0].second;
    for (int first = x1; first <= x2; ++first) {
      if (s[first][second] == '.') return false;
      has[first][second] = true;
    }
    return true;
  }
  return false;
}
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= 26; ++i) G[i].clear();
    int k = 0;
    for (int i = 1; i <= n; ++i) {
      scanf("%s", (s[i] + 1));
      for (int j = 1; j <= m; ++j) {
        has[i][j] = false;
        char c = s[i][j];
        int idx = (c - 'a') + 1;
        if (idx >= 1 && idx <= 26) {
          k = max(idx, k);
          G[idx].push_back((pair<int, int>){i, j});
        }
      }
    }
    bool f = true;
    vector<pair<int, int> > ans;
    pair<int, int> a, b;
    for (int i = k; i >= 1; --i) {
      if (G[i].size() == 0) {
        ans.push_back(b);
        ans.push_back(a);
      } else {
        if (!ok(i, a, b)) {
          f = false;
          break;
        } else {
          ans.push_back(b);
          ans.push_back(a);
        }
      }
    }
    if (f) {
      printf("YES\n");
      printf("%d\n", k);
      for (int i = 2 * k - 1; i >= 0; i -= 2) {
        printf("%d %d %d %d\n", ans[i].first, ans[i].second, ans[i - 1].first,
               ans[i - 1].second);
      }
    } else
      printf("NO\n");
  }
  return 0;
}
