#include <bits/stdc++.h>
using namespace std;
const int N = 2000;
char grid[N + 5][N + 5];
char ans[N + 5][N + 5];
void draw(int x1, int y1, int x2, int y2, char x) {
  for (int i = x1; i <= x2; ++i) {
    for (int j = y1; j <= y2; ++j) {
      ans[i][j] = x;
    }
  }
}
int n, m;
int r[26], c[26];
int cr[26], cc[26];
int mxr[26], mxc[26];
bool fail() {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (ans[i][j] != grid[i][j]) return true;
    }
  }
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    for (int i = 0; i < 26; ++i)
      r[i] = c[i] = mxr[i] = mxc[i] = -1, cc[i] = cr[i] = 0;
    int mx = 0;
    bool bend = false;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        char x;
        cin >> x;
        grid[i][j] = x;
        ans[i][j] = '.';
        if (isalpha(x)) {
          mx = max(mx, x - 'a' + 1);
          if (r[x - 'a'] == -1)
            r[x - 'a'] = i, c[x - 'a'] = j;
          else {
            if (r[x - 'a'] == i)
              cr[x - 'a']++;
            else if (c[x - 'a'] == j)
              cc[x - 'a']++;
            else
              bend = true;
          }
          mxr[x - 'a'] = max(mxr[x - 'a'], i);
          mxc[x - 'a'] = max(mxc[x - 'a'], j);
        }
      }
    }
    for (int i = 0; i < mx; ++i) {
      if (cr[i] > 0 && cc[i] > 0) bend = true;
    }
    if (bend) {
      cout << "NO" << endl;
      continue;
    }
    for (int i = 0; i < mx; ++i) {
      if (r[i] != -1) continue;
      for (int j = i + 1; j < mx; ++j) {
        if (r[j] != -1) {
          r[i] = mxr[i] = r[j];
          c[i] = mxc[i] = c[j];
          break;
        }
      }
    }
    for (int i = 0; i < mx; ++i) {
      draw(r[i], c[i], mxr[i], mxc[i], i + 'a');
    }
    if (fail())
      cout << "NO" << endl;
    else {
      cout << "YES" << endl;
      cout << mx << endl;
      for (int i = 0; i < mx; ++i) {
        cout << r[i] + 1 << " " << c[i] + 1 << " " << mxr[i] + 1 << " "
             << mxc[i] + 1 << endl;
      }
    }
  }
}
