#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
struct line {
  int sx, sy, ex, ey;
  friend bool operator<(const line &A, const line &B) { return A.sx < B.sx; }
};
map<char, line> mp;
int n, m;
char s[2005][2005], p[2005][2005], mxx;
void init() {
  for (char x = 'a'; x <= 'z'; ++x) {
    mp[x].sx = 0, mp[x].sy = 0;
    mp[x].ex = 0, mp[x].ey = 0;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      p[i][j] = '.';
    }
  }
}
bool check() {
  for (char x = 'a'; x <= mxx; ++x) {
    if (mp[x].sx != mp[x].ex and mp[x].sy != mp[x].ey) {
      return false;
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (s[i][j] != p[i][j]) return false;
    }
  }
  return true;
}
void slove() {
  cin >> n >> m;
  mxx = 0;
  init();
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> s[i][j];
      mxx = max(mxx, s[i][j]);
      if (mp[s[i][j]].sx == 0) {
        mp[s[i][j]].sx = i;
        mp[s[i][j]].sy = j;
        mp[s[i][j]].ex = i;
        mp[s[i][j]].ey = j;
      } else {
        mp[s[i][j]].ex = i;
        mp[s[i][j]].ey = j;
      }
    }
  }
  for (char x = 'a'; x <= mxx; ++x) {
    if (mp[x].sx == 0) {
      mp[x] = mp[mxx];
    }
    for (int xx = mp[x].sx; xx <= mp[x].ex; ++xx) {
      for (int yy = mp[x].sy; yy <= mp[x].ey; ++yy) {
        p[xx][yy] = x;
      }
    }
  }
  if (!check()) {
    cout << "NO" << endl;
    return;
  }
  cout << "YES" << endl;
  cout << max(0, mxx - 'a' + 1) << endl;
  for (char x = 'a'; x <= mxx; ++x) {
    cout << mp[x].sx << ' ' << mp[x].sy << ' ';
    cout << mp[x].ex << ' ' << mp[x].ey << endl;
  }
  return;
}
signed main() {
  ios ::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    slove();
  }
  return 0;
}
