#include <bits/stdc++.h>
using namespace std;
char A[2005][2005], B[2005][2005];
int last_valid;
pair<int, int> lb[26], ub[26];
bool ans;
void _clear(int n, int m) {
  for (int i = 0; i < 26; ++i) {
    lb[i] = make_pair(INT_MAX, INT_MAX);
    ub[i] = make_pair(INT_MIN, INT_MIN);
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      B[i][j] = '.';
    }
  }
  ans = true;
  last_valid = -1;
}
void _populate(int n, int m) {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (A[i][j] == '.') continue;
      char c = A[i][j] - 'a';
      lb[c].first = min(lb[c].first, i);
      lb[c].second = min(lb[c].second, j);
      ub[c].first = max(ub[c].first, i);
      ub[c].second = max(ub[c].second, j);
    }
  }
}
void _regenerate() {
  for (int i = 0; i < 26; ++i) {
    if (lb[i].first != INT_MAX) {
      last_valid = i;
      if (lb[i].first == ub[i].first) {
        int x = lb[i].first;
        for (int j = lb[i].second; j <= ub[i].second; ++j) B[x][j] = i + 'a';
      } else if (lb[i].second == ub[i].second) {
        int x = lb[i].second;
        for (int j = lb[i].first; j <= ub[i].first; ++j) B[j][x] = i + 'a';
      } else
        ans = false;
    }
  }
}
void _compare(int n, int m) {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (A[i][j] != B[i][j]) ans = false;
    }
  }
}
void _print() {
  if (!ans) {
    cout << "NO" << endl;
    return;
  }
  cout << "YES" << endl;
  cout << last_valid + 1 << endl;
  for (int i = 0; i <= last_valid; ++i) {
    if (lb[i].first != INT_MAX) {
      cout << lb[i].first + 1 << " " << lb[i].second + 1 << " "
           << ub[i].first + 1 << " " << ub[i].second + 1 << endl;
    } else {
      int x = last_valid;
      cout << lb[x].first + 1 << " " << lb[x].second + 1 << " "
           << ub[x].first + 1 << " " << ub[x].second + 1 << endl;
    }
  }
}
void _debug(int n, int m) {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) cout << A[i][j] << " ";
    cout << endl;
  }
  cout << endl;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) cout << B[i][j] << " ";
    cout << endl;
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  int t, n, m, i, j, k, x, y, z, a, b, c;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    for (i = 0; i < n; ++i) cin >> A[i];
    _clear(n, m);
    _populate(n, m);
    _regenerate();
    _compare(n, m);
    _print();
  }
  return 0;
}
