#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  std::cout.precision(12);
  int t;
  cin >> t;
  while (t--) {
    bool f = 0;
    int n, m;
    cin >> n >> m;
    char a[n][m];
    char ans[n][m];
    vector<pair<int, int>> v[26];
    int ma = -1;
    int r, c;
    for (long long int i = 0; i < n; i++) {
      for (long long int j = 0; j < m; j++) {
        cin >> a[i][j];
        ans[i][j] = '.';
        if (a[i][j] >= 97 && a[i][j] <= 'z') {
          v[a[i][j] - 'a'].push_back({i + 1, j + 1});
          if (a[i][j] - 'a' > ma) {
            ma = a[i][j] - 'a';
            r = i + 1;
            c = j + 1;
          }
        }
      }
    }
    vector<pair<int, int>> start[ma + 1], end[ma + 1];
    for (long long int i = 0; i < ma + 1; i++) {
      if (v[i].size() == 0) {
        start[i].push_back({r, c});
        end[i].push_back({r, c});
      } else if (v[i].size() == 1) {
        ans[v[i][0].first - 1][v[i][0].second - 1] = 'a' + i;
        start[i].push_back({v[i][0].first, v[i][0].second});
        end[i].push_back({v[i][0].first, v[i][0].second});
      } else {
        if (v[i][1].first == v[i][0].first) {
          int mi = m + 6, m = 0;
          for (int j = 0; j < v[i].size(); j++) {
            if (v[i][j].first != v[i][0].first) {
              f = 1;
              break;
            }
            mi = min(mi, v[i][j].second);
            m = max(m, v[i][j].second);
          }
          if (f == 1) break;
          for (int j = mi - 1; j < m; j++) {
            ans[v[i][0].first - 1][j] = 'a' + i;
          }
          start[i].push_back({v[i][0].first, mi});
          end[i].push_back({v[i][0].first, m});
        } else if (v[i][1].second == v[i][0].second) {
          int mi = n + 6, m = 0;
          for (int j = 0; j < v[i].size(); j++) {
            if (v[i][j].second != v[i][0].second) {
              f = 1;
              break;
            }
            mi = min(mi, v[i][j].first);
            m = max(m, v[i][j].first);
          }
          if (f == 1) break;
          for (int j = mi - 1; j < m; j++) {
            ans[j][v[i][0].second - 1] = 'a' + i;
          }
          start[i].push_back({mi, v[i][0].second});
          end[i].push_back({m, v[i][0].second});
        } else {
          f = 1;
          break;
        }
      }
    }
    for (long long int i = 0; i < n; i++) {
      for (long long int j = 0; j < m; j++) {
        if (a[i][j] != ans[i][j]) {
          f = 1;
          break;
        }
      }
      if (f == 1) break;
    }
    if (f == 0) {
      cout << "YES\n";
      cout << ma + 1 << endl;
      for (long long int i = 0; i < ma + 1; i++)
        cout << start[i][0].first << " " << start[i][0].second << " "
             << end[i][0].first << " " << end[i][0].second << endl;
    } else {
      cout << "NO\n";
    }
  }
}
