#include <bits/stdc++.h>
using namespace std;
int a[2005][2005];
int b[2005][2005];
vector<pair<int, int> > v[30];
vector<int> ans[30];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while (T--) {
    for (int i = 0; i <= 26; i++) {
      v[i].clear();
      ans[i].clear();
    }
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        b[i][j] = -1;
        char ch;
        cin >> ch;
        if (ch == '.')
          a[i][j] = -1;
        else {
          a[i][j] = ch - 'a';
          v[a[i][j]].push_back(make_pair(i, j));
        }
      }
    }
    int flag = 1;
    int to = -1;
    for (int i = 0; i < 26; i++) {
      if (v[i].size() == 0)
        continue;
      else if (v[i].size() >= 3) {
        int k1 = 1, k2 = 1;
        for (int j = 0; j < v[i].size(); j++) {
          for (int k = 0; k < j; k++) {
            if (v[i][j].first != v[i][k].first) {
              k1 = 0;
              break;
            }
          }
        }
        for (int j = 0; j < v[i].size(); j++) {
          for (int k = 0; k < j; k++) {
            if (v[i][j].second != v[i][k].second) {
              k2 = 0;
              break;
            }
          }
        }
        if (k1) {
          int x = v[i][0].first;
          int mi = 10000, mx = 0;
          for (int j = 0; j < v[i].size(); j++) {
            mi = min(mi, v[i][j].second);
            mx = max(mx, v[i][j].second);
          }
          ans[i].push_back(x);
          ans[i].push_back(mi);
          ans[i].push_back(x);
          ans[i].push_back(mx);
          for (int j = mi; j <= mx; j++) b[x][j] = i;
          to = i;
        } else if (k2) {
          int y = v[i][0].second;
          int mi = 10000, mx = 0;
          for (int j = 0; j < v[i].size(); j++) {
            mi = min(mi, v[i][j].first);
            mx = max(mx, v[i][j].first);
          }
          ans[i].push_back(mi);
          ans[i].push_back(y);
          ans[i].push_back(mx);
          ans[i].push_back(y);
          for (int j = mi; j <= mx; j++) b[j][y] = i;
          to = i;
        } else {
          flag = 0;
          break;
        }
      } else if (v[i].size() == 1) {
        int x = v[i][0].first, y = v[i][0].second;
        ans[i].push_back(x);
        ans[i].push_back(y);
        ans[i].push_back(x);
        ans[i].push_back(y);
        b[x][y] = i;
        to = i;
      } else if (v[i].size() == 2) {
        int x = v[i][0].first, y = v[i][0].second;
        int xx = v[i][1].first, yy = v[i][1].second;
        ans[i].push_back(x);
        ans[i].push_back(y);
        ans[i].push_back(xx);
        ans[i].push_back(yy);
        if (x == xx) {
          for (int j = min(y, yy); j <= max(y, yy); j++) b[x][j] = i;
          to = i;
        } else if (y == yy) {
          for (int j = min(x, xx); j <= max(x, xx); j++) b[j][y] = i;
          to = i;
        } else {
          flag = 0;
          break;
        }
      }
    }
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) {
        if (a[i][j] != b[i][j]) {
          flag = 0;
          break;
        }
      }
    if (flag) {
      cout << "YES" << endl;
      cout << to + 1 << endl;
      for (int i = 0; i <= to; i++) {
        if (ans[i].size() == 0) {
          for (int j = 0; j < ans[to].size(); j++) cout << ans[to][j] << ' ';
          cout << endl;
          continue;
        }
        for (int j = 0; j < ans[i].size(); j++) cout << ans[i][j] << ' ';
        cout << endl;
      }
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
