#include <bits/stdc++.h>
using namespace std;
template <class t>
t mag(t a) {
  return a > 0 ? a : -a;
}
template <class T, class U>
T cdiv(T num, U den) {
  return (num / den) + ((num % den) > 0);
}
std::ifstream term("/dev/tty");
std::string tempstring;
using ll = int_fast64_t;
using ii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<ii>;
const int sij = 400010;
const ll mod = 1000000007ll;
char vec[2002][2002];
template <class T, class U>
void vax(T &a, U b) {
  a = max(a, b);
}
template <class T, class U>
void vin(T &a, U b) {
  a = min(a, b);
}
int esc(int tcase) {
  int n, m;
  cin >> n >> m;
  vi lef(26), rig(26), top(26), down(26), in(26), out(26);
  for (auto i = 0; i != 26; i++) {
    lef[i] = m;
    rig[i] = -1;
    top[i] = n;
    down[i] = -1;
  }
  for (auto i = 0; i != n; i++) {
    for (auto j = 0; j != m; j++) {
      cin >> vec[i][j];
      if (vec[i][j] != '.') {
        vin(lef[vec[i][j] - 'a'], j);
        vax(rig[vec[i][j] - 'a'], j);
        vin(top[vec[i][j] - 'a'], i);
        vax(down[vec[i][j] - 'a'], i);
      }
    }
  }
  vi it;
  for (auto i = 0; i != 26; i++) {
    if (lef[i] == m) continue;
    it.push_back(i);
    if (lef[i] != rig[i] and top[i] != down[i]) {
      cout << "NO\n";
      return 0;
    }
    if (lef[i] == rig[i] and top[i] == down[i]) {
      continue;
    }
    if (lef[i] == rig[i]) {
      for (auto c = top[i] + 1; c != down[i]; c++) {
        if (vec[c][lef[i]] - 'a' != i) {
          if (vec[c][lef[i]] != '.' and vec[c][lef[i]] - 'a' > i) {
          } else {
            cout << "NO\n";
            return 0;
          }
        }
      }
    } else {
      for (auto c = lef[i] + 1; c != rig[i]; c++) {
        if (vec[top[i]][c] - 'a' != i) {
          if (vec[top[i]][c] - 'a' != '.' and vec[top[i]][c] - 'a' > i) {
          } else {
            cout << "NO\n";
            return 0;
          }
        }
      }
    }
  }
  if (it.empty()) {
    cout << "YES\n0\n";
    return 0;
  }
  int maxi = it.back();
  cout << "YES\n" << maxi + 1 << '\n';
  vi ch(maxi + 1);
  for (auto &e : it) {
    ch[e] = 1;
  };
  for (int e = 0; e <= maxi; e++) {
    if (ch[e] == 0) {
      cout << top[it.back()] + 1 << ' ' << lef[it.back()] + 1 << ' '
           << down[it.back()] + 1 << ' ' << rig[it.back()] + 1 << '\n';
      continue;
    }
    cout << top[e] + 1 << ' ' << lef[e] + 1 << ' ' << down[e] + 1 << ' '
         << rig[e] + 1 << '\n';
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tc = 1;
  cin >> tc;
  for (int i = 1; i <= tc; i++) esc(i);
}
