#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2001;
char g[MAX_N][MAX_N];
pair<int, int> s[256][2];
int n, m;
bool check() {
  for (int i = 'a'; i <= 'z'; ++i) {
    if (s[i][0].first == -1) {
      return false;
    }
    if (s[i][0].first == 0) {
      continue;
    }
    if (s[i][0].first == s[i][1].first) {
      for (int j = s[i][0].second; j <= s[i][1].second; ++j) {
        if (g[s[i][0].first][j] < i) {
          return false;
        }
      }
    } else if (s[i][0].second == s[i][1].second) {
      for (int j = s[i][0].first; j <= s[i][1].first; ++j) {
        if (g[j][s[i][0].second] < i) {
          return false;
        }
      }
    } else {
      return false;
    }
  }
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    for (int i = 'a'; i <= 'z'; ++i) {
      s[i][0].first = 0;
      s[i][0].second = 0;
      s[i][1].first = 0;
      s[i][1].second = 0;
    }
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= m; ++j) {
        cin >> g[i][j];
        if (g[i][j] != '.' && s[g[i][j]][0].first != -1) {
          if (s[g[i][j]][0].first == 0) {
            s[g[i][j]][0].first = i;
            s[g[i][j]][0].second = j;
            s[g[i][j]][1].first = i;
            s[g[i][j]][1].second = j;
          } else if ((s[g[i][j]][0].first == s[g[i][j]][1].first &&
                      s[g[i][j]][0].first == i) ||
                     (s[g[i][j]][0].second == s[g[i][j]][1].second &&
                      s[g[i][j]][0].second == j)) {
            s[g[i][j]][1].first = i;
            s[g[i][j]][1].second = j;
          } else {
            s[g[i][j]][0].first = -1;
          }
        }
      }
    }
    if (check()) {
      int k = 0;
      for (int i = 'a'; i <= 'z'; ++i) {
        if (s[i][0].first != 0) {
          k = i;
        }
      }
      cout << "YES" << '\n';
      cout << max(k - 'a' + 1, 0) << '\n';
      for (int i = 'a'; i <= k; ++i) {
        if (s[i][0].first == 0) {
          cout << s[k][0].first << ' ' << s[k][0].second << ' ' << s[k][1].first
               << ' ' << s[k][1].second << '\n';
        } else {
          cout << s[i][0].first << ' ' << s[i][0].second << ' ' << s[i][1].first
               << ' ' << s[i][1].second << '\n';
        }
      }
    } else {
      cout << "NO" << '\n';
    }
  }
  return 0;
}
