#include <bits/stdc++.h>
using namespace std;
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
void shoot() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
long long power(long long n, long long pwr) {
  long long ans = 1LL;
  while (pwr) {
    if (pwr & 1) ans = (ans * n);
    n = (n * n);
    pwr >>= 1;
  }
  return ans;
}
int main() {
  shoot();
  long long t;
  cin >> t;
  while (t--) {
    long long i, j, n, m, x;
    cin >> n >> m;
    char a[n][m];
    bool ok = true;
    long long minX[26], maxX[26], minY[26], maxY[26];
    for (i = 0; i < 26; i++) {
      minX[i] = LONG_LONG_MAX;
      minY[i] = LONG_LONG_MAX;
      maxX[i] = -1;
      maxY[i] = -1;
    }
    long long cnt = 0;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        cin >> a[i][j];
        if (a[i][j] != '.') {
          x = a[i][j] - 'a';
          minX[x] = min(minX[x], i);
          maxX[x] = max(maxX[x], i);
          minY[x] = min(minY[x], j);
          maxY[x] = max(maxY[x], j);
          cnt = max(cnt, x + 1);
        }
      }
    }
    for (i = 0; i < cnt; i++) {
      if (minX[i] == LONG_LONG_MAX) {
        minX[i] = minX[cnt - 1];
        maxX[i] = minX[cnt - 1];
        minY[i] = minY[cnt - 1];
        maxY[i] = minY[cnt - 1];
        continue;
      }
      if (minX[i] != maxX[i] && minY[i] != maxY[i]) ok = false;
      if (minX[i] == maxX[i]) {
        for (j = minY[i]; j <= maxY[i]; j++) {
          if (a[minX[i]][j] == '.') ok = false;
          x = a[minX[i]][j] - 'a';
          if (x < i) ok = false;
        }
      }
      if (minY[i] == maxY[i]) {
        for (j = minX[i]; j <= maxX[i]; j++) {
          if (a[j][minY[i]] == '.') ok = false;
          x = a[j][minY[i]] - 'a';
          if (x < i) ok = false;
        }
      }
    }
    if (ok) {
      cout << "YES" << endl;
      cout << cnt << endl;
      for (i = 0; i < cnt; i++) {
        cout << minX[i] + 1 << " " << minY[i] + 1 << " " << maxX[i] + 1 << " "
             << maxY[i] + 1 << endl;
      }
    } else
      cout << "NO" << endl;
  }
  return 0;
}
