#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t, n, m;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    vector<vector<int>> mat(n + 2, vector<int>(m + 2, -1));
    int total = -1;
    vector<pair<int, int>> corx(26, make_pair(-1, -1));
    vector<pair<int, int>> cory(26, make_pair(-1, -1));
    int flag = 1;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        char ch;
        cin >> ch;
        if (ch == '.')
          mat[i][j] = -1;
        else {
          mat[i][j] = (ch - 'a');
          if (corx[ch - 'a'].first == -1)
            corx[ch - 'a'].first = i;
          else if (corx[ch - 'a'].second == -1)
            corx[ch - 'a'].second = i;
          else {
            if (corx[ch - 'a'].second < corx[ch - 'a'].first) flag = 0;
            corx[ch - 'a'].first = min(corx[ch - 'a'].first, i);
            corx[ch - 'a'].second = max(corx[ch - 'a'].second, i);
          }
          if (cory[ch - 'a'].first == -1)
            cory[ch - 'a'].first = j;
          else if (cory[ch - 'a'].second == -1)
            cory[ch - 'a'].second = j;
          else {
            if (cory[ch - 'a'].second < cory[ch - 'a'].first) flag = 0;
            cory[ch - 'a'].first = min(cory[ch - 'a'].first, j);
            cory[ch - 'a'].second = max(cory[ch - 'a'].second, j);
          }
        }
        total = max(total, mat[i][j]);
      }
    }
    if (total == -1) {
      cout << "YES" << endl;
      cout << 0 << endl;
      continue;
    }
    vector<pair<pair<int, int>, pair<int, int>>> ans(total + 1);
    for (int i = 0; i <= total; i++) {
      if (corx[i].first == -1 && corx[i].second == -1) {
        ans[i] = make_pair(make_pair(-1, -1), make_pair(-1, -1));
        continue;
      }
      if (corx[i].second == -1) {
        ans[i] = make_pair(make_pair(corx[i].first, cory[i].first),
                           make_pair(corx[i].first, cory[i].first));
        continue;
      }
      if (corx[i].first != corx[i].second && cory[i].first == cory[i].second) {
        for (int j = corx[i].first; j <= corx[i].second; j++) {
          if (mat[j][cory[i].first] < i) {
            flag = 0;
            break;
          }
        }
        ans[i] = make_pair(make_pair(corx[i].first, cory[i].first),
                           make_pair(corx[i].second, cory[i].second));
      } else if (corx[i].first == corx[i].second &&
                 cory[i].first != cory[i].second) {
        for (int j = cory[i].first; j <= cory[i].second; j++) {
          if (mat[corx[i].first][j] < i) {
            flag = 0;
            break;
          }
        }
        ans[i] = make_pair(make_pair(corx[i].first, cory[i].first),
                           make_pair(corx[i].second, cory[i].second));
      } else {
        flag = 0;
        break;
      }
    }
    if (flag == 0) {
      cout << "NO" << endl;
    } else {
      cout << "YES" << endl;
      cout << total + 1 << endl;
      for (int i = 0; i <= total; i++) {
        if (ans[i].first.first == -1) {
          int j = i;
          while (ans[j].first.first == -1) j++;
          cout << ans[j].first.first << " " << ans[j].first.second << " "
               << ans[j].first.first << " " << ans[j].first.second << endl;
        } else
          cout << ans[i].first.first << " " << ans[i].first.second << " "
               << ans[i].second.first << " " << ans[i].second.second << endl;
      }
    }
  }
  return 0;
}
