#include <bits/stdc++.h>
using namespace std;
string S[2002];
int visit[2002][2002];
vector<pair<int, int> > X[26];
vector<pair<pair<int, int>, pair<int, int> > > F;
pair<int, int> func(int i) {
  int ans1 = 0, ans2 = 0;
  for (auto z : X[i]) {
    int x = z.first, y = z.second;
    if (ans1 && x != ans1)
      ans1 = -1;
    else
      ans1 = x;
    if (ans2 && y != ans2)
      ans2 = -1;
    else
      ans2 = y;
  }
  return make_pair(ans1, ans2);
}
int main() {
  ios::sync_with_stdio(0);
  int T;
  cin >> T;
  while (T--) {
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < N; i++) cin >> S[i];
    for (int i = 0; i < 26; i++) X[i].clear();
    for (int i = 0; i < N; i++)
      for (int j = 0; j < M; j++) {
        visit[i + 1][j + 1] = 0;
        if (S[i][j] >= 'a' && S[i][j] <= 'z')
          X[S[i][j] - 'a'].push_back(make_pair(i + 1, j + 1));
      }
    int ptr = 25, flag = 0, vx = -1, vy = -1;
    F.clear();
    while (ptr >= 0 && X[ptr].empty()) ptr--;
    for (int i = ptr; i >= 0 && flag == 0; i--) {
      if (X[i].empty()) {
        F.push_back({{vx, vy}, {vx, vy}});
        continue;
      }
      pair<int, int> pr = func(i);
      if (pr.first == -1 && pr.second == -1) {
        flag = 1;
        break;
      }
      if (pr.first != -1) {
        int x = pr.first;
        int maxx = -1, minn = M + 1;
        for (auto a : X[i])
          maxx = max(maxx, a.second), minn = min(minn, a.second);
        for (int j = minn; j <= maxx; j++) {
          if (visit[x][j] == 1 || S[x - 1][j - 1] - 'a' == i)
            visit[x][j] = 1, vx = x, vy = j;
          else {
            flag = 1;
            break;
          }
        }
        F.push_back({{x, minn}, {x, maxx}});
      } else {
        int y = pr.second;
        int maxx = -1, minn = N + 1;
        for (auto a : X[i])
          maxx = max(maxx, a.first), minn = min(minn, a.first);
        for (int j = minn; j <= maxx; j++) {
          if (visit[j][y] == 1 || S[j - 1][y - 1] - 'a' == i)
            visit[j][y] = 1, vx = j, vy = y;
          else {
            flag = 1;
            break;
          }
        }
        F.push_back({{minn, y}, {maxx, y}});
      }
    }
    if (flag)
      cout << "NO\n";
    else {
      cout << "YES\n";
      cout << F.size() << "\n";
      reverse(F.begin(), F.end());
      for (auto f : F)
        cout << f.first.first << " " << f.first.second << " " << f.second.first
             << " " << f.second.second << "\n";
    }
  }
  return 0;
}
